Skip to content

Commit

Permalink
Merge pull request #89 from samsonasik/drop-php80
Browse files Browse the repository at this point in the history
[v5] Drop php <8.0 support
  • Loading branch information
samsonasik authored Sep 7, 2024
2 parents f33bc58 + f5e0c4a commit f98e365
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rector_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['7.3']
php-versions: ['8.1']
steps:
- name: Setup PHP Action
uses: shivammathur/setup-php@v2
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ It is a Laminas module as session toolbar for [LaminasDeveloperTools](https://gi

You can reload, clear, add, update, and remove your sessions data.

> This is README for version ^4.0 which only support Laminas 3 with php ^7.3|~8.0.
> This is README for version ^5.0 which only support Laminas 3 with php ^8.1
> For version ^4.0, you can read at [version 4.x.x readme](https://github.com/samsonasik/SanSessionToolbar/blob/4.x.x/README.md) which support Laminas 3 and php ^7.3|~8.0.
> For version ^3.0, you can read at [version 3.x.x readme](https://github.com/samsonasik/SanSessionToolbar/blob/3.x.x/README.md) which support Laminas 3 and php ^7.2.
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
],
"require": {
"php": "^7.3|~8.0",
"php": "^8.1",
"laminas/laminas-json": "^2.5 || ^3.0",
"laminas/laminas-mvc": "^3.0",
"laminas/laminas-session": "^2.8.4"
Expand All @@ -30,9 +30,9 @@
"laminas/laminas-mvc-plugin-flashmessenger": "^1.0",
"laminas/laminas-router": "^3.0",
"laminas/laminas-serializer": "^2.5",
"laminas/laminas-test": "^4.0",
"laminas/laminas-test": "^4.10",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.4",
"phpunit/phpunit": "^10.4",
"rector/rector": "dev-main"
},
"conflict": {
Expand Down
17 changes: 8 additions & 9 deletions rector.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

use Rector\Config\RectorConfig;
use Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\PHPUnit\Set\PHPUnitSetList;

return RectorConfig::configure()
->withPreparedSets(
Expand All @@ -13,16 +14,14 @@
true, // naming
)
->withPhpSets(
false,
false,
false,
false,
false,
true, // php73
php81: true
)
->withSets([
PHPUnitSetList::PHPUNIT_100
])
->withPaths([__DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/test'])
->withRootFiles()
->withImportNames()
->withImportNames(removeUnusedImports: true)
->withSkip([
CallableThisArrayToAnonymousFunctionRector::class,
FirstClassCallableRector::class
]);
2 changes: 1 addition & 1 deletion src/Collector/SessionCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function getPriority()
*/
public function collect(MvcEvent $mvcEvent)
{
$this->data['san-session'] = $this->data['san-session'] ?? [];
$this->data['san-session'] ??= [];
}

/**
Expand Down
14 changes: 1 addition & 13 deletions src/Controller/SessionToolbarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,11 @@
*/
final class SessionToolbarController extends AbstractActionController
{
/**
* @var RendererInterface
*/
private $viewRenderer;

/**
* @var SessionManagerInterface
*/
private $sessionManager;

/**
* Construct.
*/
public function __construct(RendererInterface $viewRenderer, SessionManagerInterface $sessionManager)
public function __construct(private readonly RendererInterface $viewRenderer, private readonly SessionManagerInterface $sessionManager)
{
$this->viewRenderer = $viewRenderer;
$this->sessionManager = $sessionManager;
}

/**
Expand Down
9 changes: 3 additions & 6 deletions test/Collector/SessionCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace SanSessionToolbarTest\Collector;

use PHPUnit\Framework\Attributes\RunInSeparateProcess;
use Laminas\Mvc\MvcEvent;
use Laminas\Session\Container;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -66,9 +67,7 @@ public function testGetPriority()
$this->assertEquals(10, $this->sessionCollector->getPriority());
}

/**
* @runInSeparateProcess
*/
#[RunInSeparateProcess]
public function testGetSessionData()
{
$this->sessionContainer->word = 'zaf8go6i';
Expand Down Expand Up @@ -100,9 +99,7 @@ public function testGetSessionData()
], $this->sessionCollector->getSessionData());
}

/**
* @runInSeparateProcess
*/
#[RunInSeparateProcess]
public function testGetSessionDataForEmpty()
{
$this->sessionContainer->offsetUnset('word');
Expand Down
18 changes: 7 additions & 11 deletions test/Manager/SessionMangerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

namespace SanSessionToolbarTest\Manager;

use PHPUnit\Framework\Attributes\RunInSeparateProcess;
use PHPUnit\Framework\Attributes\DataProvider;
use Laminas\Session\Container;
use PHPUnit\Framework\TestCase;
use SanSessionToolbar\Manager\SessionManager;
Expand All @@ -43,9 +45,7 @@ protected function setUp(): void
$this->manager = new SessionManager();
}

/**
* @runInSeparateProcess
*/
#[RunInSeparateProcess]
public function testSessionIsNotStartedAlready()
{
$sessionManager = new SessionManager();
Expand All @@ -71,9 +71,7 @@ public function testGetSessionData()
$this->assertEquals($sessionData, $this->manager->getSessionData());
}

/**
* @dataProvider provideClearSession
*/
#[DataProvider('provideClearSession')]
public function testClearSession($byContainer, $result)
{
$fooContainer = new Container('Foo');
Expand All @@ -83,17 +81,15 @@ public function testClearSession($byContainer, $result)
$this->assertEquals($result, $this->manager->getSessionData());
}

public function provideClearSession()
public static function provideClearSession()
{
return [
['Default', ['Foo' => ['foo' => 'fooValue']]],
[null, []],
];
}

/**
* @dataProvider provideSessionSettingData
*/
#[DataProvider('provideSessionSettingData')]
public function testSessionSetting($container, $keysession, $value, $options, $result)
{
$fooContainer = new Container('Foo');
Expand All @@ -102,7 +98,7 @@ public function testSessionSetting($container, $keysession, $value, $options, $r
$this->assertEquals($result, $this->manager->sessionSetting($container, $keysession, $value, $options));
}

public function provideSessionSettingData()
public static function provideSessionSettingData()
{
return [
['Default', 'foo', null, [], false],
Expand Down
14 changes: 6 additions & 8 deletions test/ModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

namespace SanSessionToolbarTest;

use PHPUnit\Framework\Attributes\RunInSeparateProcess;
use PHPUnit\Framework\Attributes\DataProvider;
use Laminas\Mvc\MvcEvent;
use Laminas\Mvc\Application;
use Laminas\EventManager\EventManager;
Expand Down Expand Up @@ -49,27 +51,23 @@ protected function setUp(): void
$this->module = new Module();
}

/**
* @runInSeparateProcess
*/
#[RunInSeparateProcess]
public function testOnBootstrapOnSessionNotExists()
{
$objectProphecy = $this->prophesize(MvcEvent::class);
$this->assertNull($this->module->onBootstrap($objectProphecy->reveal()));
}

public function provideHasMessages()
public static function provideHasMessages()
{
return [
[false],
[true],
];
}

/**
* @dataProvider provideHasMessages
* @runInSeparateProcess
*/
#[DataProvider('provideHasMessages')]
#[RunInSeparateProcess]
public function testOnBootstrap($hasMessages)
{
$objectProphecy = $this->prophesize(MvcEvent::class);
Expand Down

0 comments on commit f98e365

Please sign in to comment.