Skip to content

Commit

Permalink
Allow php 8.4 + composer bump --dev-only + phpunit/phpunit:^10 + lami…
Browse files Browse the repository at this point in the history
…nas/laminas-coding-standard:^3

Signed-off-by: fezfez <[email protected]>

Allow php 8.4 + composer bump --dev-only + phpunit/phpunit:^10 + laminas/laminas-coding-standard:^3
Signed-off-by: fezfez <[email protected]>
  • Loading branch information
fezfez committed Nov 15, 2024
1 parent 90a2646 commit aaef799
Show file tree
Hide file tree
Showing 21 changed files with 525 additions and 535 deletions.
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
}
},
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
"laminas/laminas-eventmanager": "^3.12",
"laminas/laminas-servicemanager": "^3.22",
"laminas/laminas-stdlib": "^3.18"
Expand All @@ -41,14 +41,14 @@
"ext-xdebug": "*",
"laminas/laminas-cache": "^3.12.2",
"laminas/laminas-cache-storage-adapter-memory": "^2.3",
"laminas/laminas-coding-standard": "~2.5.0",
"laminas/laminas-coding-standard": "~3.0.1",
"laminas/laminas-db": "^2.20.0",
"laminas/laminas-http": "^2.19",
"laminas/laminas-validator": "^2.57.0",
"laminas/laminas-http": "^2.20",
"laminas/laminas-validator": "^2.64.1",
"mongodb/mongodb": "~1.20.0",
"phpunit/phpunit": "^9.6.19",
"phpunit/phpunit": "^10.5.38",
"psalm/plugin-phpunit": "^0.19.0",
"vimeo/psalm": "^5.24.0"
"vimeo/psalm": "^5.26.1"
},
"suggest": {
"laminas/laminas-cache": "Laminas\\Cache component",
Expand Down
787 changes: 367 additions & 420 deletions composer.lock

Large diffs are not rendered by default.

91 changes: 47 additions & 44 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,46 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="./vendor/autoload.php"
convertDeprecationsToExceptions="true"
colors="true">
<testsuites>
<testsuite name="laminas-session Test Suite">
<directory>./test/</directory>
</testsuite>
</testsuites>

<groups>
<exclude>
<group>disable</group>
</exclude>
</groups>

<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<file>src/compatibility/autoload.php</file>
</exclude>
</coverage>

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

<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL" value="false" />
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL_HOSTNAME" value="localhost" />
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL_USERNAME" value="travis" />
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL_PASSWORD" value="" />
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL_DATABASE" value="laminas_session_test" />

<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL" value="false" />
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL_HOSTNAME" value="localhost" />
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL_USERNAME" value="travis" />
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL_PASSWORD" value="" />
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL_DATABASE" value="laminas_session_test" />

<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MONGODB" value="false" />
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MONGODB_CONNECTION_STRING" value="mongodb://localhost/" />
</php>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="./vendor/autoload.php"
colors="true"
cacheDirectory=".phpunit.cache"
failOnDeprecation="true"
failOnNotice="true"
failOnWarning="true"
failOnPhpunitDeprecation="true"
displayDetailsOnPhpunitDeprecations="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true">
<testsuites>
<testsuite name="laminas-session Test Suite">
<directory>./test/</directory>
</testsuite>
</testsuites>
<groups>
<exclude>
<group>disable</group>
</exclude>
</groups>
<php>
<ini name="date.timezone" value="UTC"/>
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL" value="false"/>
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL_HOSTNAME" value="localhost"/>
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL_USERNAME" value="travis"/>
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL_PASSWORD" value=""/>
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL_DATABASE" value="laminas_session_test"/>
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL" value="false"/>
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL_HOSTNAME" value="localhost"/>
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL_USERNAME" value="travis"/>
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL_PASSWORD" value=""/>
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL_DATABASE" value="laminas_session_test"/>
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MONGODB" value="false"/>
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MONGODB_CONNECTION_STRING" value="mongodb://localhost/"/>
</php>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<file>src/compatibility/autoload.php</file>
</exclude>
</source>
</phpunit>
2 changes: 2 additions & 0 deletions src/Config/SessionConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ public function setHashBitsPerCharacter($hashBitsPerCharacter)
/**
* Set session.sid_bits_per_character
*
* @deprecated see https://wiki.php.net/rfc/deprecations_php_8_4#sessionsid_length_and_sessionsid_bits_per_character
*
* @param int $sidBitsPerCharacter
* @return SessionConfig
* @throws Exception\InvalidArgumentException
Expand Down
2 changes: 2 additions & 0 deletions src/Config/StandardConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,8 @@ public function getHashBitsPerCharacter()
/**
* Set session.sid_length
*
* @deprecated see https://wiki.php.net/rfc/deprecations_php_8_4#sessionsid_length_and_sessionsid_bits_per_character
*
* @param int $sidLength
* @return StandardConfig
* @throws Exception\InvalidArgumentException
Expand Down
1 change: 0 additions & 1 deletion src/Service/SessionManagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class SessionManagerFactory implements FactoryInterface
* - validators: ...
*
* @param string $requestedName
* @param array $options
* @return SessionManager
*/
public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null)
Expand Down
8 changes: 2 additions & 6 deletions src/SessionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

