Skip to content

Commit b50a0f1

Browse files
committed
Library modified to be compatible with PHP 5.6 or higher
1 parent ba5daca commit b50a0f1

File tree

7 files changed

+28
-26
lines changed

7 files changed

+28
-26
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CHANGELOG
22

3+
## 1.1.0 - 2017-01-30
4+
* Compatible with PHP 5.6 or higher.
5+
6+
## 1.0.0 - 2017-01-30
7+
* Compatible only with PHP 7.0 or higher. In the next versions, the library will be modified to make it compatible with PHP 5.6 or higher.
8+
39
## 1.0.0 - 2017-01-17
410
* Added `Josantonius\Session\Session` class.
511
* Added `Josantonius\Session\Session::init()` method.

README-ES.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ Para instalar PHP Session library, simplemente escribe:
3232

3333
### Requisitos
3434

35-
Esta ĺibrería es soportada por versiones de PHP 7.0 o superiores y es compatible con versiones de HHVM 3.0 o superiores.
36-
37-
Para utilizar esta librería en HHVM (HipHop Virtual Machine) tendrás que activar los tipos escalares. Añade la siguiente ĺínea "hhvm.php7.scalar_types = true" en tu "/etc/hhvm/php.ini".
35+
Esta ĺibrería es soportada por versiones de PHP 5.6 o superiores y es compatible con versiones de HHVM 3.0 o superiores.
3836

3937
### Cómo empezar y ejemplos
4038

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ To install PHP Session library, simply:
3232

3333
### Requirements
3434

35-
This library is supported by PHP versions 7.0 or higher and is compatible with HHVM versions 3.0 or higher.
36-
37-
To use this library in HHVM (HipHop Virtual Machine) you will have to activate the scalar types. Add the following line "hhvm.php7.scalar_types = true" in your "/etc/hhvm/php.ini".
35+
This library is supported by PHP versions 5.6 or higher and is compatible with HHVM versions 3.0 or higher.
3836

3937
### Quick Start and Examples
4038

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "josantonius/session",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"type": "library",
55
"description": "PHP library for handling sessions.",
66
"keywords": [
@@ -20,7 +20,7 @@
2020
"minimum-stability": "dev",
2121
"prefer-stable" : true,
2222
"require": {
23-
"php" : ">=7.0"
23+
"php" : ">=5.6"
2424
},
2525
"autoload": {
2626
"psr-4": {
@@ -37,4 +37,4 @@
3737
"dev-master": "1.0-dev"
3838
}
3939
}
40-
}
40+
}

src/Exception/SessionException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php declare(strict_types=1);
1+
<?php
22
/**
33
* PHP library for handling sessions.
44
*
@@ -8,9 +8,9 @@
88
* @author Josantonius - [email protected]
99
* @copyright Copyright (c) 2017 JST PHP Framework
1010
* @license https://opensource.org/licenses/MIT - The MIT License (MIT)
11-
* @version 1.0.0
11+
* @version 1.1.0
1212
* @link https://github.com/Josantonius/PHP-Session
13-
* @since File available since 1.0.0 - Update: 2017-01-17
13+
* @since File available since 1.0.0 - Update: 2017-01-30
1414
*/
1515

1616
namespace Josantonius\Session\Exception;
@@ -35,7 +35,7 @@ class SessionException extends \Exception {
3535
* @param int $error → error code (Optional)
3636
* @param int $status → HTTP response status code (Optional)
3737
*/
38-
public function __construct(string $msg = '', int $error = 0, int $status = 0) {
38+
public function __construct($msg = '', $error = 0, $status = 0) {
3939

4040
$this->message = $msg;
4141
$this->code = $error;

src/Session.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php declare(strict_types=1);
1+
<?php
22
/**
33
* PHP library for handling sessions.
44
*
@@ -9,9 +9,9 @@
99
* @author Josantonius - [email protected]
1010
* @copyright Copyright (c) 2017 JST PHP Framework
1111
* @license https://opensource.org/licenses/MIT - The MIT License (MIT)
12-
* @version 1.0.0
12+
* @version 1.1.0
1313
* @link https://github.com/Josantonius/PHP-Session
14-
* @since File available since 1.0.0 - Update: 2017-01-17
14+
* @since File available since 1.0.0 - Update: 2017-01-30
1515
*/
1616

1717
namespace Josantonius\Session;
@@ -48,7 +48,7 @@ class Session {
4848
*
4949
* @since 1.0.0
5050
*/
51-
public static function setPrefix(string $prefix) {
51+
public static function setPrefix($prefix) {
5252

5353
static::$_prefix = $prefix;
5454
}
@@ -76,7 +76,7 @@ public static function init() {
7676
* @param mixed $key → name the data to save
7777
* @param string $value → the data to save
7878
*/
79-
public static function set($key, string $value = false) {
79+
public static function set($key, $value = false) {
8080

8181
/**
8282
* Check whether session is set in array or not
@@ -104,7 +104,7 @@ public static function set($key, string $value = false) {
104104
*
105105
* @return mixed|null → return item or null when key does not exists
106106
*/
107-
public static function pull(string $key) {
107+
public static function pull($key) {
108108

109109
if (isset($_SESSION[static::$_prefix.$key])) {
110110

@@ -138,7 +138,7 @@ public static function get($key, $secondkey = false) {
138138
}
139139
}
140140

141-
return $_SESSION[static::$_prefix.$key] ?? null;
141+
return (isset($_SESSION[static::$_prefix.$key])) ? $_SESSION[static::$_prefix.$key] : null;
142142
}
143143

144144
/**
@@ -148,7 +148,7 @@ public static function get($key, $secondkey = false) {
148148
*
149149
* @return string → the session id
150150
*/
151-
public static function id(): string {
151+
public static function id() {
152152

153153
return session_id();
154154
}
@@ -160,7 +160,7 @@ public static function id(): string {
160160
*
161161
* @return string → session_id
162162
*/
163-
public static function regenerate(): string {
163+
public static function regenerate() {
164164

165165
session_regenerate_id(true);
166166
return session_id();
@@ -173,7 +173,7 @@ public static function regenerate(): string {
173173
*
174174
* @return array → session indexes
175175
*/
176-
public static function display(): array {
176+
public static function display() {
177177

178178
return $_SESSION;
179179
}
@@ -187,7 +187,7 @@ public static function display(): array {
187187
* @param string $key → session name to destroy
188188
* @param boolean $prefix → if set to true clear all sessions for current prefix
189189
*/
190-
public static function destroy(string $key = '', bool $prefix = false) {
190+
public static function destroy($key = '', $prefix = false) {
191191

192192
if (static::$_sessionStarted == true) {
193193

tests/SessionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
* @author Josantonius - [email protected]
99
* @copyright Copyright (c) 2017 JST PHP Framework
1010
* @license https://opensource.org/licenses/MIT - The MIT License (MIT)
11-
* @version 1.0.0
11+
* @version 1.1.0
1212
* @link https://github.com/Josantonius/PHP-Session
13-
* @since File available since 1.0.0 - Update: 2017-01-17
13+
* @since File available since 1.0.0 - Update: 2017-01-30
1414
*/
1515

1616
namespace Josantonius\Session\Tests;

0 commit comments

Comments
 (0)