diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f3443dcb..e512e3bb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,6 +10,7 @@ on: - 'psalm.xml' push: + branches: ['master'] paths-ignore: - 'docs/**' - 'README.md' @@ -39,9 +40,9 @@ jobs: - ubuntu-latest - windows-latest php: - - "8.1" - "8.2" - "8.3" + - "8.4" steps: - name: Checkout. diff --git a/.github/workflows/composer-require-checker.yml b/.github/workflows/composer-require-checker.yml index a857bce6..fda7a3d0 100644 --- a/.github/workflows/composer-require-checker.yml +++ b/.github/workflows/composer-require-checker.yml @@ -31,4 +31,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.1', '8.2', '8.3'] + ['8.2', '8.3', '8.4'] diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index 35411d0a..b2294456 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -20,4 +20,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.3'] + ['8.4'] diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 85925b6c..0c55b585 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -11,6 +11,7 @@ on: - 'phpunit.xml.dist' push: + branches: ['master'] paths-ignore: - 'docs/**' - 'README.md' @@ -30,5 +31,5 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.1', '8.2', '8.3'] + ['8.2', '8.3', '8.4'] diff --git a/.styleci.yml b/.styleci.yml index 1ab379b4..e1210398 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -1,7 +1,7 @@ preset: psr12 risky: true -version: 8.1 +version: 8.2 finder: exclude: diff --git a/Makefile b/Makefile index 67174433..8b859b60 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,9 @@ codecept: run-test psalm: CMD="./vendor/bin/psalm" ## Run Psalm. psalm: run +rector: CMD="./vendor/bin/rector" ## Run Rector. +rector: run + build-prod: ## Build an image. docker build --file docker/Dockerfile --target prod --pull -t ${IMAGE}:${IMAGE_TAG} . diff --git a/composer.json b/composer.json index 532ba04f..40412036 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "yiisoft/app", "type": "project", - "description": "Yii 3 application template", + "description": "Yii3 application template", "keywords": [ "yii3", "app" @@ -25,8 +25,6 @@ "url": "https://github.com/sponsors/yiisoft" } ], - "minimum-stability": "dev", - "prefer-stable": true, "scripts": { "serve": [ "Composer\\Config::disableProcessTimeout", @@ -42,59 +40,56 @@ ] }, "require": { - "php": "^8.1", + "php": "^8.2", "ext-filter": "*", "ext-intl": "*", - "httpsoft/http-message": "^1.1", - "psr/container": "^2.0", - "psr/http-message": "^1.1|^2.0", - "psr/http-server-handler": "^1.0", - "symfony/console": "^6.0", + "httpsoft/http-message": "^1.1.6", + "psr/container": "^2.0.2", + "psr/http-message": "^2.0", + "psr/http-server-handler": "^1.0.2", + "symfony/console": "^7.3.1", "yiisoft/aliases": "^3.0", - "yiisoft/assets": "^4.0", - "yiisoft/cache": "^3.0", - "yiisoft/cache-file": "^3.0", - "yiisoft/config": "^1.1", - "yiisoft/csrf": "^2.0", - "yiisoft/data-response": "^2.0", - "yiisoft/definitions": "^3.0", - "yiisoft/di": "^1.2", - "yiisoft/error-handler": "^4.0", - "yiisoft/factory": "^1.0", + "yiisoft/assets": "^5.1", + "yiisoft/cache": "^3.1", + "yiisoft/cache-file": "^3.2", + "yiisoft/config": "^1.6", + "yiisoft/csrf": "^2.2.2", + "yiisoft/data-response": "^2.1", + "yiisoft/definitions": "^3.4", + "yiisoft/di": "^1.4", + "yiisoft/error-handler": "^4.1", + "yiisoft/factory": "^1.3", "yiisoft/files": "^2.0", - "yiisoft/html": "^3.0", + "yiisoft/html": "^3.11", "yiisoft/http": "^1.2", - "yiisoft/i18n": "^1.1", - "yiisoft/log": "^2.1", + "yiisoft/i18n": "^1.2.1", + "yiisoft/log": "^2.1.1", "yiisoft/log-target-file": "^3.0", - "yiisoft/router": "^3.0", - "yiisoft/router-fastroute": "^3.0", - "yiisoft/translator": "^3.0", - "yiisoft/translator-message-php": "^1.1", - "yiisoft/view": "^12.0", - "yiisoft/yii-console": "^2.0", - "yiisoft/yii-debug": "dev-master", - "yiisoft/yii-event": "^2.0", - "yiisoft/yii-http": "^1.0", - "yiisoft/yii-middleware": "^1.0", - "yiisoft/yii-runner-console": "^2.0", + "yiisoft/router": "^4", + "yiisoft/router-fastroute": "^4.0.1", + "yiisoft/translator": "^3.1", + "yiisoft/translator-message-php": "^1.1.1", + "yiisoft/view": "^12.2", + "yiisoft/yii-console": "^2.3", + "yiisoft/yii-event": "^2.1", + "yiisoft/yii-http": "^1.0.4", + "yiisoft/yii-middleware": "^1.1.0", + "yiisoft/yii-runner-console": "^2.2", "yiisoft/yii-runner-http": "^3.2", - "yiisoft/yii-view-renderer": "^7.1" + "yiisoft/yii-view-renderer": "^7.3" }, "require-dev": { - "codeception/c3": "^2.7", - "codeception/codeception": "^5.0", - "codeception/module-asserts": "^3.0", - "codeception/module-cli": "^2.0", - "codeception/module-phpbrowser": "^3.0", - "maglnet/composer-require-checker": "^4.5", - "rector/rector": "^2.0.3", - "roave/infection-static-analysis-plugin": "^1.34", - "roave/security-advisories": "dev-master", - "spatie/phpunit-watcher": "^1.23", - "vimeo/psalm": "^5.20", - "yiisoft/yii-debug-api": "3.0.x-dev", - "yiisoft/yii-debug-viewer": "^3.0@dev" + "codeception/c3": "^2.9", + "codeception/codeception": "^5.3.2", + "codeception/module-asserts": "^3.2", + "codeception/module-cli": "^2.0.1", + "codeception/module-phpbrowser": "^3.0.1", + "maglnet/composer-require-checker": "^4.16.1", + "rector/rector": "^2.1.0", + "roave/infection-static-analysis-plugin": "^1.38", + "roave/security-advisories": "dev-latest", + "spatie/phpunit-watcher": "^1.24", + "vimeo/psalm": "^6.12.1" }, "autoload": { "psr-4": { @@ -107,13 +102,11 @@ } }, "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - }, "config-plugin-file": "configuration.php" }, "config": { "sort-packages": true, + "bump-after-update": true, "allow-plugins": { "yiisoft/config": true, "infection/extension-installer": true, diff --git a/config/common/di/router.php b/config/common/di/router.php index 4c9df520..6e7d12dd 100644 --- a/config/common/di/router.php +++ b/config/common/di/router.php @@ -3,9 +3,8 @@ declare(strict_types=1); use Yiisoft\Config\Config; -use Yiisoft\Csrf\CsrfMiddleware; +use Yiisoft\Csrf\CsrfTokenMiddleware; use Yiisoft\DataResponse\Middleware\FormatDataResponse; -use Yiisoft\Router\Group; use Yiisoft\Router\RouteCollection; use Yiisoft\Router\RouteCollectionInterface; use Yiisoft\Router\RouteCollectorInterface; @@ -15,12 +14,9 @@ return [ RouteCollectionInterface::class => static function (RouteCollectorInterface $collector) use ($config) { $collector - ->middleware(CsrfMiddleware::class) + ->middleware(CsrfTokenMiddleware::class) ->middleware(FormatDataResponse::class) - ->addGroup( - Group::create() - ->routes(...$config->get('routes')) - ); + ->addRoute(...$config->get('routes')); return new RouteCollection($collector); }, diff --git a/config/environments/dev/params.php b/config/environments/dev/params.php index 8c012d6a..0dae23de 100644 --- a/config/environments/dev/params.php +++ b/config/environments/dev/params.php @@ -2,8 +2,4 @@ declare(strict_types=1); -return [ - 'yiisoft/yii-debug' => [ - 'enabled' => true, - ], -]; +return []; diff --git a/config/environments/prod/params.php b/config/environments/prod/params.php index 3e62e040..0dae23de 100644 --- a/config/environments/prod/params.php +++ b/config/environments/prod/params.php @@ -2,8 +2,4 @@ declare(strict_types=1); -return [ - 'yiisoft/yii-debug' => [ - 'enabled' => false, - ], -]; +return []; diff --git a/config/environments/test/params.php b/config/environments/test/params.php index 3e62e040..0dae23de 100644 --- a/config/environments/test/params.php +++ b/config/environments/test/params.php @@ -2,8 +2,4 @@ declare(strict_types=1); -return [ - 'yiisoft/yii-debug' => [ - 'enabled' => false, - ], -]; +return []; diff --git a/docker/Dockerfile b/docker/Dockerfile index f6989384..aa619430 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,6 +1,6 @@ FROM composer/composer:latest-bin AS composer -FROM ghcr.io/shyim/wolfi-php/frankenphp:8.3 AS base +FROM ghcr.io/shyim/wolfi-php/frankenphp:8.2 AS base ARG UID=10001 ARG GID=10001 RUN <sets([ - LevelSetList::UP_TO_PHP_81, + LevelSetList::UP_TO_PHP_82, ]); $rectorConfig->skip([ diff --git a/src/Asset/AppAsset.php b/src/Asset/AppAsset.php index 04deb056..c7ecc540 100644 --- a/src/Asset/AppAsset.php +++ b/src/Asset/AppAsset.php @@ -5,13 +5,20 @@ namespace App\Asset; use Yiisoft\Assets\AssetBundle; +use Yiisoft\Assets\AssetManager; +/** + * @psalm-import-type CssFile from AssetManager + */ final class AppAsset extends AssetBundle { public ?string $basePath = '@assets'; public ?string $baseUrl = '@assetsUrl'; public ?string $sourcePath = '@resources/assets/css'; + /** + * @psalm-var array + */ public array $css = [ 'site.css', ]; diff --git a/src/Command/Hello.php b/src/Command/Hello.php index 55e43387..9a0a0633 100644 --- a/src/Command/Hello.php +++ b/src/Command/Hello.php @@ -4,28 +4,18 @@ namespace App\Command; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Yiisoft\Yii\Console\ExitCode; +#[AsCommand( + name: 'hello', + description: 'An example command', +)] final class Hello extends Command { - public function __construct() - { - parent::__construct(); - } - - public static function getDefaultName(): string - { - return 'hello'; - } - - public static function getDefaultDescription(): string - { - return 'An example command'; - } - protected function execute(InputInterface $input, OutputInterface $output): int { $output->writeln('Hello!'); diff --git a/src/Handler/NotFoundHandler.php b/src/Handler/NotFoundHandler.php index 726ec4f0..04b98919 100644 --- a/src/Handler/NotFoundHandler.php +++ b/src/Handler/NotFoundHandler.php @@ -15,8 +15,8 @@ final class NotFoundHandler implements RequestHandlerInterface { public function __construct( - private UrlGeneratorInterface $urlGenerator, - private CurrentRoute $currentRoute, + private readonly UrlGeneratorInterface $urlGenerator, + private readonly CurrentRoute $currentRoute, private ViewRenderer $viewRenderer ) { $this->viewRenderer = $viewRenderer->withControllerName('site'); diff --git a/src/ViewInjection/CommonViewInjection.php b/src/ViewInjection/CommonViewInjection.php index cbe83901..4844998e 100644 --- a/src/ViewInjection/CommonViewInjection.php +++ b/src/ViewInjection/CommonViewInjection.php @@ -8,7 +8,7 @@ use Yiisoft\Yii\View\Renderer\CommonParametersInjectionInterface; use Yiisoft\Router\UrlGeneratorInterface; -final class CommonViewInjection implements CommonParametersInjectionInterface +final readonly class CommonViewInjection implements CommonParametersInjectionInterface { public function __construct( private ApplicationParameters $applicationParameters, diff --git a/src/ViewInjection/LayoutViewInjection.php b/src/ViewInjection/LayoutViewInjection.php index f0392cac..675682f6 100644 --- a/src/ViewInjection/LayoutViewInjection.php +++ b/src/ViewInjection/LayoutViewInjection.php @@ -10,7 +10,7 @@ use Yiisoft\Router\CurrentRoute; use Yiisoft\Yii\View\Renderer\LayoutParametersInjectionInterface; -final class LayoutViewInjection implements LayoutParametersInjectionInterface +final readonly class LayoutViewInjection implements LayoutParametersInjectionInterface { public function __construct( private Aliases $aliases, diff --git a/src/ViewInjection/TranslatorViewInjection.php b/src/ViewInjection/TranslatorViewInjection.php index d84e17ef..6991d099 100644 --- a/src/ViewInjection/TranslatorViewInjection.php +++ b/src/ViewInjection/TranslatorViewInjection.php @@ -7,7 +7,7 @@ use Yiisoft\Translator\TranslatorInterface; use Yiisoft\Yii\View\Renderer\CommonParametersInjectionInterface; -final class TranslatorViewInjection implements CommonParametersInjectionInterface +final readonly class TranslatorViewInjection implements CommonParametersInjectionInterface { public function __construct(private TranslatorInterface $translator) {