use function array_key_exists;
use function array_merge;
use function constant;
use function defined;
use function headers_sent;
use function is_array;
use function iterator_to_array;
Expand Down Expand Up @@ -64,8 +62,6 @@ class SessionManager extends AbstractManager
/**
* Constructor
*
* @param array $validators
* @param array $options
* @throws Exception\RuntimeException
*/
public function __construct(
Expand Down Expand Up @@ -94,8 +90,8 @@ public function sessionExists()
if (session_status() === PHP_SESSION_ACTIVE) {
return true;
}
$sid = defined('SID') ? constant('SID') : false;
if ($sid !== false && $this->getId()) {

if ($this->getId()) {
return true;
}
if (headers_sent()) {
Expand Down
1 change: 0 additions & 1 deletion src/Storage/AbstractSessionArrayStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ public function getIterator()
*
* Ensures $_SESSION is set to an instance of the object when complete.
*
* @param array $array
* @return SessionStorage
*/
public function fromArray(array $array)
Expand Down
1 change: 0 additions & 1 deletion src/Storage/ArrayStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ public function clear($key = null)
*
* Overwrites any data that was previously set.
*
* @param array $array
* @return $this
*/
public function fromArray(array $array)
Expand Down
1 change: 0 additions & 1 deletion src/Storage/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ protected static function createArrayStorage($type, $options)
* Create a storage object from a class extending AbstractSessionArrayStorage
*
* @param string $type
* @param array $options
* @return AbstractSessionArrayStorage
* @throws Exception\InvalidArgumentException If the input option is invalid.
*/
Expand Down
1 change: 0 additions & 1 deletion src/Storage/StorageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public function getMetadata($key = null);
public function clear($key = null);

/**
* @param array $array
* @return self
*/
public function fromArray(array $array);
Expand Down
43 changes: 26 additions & 17 deletions test/Config/SessionConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use Laminas\Session\Exception;
use Laminas\Session\Exception\InvalidArgumentException;
use LaminasTest\Session\TestAsset\TestSaveHandler;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use PHPUnit\Framework\TestCase;
use ReflectionProperty;
use SessionHandlerInterface;
Expand All @@ -22,8 +24,7 @@
*/
class SessionConfigTest extends TestCase
{
/** @var SessionConfig */
protected $config;
protected SessionConfig|null $config = null;

protected function setUp(): void
{
Expand Down Expand Up @@ -479,13 +480,15 @@ public function testUseOnlyCookiesDefaultsToIniSettings(): void
self::assertSame((bool) ini_get('session.use_only_cookies'), $this->config->getUseOnlyCookies());
}

#[IgnoreDeprecations]
public function testUseOnlyCookiesIsMutable(): void
{
$value = ! (bool) ini_get('session.use_only_cookies');
$this->config->setOption('use_only_cookies', $value);
self::assertEquals($value, (bool) $this->config->getOption('use_only_cookies'));
}

#[IgnoreDeprecations]
public function testUseOnlyCookiesAltersIniSetting(): void
{
$value = ! (bool) ini_get('session.use_only_cookies');
Expand All @@ -500,6 +503,7 @@ public function testRefererCheckDefaultsToIniSettings(): void
self::assertSame(ini_get('session.referer_check'), $this->config->getRefererCheck());
}

#[IgnoreDeprecations]
public function testRefererCheckIsMutable(): void
{
$this->config->setOption('referer_check', 'FOOBAR');
Expand All @@ -512,6 +516,7 @@ public function testRefererCheckMayBeEmpty(): void
self::assertEquals('', $this->config->getOption('referer_check'));
}

#[IgnoreDeprecations]
public function testRefererCheckAltersIniSetting(): void
{
$this->config->setOption('referer_check', 'BARBAZ');
Expand All @@ -521,7 +526,7 @@ public function testRefererCheckAltersIniSetting(): void
// session.cache_limiter

/** @psalm-return array<array-key, array{0: string}> */
public function cacheLimiters(): array
public static function cacheLimiters(): array
{
return [
[''],
Expand Down Expand Up @@ -602,13 +607,15 @@ public function testUseTransSidDefaultsToIniSettings(): void
self::assertSame((bool) ini_get('session.use_trans_sid'), $this->config->getUseTransSid());
}

#[IgnoreDeprecations]
public function testUseTransSidIsMutable(): void
{
$value = ! (bool) ini_get('session.use_trans_sid');
$this->config->setOption('use_trans_sid', $value);
self::assertEquals($value, (bool) $this->config->getOption('use_trans_sid'));
}

#[IgnoreDeprecations]
public function testUseTransSidAltersIniSetting(): void
{
$value = ! (bool) ini_get('session.use_trans_sid');
Expand All @@ -623,25 +630,29 @@ public function testSidLengthDefaultsToIniSettings(): void
self::assertSame(ini_get('session.sid_length'), $this->config->getSidLength());
}

#[IgnoreDeprecations]
public function testSidLengthIsMutable(): void
{
$this->config->setSidLength(40);
self::assertEquals(40, $this->config->getSidLength());
}

#[IgnoreDeprecations]
public function testSidLengthAltersIniSetting(): void
{
$this->config->setSidLength(40);
self::assertEquals(40, ini_get('session.sid_length'));
}

#[IgnoreDeprecations]
public function testSettingInvalidSidLengthRaisesException(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid length provided');
$this->config->setSidLength('foobar_bogus');
}

#[IgnoreDeprecations]
public function testSettingOutOfRangeSidLengthRaisesException(): void
{
$this->expectException(InvalidArgumentException::class);
Expand All @@ -652,7 +663,7 @@ public function testSettingOutOfRangeSidLengthRaisesException(): void
// session.sid_bits_per_character

/** @psalm-return array<array-key, array{0: int}> */
public function sidSidPerCharacters(): array
public static function sidSidPerCharacters(): array
{
return [
[4],
Expand All @@ -666,31 +677,31 @@ public function testSidBitsPerCharacterDefaultsToIniSettings(): void
self::assertSame(ini_get('session.sid_bits_per_character'), $this->config->getSidBitsPerCharacter());
}

/**
* @dataProvider sidSidPerCharacters
*/
#[DataProvider('sidSidPerCharacters')]
#[IgnoreDeprecations]
public function testSidBitsPerCharacterIsMutable(int $sidBitsPerCharacter): void
{
$this->config->setSidBitsPerCharacter($sidBitsPerCharacter);
self::assertEquals($sidBitsPerCharacter, $this->config->getSidBitsPerCharacter());
}

/**
* @dataProvider sidSidPerCharacters
*/
#[DataProvider('sidSidPerCharacters')]
#[IgnoreDeprecations]
public function testSidBitsPerCharacterAltersIniSetting(int $sidBitsPerCharacter): void
{
$this->config->setSidBitsPerCharacter($sidBitsPerCharacter);
self::assertEquals($sidBitsPerCharacter, ini_get('session.sid_bits_per_character'));
}

#[IgnoreDeprecations]
public function testSettingInvalidSidBitsPerCharacterRaisesException(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid sid bits per character provided');
$this->config->setSidBitsPerCharacter('foobar_bogus');
}

#[IgnoreDeprecations]
public function testSettingOutOfBoundSidBitsPerCharacterRaisesException(): void
{
$this->expectException(InvalidArgumentException::class);
Expand Down Expand Up @@ -731,9 +742,8 @@ public function testRememberMeSecondsIsMutable(): void
}

// setOption
/**
* @dataProvider optionsProvider
*/
#[IgnoreDeprecations]
#[DataProvider('optionsProvider')]
public function testSetOptionSetsIniSetting(string $option, string $getter, mixed $value): void
{
// Leaving out special cases.
Expand Down Expand Up @@ -767,9 +777,8 @@ public function testSetOptionsThrowsExceptionOnInvalidKey(): void
}

// setOptions
/**
* @dataProvider optionsProvider
*/
#[IgnoreDeprecations]
#[DataProvider('optionsProvider')]
public function testSetOptionsTranslatesUnderscoreSeparatedKeys(
string $option,
string $getter,
Expand All @@ -785,7 +794,7 @@ public function testSetOptionsTranslatesUnderscoreSeparatedKeys(
}

/** @psalm-return array<array-key, array{0: string, 1: string, 2: mixed}> */
public function optionsProvider(): array
public static function optionsProvider(): array
{
return [
[
Expand Down
Loading

0 comments on commit aaef799

Please sign in to comment.