From 291d05986685073fb1acc5f8c15e4684d3bc64df Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Thu, 1 Aug 2024 21:09:14 +0200 Subject: [PATCH 1/3] Fix super-linter config --- tools/linters/.eslintrc.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/linters/.eslintrc.js b/tools/linters/.eslintrc.js index e287e62..eeca409 100644 --- a/tools/linters/.eslintrc.js +++ b/tools/linters/.eslintrc.js @@ -1,8 +1,14 @@ module.exports = { - extends: ["json:recommended"], ignorePatterns: ["!/tools/linters/.eslintrc.yml", "!/tools/linters/.stylelintrc.json"], parserOptions: { ecmaVersion: 2015, sourceType: "module" - } + }, + overrides: [ + { + files: ["*.json"], + extends: ["plugin:jsonc/recommended-with-json"], + parser: "jsonc-eslint-parser", + } + ] }; From 88abc4d761b93504d971516e46d0059eba90d773 Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Tue, 6 Aug 2024 20:07:33 +0200 Subject: [PATCH 2/3] Migrate Psalm to PHPStan --- .github/workflows/php.yml | 18 +++++------------- phpstan-dev.neon | 4 ++++ phpstan.neon | 4 ++++ psalm.xml | 38 -------------------------------------- 4 files changed, 13 insertions(+), 51 deletions(-) create mode 100644 phpstan-dev.neon create mode 100644 phpstan.neon delete mode 100644 psalm.xml diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 7ab1805..8ef6930 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -51,8 +51,7 @@ jobs: with: # Should be the higest supported version, so we can use the newest tools php-version: '8.3' - tools: composer, composer-require-checker, composer-unused, phpcs, psalm - # optional performance gain for psalm: opcache + tools: composer, composer-require-checker, composer-unused, phpcs, phpstan extensions: ctype, date, dom, filter, hash, intl, mbstring, opcache, openssl, pcre, spl, xml - name: Setup problem matchers for PHP @@ -91,20 +90,13 @@ jobs: - name: PHP Code Sniffer run: phpcs - - name: Psalm - continue-on-error: true + - name: PHPStan run: | - psalm -c psalm.xml \ - --show-info=true \ - --shepherd \ - --php-version=${{ steps.setup-php.outputs.php-version }} + phpstan analyze -c phpstan.neon --debug - - name: Psalter + - name: PHPStan (testsuite) run: | - psalm --alter \ - --issues=UnnecessaryVarAnnotation \ - --dry-run \ - --php-version=${{ steps.setup-php.outputs.php-version }} + phpstan analyze -c phpstan-dev.neon --debug security: name: Security checks diff --git a/phpstan-dev.neon b/phpstan-dev.neon new file mode 100644 index 0000000..57972f5 --- /dev/null +++ b/phpstan-dev.neon @@ -0,0 +1,4 @@ +parameters: + level: 6 + paths: + - tests diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..db37782 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,4 @@ +parameters: + level: 6 + paths: + - src diff --git a/psalm.xml b/psalm.xml deleted file mode 100644 index bf5cabd..0000000 --- a/psalm.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 157dbad53f1fc10610b23e9457eec20d0e4ad5aa Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Mon, 19 Aug 2024 10:33:14 +0200 Subject: [PATCH 3/3] Give the builtin server a few seconds to get ready; before requests to get() could fail --- lib/BuiltInServer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/BuiltInServer.php b/lib/BuiltInServer.php index 127cb8e..0f0a907 100644 --- a/lib/BuiltInServer.php +++ b/lib/BuiltInServer.php @@ -116,7 +116,7 @@ public function start(): string $sock = @fsockopen('localhost', $port, $errno, $errstr, 10); if ($sock === false) { // set a 5 secs timeout waiting for the server to start - if (microtime(true) > $start + 5) { + if (microtime(true) > $start + 5.0) { $this->pid = 0; // signal failure break; } @@ -127,6 +127,7 @@ public function start(): string fclose($sock); } + sleep(2); // Ensure the service is able to prepare itself before receiving requests return $this->address; }