diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml new file mode 100644 index 00000000..564da8b4 --- /dev/null +++ b/.github/workflows/coding-standards.yml @@ -0,0 +1,24 @@ +name: "Static analysis" + +on: + push: + branches: + - '[0-9]+.x' + - '[0-9]+.[0-9]+' + - '[0-9]+.[0-9]+.x' + pull_request: + +jobs: + phpstan: + name: "PHPStan" + runs-on: "ubuntu-latest" + + steps: + - name: "Checkout" + uses: "actions/checkout@v3" + - name: PHPStan + uses: "docker://oskarstark/phpstan-ga" + env: + REQUIRE_DEV: true + with: + args: analyze --no-progress diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/php-cs-fixer.yml similarity index 82% rename from .github/workflows/static-analysis.yml rename to .github/workflows/php-cs-fixer.yml index 9703d7de..d4c0b0be 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/php-cs-fixer.yml @@ -1,4 +1,4 @@ -name: "Static analysis" +name: "PHP-CS-Fixer" on: push: @@ -9,8 +9,8 @@ on: pull_request: jobs: - coding-standards: - name: "Coding Standards" + php-cs-fixer: + name: "PHP-CS-Fixer" runs-on: "ubuntu-latest" steps: diff --git a/.gitignore b/.gitignore index 70efea11..3a9ff611 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,6 @@ /build/ /composer.lock /phpspec.yml +/phpstan.neon /phpunit.xml /vendor/ diff --git a/composer.json b/composer.json index 465b54bc..bab75c8f 100644 --- a/composer.json +++ b/composer.json @@ -43,12 +43,11 @@ }, "conflict": { "php-http/guzzle6-adapter": "<1.1", - "php-http/cache-plugin": "<1.7.0", + "php-http/cache-plugin": "<1.7", "php-http/curl-client": "<2.0", "php-http/socket-client": "<2.0", "kriswallsmith/buzz": "<0.17", - "php-http/react-adapter": "<3.0", - "php-http/cache-plugin": "<1.7" + "php-http/react-adapter": "<3.0" }, "require-dev": { "guzzlehttp/psr7": "^1.7 || ^2.0", @@ -84,10 +83,7 @@ "autoload": { "psr-4": { "Http\\HttplugBundle\\": "src/" - }, - "exclude-from-classmap": [ - "/Tests/Resources/MyPsr18TestClient.php" - ] + } }, "autoload-dev": { "psr-4": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 00000000..bb0c7052 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,31 @@ +parameters: + ignoreErrors: + - + message: "#^Call to static method create\\(\\) on an unknown class Symfony\\\\Component\\\\HttpClient\\\\HttpClient\\.$#" + count: 1 + path: src/ClientFactory/SymfonyFactory.php + + - + message: "#^Class Http\\\\Client\\\\Plugin\\\\Vcr\\\\NamingStrategy\\\\NamingStrategyInterface not found\\.$#" + count: 1 + path: src/DependencyInjection/Configuration.php + + - + message: "#^Class Http\\\\Client\\\\Plugin\\\\Vcr\\\\Recorder\\\\PlayerInterface not found\\.$#" + count: 1 + path: src/DependencyInjection/Configuration.php + + - + message: "#^Class Http\\\\Client\\\\Plugin\\\\Vcr\\\\Recorder\\\\RecorderInterface not found\\.$#" + count: 1 + path: src/DependencyInjection/Configuration.php + + - + message: "#^Class Http\\\\Client\\\\Plugin\\\\Vcr\\\\RecordPlugin not found\\.$#" + count: 1 + path: src/DependencyInjection/HttplugExtension.php + + - + message: "#^Class Http\\\\Client\\\\Plugin\\\\Vcr\\\\ReplayPlugin not found\\.$#" + count: 1 + path: src/DependencyInjection/HttplugExtension.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 00000000..8843f528 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,12 @@ +includes: + - phpstan-baseline.neon + - %rootDir%/../phpstan-symfony/extension.neon + - %rootDir%/../phpstan-symfony/rules.neon + +parameters: + scanFiles: + - vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php + + level: 2 + paths: + - src diff --git a/src/Collector/PluginClientFactory.php b/src/Collector/PluginClientFactory.php index 17d8198c..d519d00d 100644 --- a/src/Collector/PluginClientFactory.php +++ b/src/Collector/PluginClientFactory.php @@ -45,11 +45,10 @@ public function __construct(Collector $collector, Formatter $formatter, Stopwatc /** * @param ClientInterface|HttpAsyncClient $client * @param Plugin[] $plugins - * @param array $options { + * @param array{client_name?: string} $options * - * @var string $client_name to give client a name which may be used when displaying client information like in - * the HTTPlugBundle profiler. - * } + * - client_name: to give client a name which may be used when displaying client information like in + * the HTTPlugBundle profiler * * @see PluginClient constructor for PluginClient specific $options. * @@ -61,7 +60,7 @@ public function createClient($client, array $plugins = [], array $options = []) return new ProfilePlugin($plugin, $this->collector, $this->formatter); }, $plugins); - $clientName = isset($options['client_name']) ? $options['client_name'] : 'Default'; + $clientName = $options['client_name'] ?? 'Default'; array_unshift($plugins, new StackPlugin($this->collector, $this->formatter, $clientName)); unset($options['client_name']);