Skip to content

Commit

Permalink
Bump PHP to 8.1 (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik authored Feb 20, 2025
1 parent 98b8cba commit a57dee0
Show file tree
Hide file tree
Showing 26 changed files with 100 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.0']
['8.1']
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
os: >-
['ubuntu-latest', 'windows-latest']
php: >-
['8.0', '8.1', '8.2', '8.3']
['8.1', '8.2', '8.3']
2 changes: 1 addition & 1 deletion .github/workflows/composer-require-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.0', '8.1', '8.2', '8.3']
['8.1', '8.2', '8.3']
8 changes: 0 additions & 8 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,3 @@ jobs:
['ubuntu-latest']
php: >-
['8.1', '8.2', '8.3']
psalm80:
uses: yiisoft/actions/.github/workflows/psalm.yml@master
with:
psalm-config: psalm80.xml
os: >-
['ubuntu-latest']
php: >-
['8.0']
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ composer.phar
# Mac DS_Store Files
.DS_Store

# phpunit itself is not needed
phpunit.phar
# local phpunit config
# PHPUnit
/phpunit.phar
/phpunit.xml
# phpunit cache
.phpunit.result.cache
/.phpunit.cache


2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- Chg #207: Replace two `RouteCollectorInterface` methods `addRoute()` and `addGroup()` to single `addRoute()` (@vjik)
- Chg #222: Make `Route`, `Group` and `MatchingResult` dispatcher-independent (@rustamwin, @vjik)
- Enh #229: Add URL arguments' psalm type in `UrlGeneratorInterface` (@vjik)
- Chg #256: Bump minimum PHP version to 8.1 (@vjik)
- Enh #256: Mark readonly properties (@vjik)

## 3.1.0 February 20, 2024

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ with an adapter package. Currently, the only adapter available is [FastRoute](ht

## Requirements

- PHP 8.0 or higher.
- PHP 8.1 or higher.

## Installation

Expand Down
3 changes: 2 additions & 1 deletion composer-require-checker.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"Symfony\\Component\\Console\\Input\\InputArgument",
"Symfony\\Component\\Console\\Input\\InputInterface",
"Symfony\\Component\\Console\\Output\\OutputInterface",
"Symfony\\Component\\Console\\Style\\SymfonyStyle"
"Symfony\\Component\\Console\\Style\\SymfonyStyle",
"Symfony\\Component\\Console\\Attribute\\AsCommand"
]
}
33 changes: 18 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,30 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"psr/event-dispatcher": "^1.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0|^2.0",
"psr/http-message": "^1.0 || ^2.0",
"psr/http-server-handler": "^1.0",
"psr/http-server-middleware": "^1.0",
"yiisoft/http": "^1.2",
"yiisoft/middleware-dispatcher": "^5.0",
"yiisoft/router-implementation": "1.0.0"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.4",
"nyholm/psr7": "^1.5",
"phpunit/phpunit": "^9.5",
"psr/container": "^1.1|^2.0",
"rector/rector": "^2.0",
"roave/infection-static-analysis-plugin": "^1.18",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.22",
"yiisoft/di": "^1.0",
"yiisoft/dummy-provider": "^1.0.0",
"yiisoft/hydrator": "^1.0",
"yiisoft/test-support": "^3.0",
"yiisoft/yii-debug": "dev-master|dev-php80"
"maglnet/composer-require-checker": "^4.7.1",
"nyholm/psr7": "^1.8.2",
"phpunit/phpunit": "^10.5.45",
"psr/container": "^1.1 || ^2.0.2",
"rector/rector": "^2.0.9",
"roave/infection-static-analysis-plugin": "^1.35",
"spatie/phpunit-watcher": "^1.24",
"vimeo/psalm": "^5.26.1 || ^6.7.1",
"yiisoft/di": "^1.3",
"yiisoft/dummy-provider": "^1.0.1",
"yiisoft/hydrator": "^1.5",
"yiisoft/test-support": "^3.0.1",
"yiisoft/yii-debug": "dev-master"
},
"autoload": {
"psr-4": {
Expand All @@ -78,13 +78,16 @@
},
"config": {
"sort-packages": true,
"bump-after-update": "dev",
"allow-plugins": {
"infection/extension-installer": true,
"composer/package-versions-deprecated": true,
"yiisoft/config": false
}
},
"scripts": {
"composer-require-checker": "composer-require-checker",
"rector": "rector",
"test": "phpunit --testdox --no-interaction",
"test-watch": "phpunit-watcher watch"
}
Expand Down
33 changes: 16 additions & 17 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit
bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
failOnRisky="true"
failOnWarning="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false"
executionOrder="random"
resolveDependencies="true"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
requireCoverageMetadata="false"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
executionOrder="random"
failOnRisky="true"
failOnWarning="true"
stopOnFailure="false"
colors="true"
displayDetailsOnPhpunitDeprecations="true"
>
<php>
<ini name="error_reporting" value="-1"/>
Expand All @@ -23,10 +23,9 @@
</testsuite>
</testsuites>

<coverage>
<source>
<include>
<directory>./src</directory>
<directory>./config</directory>
<directory suffix=".php">./src</directory>
</include>
</coverage>
</source>
</phpunit>
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
<RiskyTruthyFalsyComparison errorLevel="suppress" />
<MissingOverrideAttribute errorLevel="suppress" />
</issueHandlers>
</psalm>
19 changes: 0 additions & 19 deletions psalm80.xml

This file was deleted.

24 changes: 12 additions & 12 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withPhpSets(php81: true)
->withRules([
InlineConstructorDefaultToPropertyRector::class,
])
->withSkip([
ClosureToArrowFunctionRector::class,
NullToStrictStringFuncCallArgRector::class,
]);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_80,
]);
};
17 changes: 11 additions & 6 deletions src/Debug/DebugRoutesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Yiisoft\Router\Debug;

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -14,23 +15,27 @@
use Yiisoft\VarDumper\VarDumper;
use Yiisoft\Yii\Debug\Debugger;

