Skip to content

Commit

Permalink
Merge pull request #35 from rieschl/feat/php8
Browse files Browse the repository at this point in the history
  • Loading branch information
boesing committed Oct 31, 2020
2 parents 7f0b1d0 + f633855 commit 990a9d1
Show file tree
Hide file tree
Showing 44 changed files with 1,846 additions and 1,975 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/laminas-mkdoc-theme/
/phpunit.xml
/vendor/
.phpunit.result.cache
39 changes: 14 additions & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,47 +19,36 @@ services:
matrix:
fast_finish: true
include:
- php: 5.6
env:
- DEPS=lowest
- php: 5.6
env:
- DEPS=latest
- php: 7
env:
- DEPS=lowest
- php: 7
env:
- DEPS=latest
- php: 7.1
env:
- DEPS=lowest
- php: 7.1
- php: 7.3
env:
- DEPS=latest
- CS_CHECK=true
- TEST_COVERAGE=true
- php: 7.2
- php: 7.3
env:
- DEPS=lowest
- php: 7.2
env:
- DEPS=latest
- php: 7.3
- php: 7.4
env:
- DEPS=lowest
- php: 7.3
- php: 7.4
env:
- DEPS=latest
- php: 7.4
- php: nightly
env:
- DEPS=lowest
- COMPOSER_ARGS="--no-interaction --ignore-platform-reqs"
- SKIP_MONGODB=true # ext-mongodb does not build on php8 yet (https://github.com/mongodb/mongo-php-driver/issues/1161)
- php: nightly
env:
- DEPS=latest
- COMPOSER_ARGS="--no-interaction --ignore-platform-reqs"
- SKIP_MONGODB=true # ext-mongodb does not build on php8 yet (https://github.com/mongodb/mongo-php-driver/issues/1161)

before_install:
- if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
- pecl channel-update pecl.php.net
- pecl -q upgrade mongodb
- $(php -m | grep -q mongodb) || echo "extension=mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- if [[ $SKIP_MONGODB != 'true' ]]; then pecl -q upgrade mongodb ; fi
- if [[ $SKIP_MONGODB != 'true' ]]; then $(php -m | grep -q mongodb) || echo "extension=mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini ; fi
- psql -c 'create database laminas_session_test;' -U postgres
- mysql -e 'CREATE DATABASE laminas_session_test;'

Expand Down
18 changes: 15 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,31 @@ All notable changes to this project will be documented in this file, in reverse

### Added

