From a6ac3b5171a393daf16dec4f7b8f09474e3f8752 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 20 Nov 2024 11:58:13 +0800 Subject: [PATCH 1/2] wip Signed-off-by: Mior Muhammad Zaki --- .github/workflows/analyse.yaml | 15 +++++---------- .github/workflows/coveralls.yaml | 9 +++------ composer.json | 1 + 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/.github/workflows/analyse.yaml b/.github/workflows/analyse.yaml index 41fe624..0370c21 100644 --- a/.github/workflows/analyse.yaml +++ b/.github/workflows/analyse.yaml @@ -6,20 +6,15 @@ on: jobs: tests: - runs-on: ${{ matrix.os }} + runs-on: "ubuntu-latest" continue-on-error: ${{ matrix.experimental }} strategy: matrix: - os: - - "ubuntu-latest" - php: - - 8.1 - dependencies: - - "locked" + php: [8.3] experimental: - false - name: PHP${{ matrix.php }} on ${{ matrix.os }} (${{ matrix.dependencies }}) + name: PHP:${{ matrix.php }} Code Analysis steps: - name: Checkout code @@ -35,11 +30,11 @@ jobs: - name: Install dependencies uses: "ramsey/composer-install@v3" with: - dependency-versions: "${{ matrix.dependencies }}" + dependency-versions: "highest" composer-options: "--prefer-dist --no-cache" - name: Installed dependencies run: composer show -D - name: Execute Static Code Analysis - run: vendor/bin/phpstan analyse + run: vendor/bin/phpstan analyse --verbose diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index c968262..b58cf00 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -10,14 +10,11 @@ jobs: continue-on-error: ${{ matrix.experimental }} strategy: matrix: - php: - - 8.1 - dependencies: - - "highest" + php: [8.3] experimental: - false - name: PHP${{ matrix.php }} on ${{ matrix.os }} (${{ matrix.dependencies }}) + name: PHP:${{ matrix.php }} Code Coverage steps: - name: Checkout code @@ -33,7 +30,7 @@ jobs: - name: Install dependencies uses: "ramsey/composer-install@v3" with: - dependency-versions: "${{ matrix.dependencies }}" + dependency-versions: "highest" composer-options: "--prefer-dist --prefer-stable" - name: Installed dependencies diff --git a/composer.json b/composer.json index 13a2386..5b596a9 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,7 @@ "illuminate/support": ">=5.7.0", "symfony/console": "^4.3.4 || ^5.0 || ^6.0", "symfony/polyfill-ctype": "^1.9", + "symfony/polyfill-php83": "^1.31", "symfony/process": "^4.3.4 || ^5.0 || ^6.0" }, "require-dev": { From 840c21f67089dc778afc6c0d8cc2f542dcc8dd49 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 20 Nov 2024 12:08:10 +0800 Subject: [PATCH 2/2] wip Signed-off-by: Mior Muhammad Zaki --- composer.json | 9 +++++++-- phpstan.neon.dist | 6 ++++-- src/Command.php | 21 ++++----------------- src/Concerns/DetectsChromeVersion.php | 10 +++------- src/DetectCommand.php | 14 ++++---------- src/UpdateCommand.php | 14 ++++---------- 6 files changed, 26 insertions(+), 48 deletions(-) diff --git a/composer.json b/composer.json index 5b596a9..d463fcc 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ }, "require-dev": { "laravel/dusk": "^5.8.2 || ^6.0 || ^7.0 || ^8.0", - "phpstan/phpstan": "^1.10.7", + "phpstan/phpstan": "^1.12", "phpunit/phpunit": "^9.6" }, "conflict": { @@ -58,7 +58,12 @@ } }, "scripts": { - "test": "@php vendor/bin/phpunit -c ./ --color" + "lint": "@php vendor/bin/phpstan analyse --verbose", + "test": "@php vendor/bin/phpunit -c ./ --color", + "ci": [ + "@lint", + "@test" + ] }, "minimum-stability": "stable" } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 41f5318..3b5dfc8 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -8,6 +8,8 @@ parameters: # The level 8 is the highest level level: 8 + ignoreErrors: + # - identifier: missingType.generics + - identifier: missingType.iterableValue + treatPhpDocTypesAsCertain: false - checkMissingIterableValueType: false - checkGenericClassInNonGenericObjectType: false diff --git a/src/Command.php b/src/Command.php index 6f78dce..17579e1 100644 --- a/src/Command.php +++ b/src/Command.php @@ -33,11 +33,8 @@ class Command extends SymfonyCommand */ protected $withSslVerification = true; - /** - * Configure the command options. - * - * @return void - */ + /** {@inheritDoc */ + #[\Override] protected function configure() { $this->ignoreValidationErrors(); @@ -54,18 +51,8 @@ protected function configure() ->addOption('ssl-no-verify', null, InputOption::VALUE_NONE, 'Bypass SSL certificate verification when installing through a proxy'); } - /** - * Initializes the command after the input has been bound and before the input - * is validated. - * - * This is mainly useful when a lot of commands extends one main command - * where some things need to be initialized based on the input arguments and options. - * - * @see InputInterface::bind() - * @see InputInterface::validate() - * - * @return void - */ + /** {@inheritDoc */ + #[\Override] protected function initialize(InputInterface $input, OutputInterface $output) { $this->directory = $input->getOption('install-dir'); diff --git a/src/Concerns/DetectsChromeVersion.php b/src/Concerns/DetectsChromeVersion.php index 9c87473..5344988 100644 --- a/src/Concerns/DetectsChromeVersion.php +++ b/src/Concerns/DetectsChromeVersion.php @@ -15,7 +15,7 @@ trait DetectsChromeVersion /** * The legacy versions for the ChromeDriver. * - * @var array + * @var array */ protected $legacyVersions = [ 43 => '2.20', @@ -130,9 +130,7 @@ protected function installedChromeVersion(string $operatingSystem, $directory = continue; } - preg_match('/(\d+)\.(\d+)\.(\d+)(\.\d+)?/', $process->getOutput(), $matches); - - if (! isset($matches[1])) { + if (preg_match('/(\d+)\.(\d+)\.(\d+)(\.\d+)?/', $process->getOutput(), $matches) === false) { continue; } @@ -175,9 +173,7 @@ protected function installedChromeDriverVersion(string $operatingSystem, string $process->run(); if ($process->getExitCode() == 0) { - preg_match('/ChromeDriver\s(\d+)\.(\d+)\.(\d+)(\.\d+)?\s[\w\D]+/', $process->getOutput(), $matches); - - if (isset($matches[1])) { + if (preg_match('/ChromeDriver\s(\d+)\.(\d+)\.(\d+)(\.\d+)?\s[\w\D]+/', $process->getOutput(), $matches) !== false) { $semver = implode('.', [$matches[1], $matches[2], $matches[3]]); return [ diff --git a/src/DetectCommand.php b/src/DetectCommand.php index 0112a71..0e3e08d 100644 --- a/src/DetectCommand.php +++ b/src/DetectCommand.php @@ -14,11 +14,8 @@ */ class DetectCommand extends Command { - /** - * Configure the command options. - * - * @return void - */ + /** {@inheritDoc */ + #[\Override] protected function configure() { $this->setName('detect') @@ -29,11 +26,8 @@ protected function configure() parent::configure(); } - /** - * Execute the command. - * - * @return int 0 if everything went fine, or an exit code - */ + /** {@inheritDoc */ + #[\Override] protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); diff --git a/src/UpdateCommand.php b/src/UpdateCommand.php index 298438f..211d130 100644 --- a/src/UpdateCommand.php +++ b/src/UpdateCommand.php @@ -16,11 +16,8 @@ */ class UpdateCommand extends Command { - /** - * Configure the command options. - * - * @return void - */ + /** {@inheritDoc */ + #[\Override] protected function configure() { $this->setName('update') @@ -31,11 +28,8 @@ protected function configure() parent::configure(); } - /** - * Execute the command. - * - * @return int 0 if everything went fine, or an exit code - */ + /** {@inheritDoc */ + #[\Override] protected function execute(InputInterface $input, OutputInterface $output) { $version = $this->version($input);