/**
* @infection-ignore-all
*/
#[AsCommand(
name: DebugRoutesCommand::COMMAND_NAME,
description: 'Show information about registered routes'
)]
final class DebugRoutesCommand extends Command
{
public const COMMAND_NAME = 'debug:routes';
protected static $defaultName = self::COMMAND_NAME;

public function __construct(
private RouteCollectionInterface $routeCollection,
private Debugger $debugger,
private readonly RouteCollectionInterface $routeCollection,
private readonly Debugger $debugger,
) {
parent::__construct();
}

protected function configure(): void
{
$this
->setDescription('Show information about registered routes')
->addArgument('route', InputArgument::IS_ARRAY, 'Route name');
$this->addArgument('route', InputArgument::IS_ARRAY, 'Route name');
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/Debug/RouterCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
use Yiisoft\Yii\Debug\Collector\CollectorTrait;
use Yiisoft\Yii\Debug\Collector\SummaryCollectorInterface;

/**
* @infection-ignore-all
*/
final class RouterCollector implements SummaryCollectorInterface
{
use CollectorTrait;
Expand Down
7 changes: 5 additions & 2 deletions src/Debug/UrlMatcherInterfaceProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
use Yiisoft\Router\MatchingResult;
use Yiisoft\Router\UrlMatcherInterface;

/**
* @infection-ignore-all
*/
final class UrlMatcherInterfaceProxy implements UrlMatcherInterface
{
public function __construct(
private UrlMatcherInterface $urlMatcher,
private RouterCollector $routerCollector
private readonly UrlMatcherInterface $urlMatcher,
private readonly RouterCollector $routerCollector
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/HydratorAttribute/RouteArgument.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
final class RouteArgument implements ParameterAttributeInterface
{
public function __construct(
private ?string $name = null
private readonly ?string $name = null
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/HydratorAttribute/RouteArgumentResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
final class RouteArgumentResolver implements ParameterAttributeResolverInterface
{
public function __construct(
private CurrentRoute $currentRoute,
private readonly CurrentRoute $currentRoute,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/MatchingResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class MatchingResult
*/
private array $methods = [];

private function __construct(private ?Route $route)
private function __construct(private readonly ?Route $route)
{
}

Expand Down
8 changes: 4 additions & 4 deletions src/Middleware/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

final class Router implements MiddlewareInterface
{
private MiddlewareDispatcher $dispatcher;
private readonly MiddlewareDispatcher $dispatcher;

public function __construct(
private UrlMatcherInterface $matcher,
private ResponseFactoryInterface $responseFactory,
private readonly UrlMatcherInterface $matcher,
private readonly ResponseFactoryInterface $responseFactory,
MiddlewareFactory $middlewareFactory,
private CurrentRoute $currentRoute,
private readonly CurrentRoute $currentRoute,
?EventDispatcherInterface $eventDispatcher = null
) {
$this->dispatcher = new MiddlewareDispatcher($middlewareFactory, $eventDispatcher);
Expand Down
2 changes: 1 addition & 1 deletion src/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class RouteCollection implements RouteCollectionInterface
*/
private array $routes = [];

public function __construct(private RouteCollectorInterface $collector)
public function __construct(private readonly RouteCollectorInterface $collector)
{
}

Expand Down
Loading

0 comments on commit a57dee0

Please sign in to comment.