diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d4597af17..d128557bc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,5 +38,8 @@ jobs: - name: Install dependencies run: composer install --prefer-dist --no-interaction --no-progress + - name: Run PhpStan + run: vendor/bin/phpstan analyse src tests + - name: Execute tests run: vendor/bin/phpunit --verbose diff --git a/composer.json b/composer.json index f7751426a..673e0fde7 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,8 @@ }, "require-dev": { "phpunit/phpunit": "^9.5", - "dms/phpunit-arraysubset-asserts": "^0.2.1" + "dms/phpunit-arraysubset-asserts": "^0.2.1", + "phpstan/phpstan": "^1.10" }, "license": "MIT", "authors": [ diff --git a/composer.lock b/composer.lock index d3d947f22..f975aeb18 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f661151eb1a23240797e306139755a5b", + "content-hash": "186632e5fcfc8b65dc45f3bb657fd6b8", "packages": [ { "name": "psr/container", @@ -1196,6 +1196,68 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "phpstan/phpstan", + "version": "1.10.57", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "1627b1d03446904aaa77593f370c5201d2ecc34e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1627b1d03446904aaa77593f370c5201d2ecc34e", + "reference": "1627b1d03446904aaa77593f370c5201d2ecc34e", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2024-01-24T11:51:34+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.30", diff --git a/phpstan.src.neon.dist b/phpstan.src.neon.dist new file mode 100644 index 000000000..f5d4e5750 --- /dev/null +++ b/phpstan.src.neon.dist @@ -0,0 +1,17 @@ +parameters: + paths: + - src + level: 0 + ignoreErrors: + - "#\\(void\\) is used#" + - "#Access to an undefined property#" + - "#Call to an undefined method#" + - "#but return statement is missing.#" + - "#Caught class [a-zA-Z0-9\\\\_]+ not found.#" + - "#Class [a-zA-Z0-9\\\\_]+ not found.#" + - "#has invalid type#" + - "#should always throw an exception or terminate script execution#" + - "#Instantiated class [a-zA-Z0-9\\\\_]+ not found.#" + - "#Unsafe usage of new static#" + excludePaths: + - "src/Illuminate/Testing/ParallelRunner.php" diff --git a/src/Settings/JsonSettings.php b/src/Settings/JsonSettings.php index e25c88f34..cf891d419 100644 --- a/src/Settings/JsonSettings.php +++ b/src/Settings/JsonSettings.php @@ -2,7 +2,7 @@ namespace Laravel\Homestead\Settings; -class JsonSettings extends HomesteadSettings +final class JsonSettings extends HomesteadSettings { /** * Create an instance from a file. diff --git a/src/Settings/YamlSettings.php b/src/Settings/YamlSettings.php index d136613d2..d25924b14 100644 --- a/src/Settings/YamlSettings.php +++ b/src/Settings/YamlSettings.php @@ -4,7 +4,7 @@ use Symfony\Component\Yaml\Yaml; -class YamlSettings extends HomesteadSettings +final class YamlSettings extends HomesteadSettings { /** * Create an instance from a file.