- Nothing.
- [#35](https://github.com/laminas/laminas-session/pull/35) Adds PHP 8.0 support

### Changed

- Nothing.

### Deprecated

- Nothing.
- [#35](https://github.com/laminas/laminas-session/pull/35) Marks some methods in `StandardConfig` and `SessionConfig` as deprecated as the functionality behind these methods was dropped in PHP 7.1
- `StandardConfig::setEntropyFile`
- `StandardConfig::getEntropyFile`
- `StandardConfig::setEntropyLength`
- `StandardConfig::getEntropyLength`
- `StandardConfig::setHashFunction`
- `StandardConfig::getHashFunction`
- `StandardConfig::setHashBitsPerCharacter`
- `StandardConfig::getHashBitsPerCharacter`
- `SessionConfig::setHashFunction`
- `SessionConfig::setHashBitsPerCharacter`

- [#35](https://github.com/laminas/laminas-session/pull/35) Marks the `AbstractValidatorChain`, `ValidatorChainTrait` and `AbstractValidatorChainEM3` as deprecated as they can be replaced by using the `ValidatorChain` instead.

### Removed

- Nothing.
- [#35](https://github.com/laminas/laminas-session/pull/35) Removed compatibility with laminas-eventmanager v2

### Fixed

Expand Down
12 changes: 5 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
}
},
"require": {
"php": "^5.6 || ^7.0",
"laminas/laminas-eventmanager": "^2.6.2 || ^3.0",
"php": "^7.3 || ~8.0.0",
"laminas/laminas-eventmanager": "^3.0",
"laminas/laminas-stdlib": "^3.2.1",
"laminas/laminas-zendframework-bridge": "^1.0"
},
Expand All @@ -36,11 +36,12 @@
"laminas/laminas-coding-standard": "~1.0.0",
"laminas/laminas-db": "^2.7",
"laminas/laminas-http": "^2.5.4",
"laminas/laminas-servicemanager": "^2.7.5 || ^3.0.3",
"laminas/laminas-servicemanager": "^3.0.3",
"laminas/laminas-validator": "^2.6",
"mongodb/mongodb": "^1.0.1",
"php-mock/php-mock-phpunit": "^1.1.2 || ^2.0",
"phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.5.20"
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.3"
},
"suggest": {
"laminas/laminas-cache": "Laminas\\Cache component",
Expand All @@ -56,9 +57,6 @@
}
},
"autoload-dev": {
"files": [
"test/autoload.php"
],
"psr-4": {
"LaminasTest\\Session\\": "test/"
}
Expand Down
17 changes: 8 additions & 9 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@
</exclude>
</groups>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<coverage>
<include>
<directory suffix=".php">./src</directory>
<exclude>
<file>src/compatibility/autoload.php</file>
<file>src/Validator/AbstractValidatorChainEM2.php</file>
</exclude>
</whitelist>
</filter>
</include>
<exclude>
<file>src/compatibility/autoload.php</file>
</exclude>
</coverage>

<php>
<ini name="date.timezone" value="UTC"/>
<ini name="date.timezone" value="UTC" />

<!-- OB_ENABLED should be enabled for some tests to check if all
functionality works as expected. Such tests include those for
Expand Down
16 changes: 16 additions & 0 deletions src/AbstractValidatorChain.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace Laminas\Session;

use Laminas\Session\Validator\AbstractValidatorChainEM3;

/**
* Dummy class to keep backwards compatibility
*
* @deprecated Use {@see \Laminas\Session\ValidatorChain} directly
*/
abstract class AbstractValidatorChain extends AbstractValidatorChainEM3
{
}
2 changes: 2 additions & 0 deletions src/Config/SessionConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ public function setCacheLimiter($cacheLimiter)
* @param string|int $hashFunction
* @return SessionConfig
* @throws Exception\InvalidArgumentException
* @deprecated removed in PHP 7.1
*/
public function setHashFunction($hashFunction)
{
Expand All @@ -308,6 +309,7 @@ public function setHashFunction($hashFunction)
* @param int $hashBitsPerCharacter
* @return SessionConfig
* @throws Exception\InvalidArgumentException
* @deprecated removed in PHP 7.1
*/
public function setHashBitsPerCharacter($hashBitsPerCharacter)
{
Expand Down
8 changes: 8 additions & 0 deletions src/Config/StandardConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ public function getUseCookies()
* @param string $entropyFile
* @return StandardConfig
* @throws Exception\InvalidArgumentException
* @deprecated removed in PHP 7.1
*/
public function setEntropyFile($entropyFile)
{
Expand All @@ -605,6 +606,7 @@ public function setEntropyFile($entropyFile)
* Get session.entropy_file
*
* @return string
* @deprecated removed in PHP 7.1
*/
public function getEntropyFile()
{
Expand All @@ -625,6 +627,7 @@ public function getEntropyFile()
* @param int $entropyLength
* @return StandardConfig
* @throws Exception\InvalidArgumentException
* @deprecated removed in PHP 7.1
*/
public function setEntropyLength($entropyLength)
{
Expand All @@ -648,6 +651,7 @@ public function setEntropyLength($entropyLength)
* Get session.entropy_length
*
* @return string
* @deprecated removed in PHP 7.1
*/
public function getEntropyLength()
{
Expand Down Expand Up @@ -704,6 +708,7 @@ public function getCacheExpire()
*
* @param string $hashFunction
* @return mixed
* @deprecated removed in PHP 7.1
*/
public function setHashFunction($hashFunction)
{
Expand All @@ -718,6 +723,7 @@ public function setHashFunction($hashFunction)
* Get session.hash_function
*
* @return string
* @deprecated removed in PHP 7.1
*/
public function getHashFunction()
{
Expand All @@ -734,6 +740,7 @@ public function getHashFunction()
* @param int $hashBitsPerCharacter
* @return StandardConfig
* @throws Exception\InvalidArgumentException
* @deprecated removed in PHP 7.1
*/
public function setHashBitsPerCharacter($hashBitsPerCharacter)
{
Expand All @@ -754,6 +761,7 @@ public function setHashBitsPerCharacter($hashBitsPerCharacter)
* Get session.hash_bits_per_character
*
* @return string
* @deprecated removed in PHP 7.1
*/
public function getHashBitsPerCharacter()
{
Expand Down
55 changes: 0 additions & 55 deletions src/Validator/AbstractValidatorChainEM2.php

This file was deleted.

2 changes: 2 additions & 0 deletions src/Validator/AbstractValidatorChainEM3.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

/**
* Abstract validator chain for validating sessions (for use with laminas-eventmanager v3)
*
* @deprecated Use {@see \Laminas\Session\ValidatorChain} directly
*/
abstract class AbstractValidatorChainEM3 extends EventManager
{
Expand Down
7 changes: 2 additions & 5 deletions src/Validator/Id.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,15 @@ public function isValid()
{
$id = $this->id;
$saveHandler = ini_get('session.save_handler');
if ($saveHandler == 'cluster') { // Zend Server SC, validate only after last dash
if ($saveHandler === 'cluster') { // Zend Server SC, validate only after last dash
$dashPos = strrpos($id, '-');
if ($dashPos) {
$id = substr($id, $dashPos + 1);
}
}

// Get the session id bits per character INI setting, using 5 if unavailable
$bitsPerCharacter = PHP_VERSION_ID >= 70100
? 'session.sid_bits_per_character'
: 'session.hash_bits_per_character';
$hashBitsPerChar = ini_get($bitsPerCharacter) ?: 5;
$hashBitsPerChar = ini_get('session.sid_bits_per_character') ?: 5;

switch ($hashBitsPerChar) {
case 4:
Expand Down
2 changes: 2 additions & 0 deletions src/Validator/ValidatorChainTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

/**
* Base trait for validator chain implementations
*
* @deprecated Use {@see \Laminas\Session\ValidatorChain} directly
*/
trait ValidatorChainTrait
{
Expand Down
Loading

0 comments on commit 990a9d1

Please sign in to comment.