diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ee3f235 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 + +[*.{json,yaml,yml,xml}] +indent_style = space +indent_size = 2 + +[*.php] +indent_style = space +indent_size = 4 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..49e6ab8 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,12 @@ +* text eol=lf +.github export-ignore +docs export-ignore +features export-ignore +tests export-ignore +.editorconfig export-ignore +.gitattributes export-ignore +.gitignore export-ignore +.php-cs-fixer.dist.php export-ignore +.readthedocs.yaml export-ignore +phpstan.dist.neon export-ignore +phpunit.xml.dist export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6503468..d80a6f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,10 +6,11 @@ on: - main jobs: ci: - runs-on: ubuntu-latest strategy: fail-fast: false matrix: + os: + - ubuntu-latest composer-script: - behat - cs @@ -19,14 +20,21 @@ jobs: - "8.3" - "8.4" - "8.5" + include: + - os: windows-latest + php: "8.5" + composer-script: phpunit + runs-on: ${{ matrix.os }} name: composer run ${{ matrix.composer-script }} / PHP ${{ matrix.php }} steps: - uses: actions/checkout@v6 - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} + extensions: json, fileinfo, sockets - id: composer-cache-dir run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + shell: bash - id: composer-cache uses: actions/cache@v5 with: @@ -36,6 +44,7 @@ jobs: - run: composer install - if: ${{ matrix.composer-script == 'behat' }} run: php -S localhost:8080 -t ./features/bootstrap > httpd.log 2>&1 & + shell: bash - run: composer run ${{ matrix.composer-script }} env: PHP_CS_FIXER_IGNORE_ENV: 1 diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 62a0c66..965e7ff 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,4 +1,5 @@ =8.3", "ext-json": "*", + "ext-fileinfo": "*", "beberlei/assert": "^3", "behat/behat": "^3", "firebase/php-jwt": "^6", "guzzlehttp/guzzle": "^7.7" }, "require-dev": { + "ext-sockets": "*", "friendsofphp/php-cs-fixer": "^3.92", "imbo/imbo-coding-standard": "^3.0", "phpstan/extension-installer": "^1.4", @@ -60,7 +62,7 @@ } }, "scripts": { - "behat": "vendor/bin/behat --strict", + "behat": "vendor/bin/behat --strict --colors", "ci": [ "@behat", "@cs", @@ -71,8 +73,8 @@ "cs:fix": "vendor/bin/php-cs-fixer fix --diff", "dev": "php -S localhost:8080 -t ./features/bootstrap", "docs": "cd docs; make html", - "phpunit": "vendor/bin/phpunit", - "phpunit:coverage": "vendor/bin/phpunit --coverage-html build/coverage", + "phpunit": "vendor/bin/phpunit --colors=always", + "phpunit:coverage": "@phpunit --coverage-html build/coverage", "sa": "vendor/bin/phpstan", "test": [ "@behat", diff --git a/features/bootstrap/FeatureContext.php b/features/bootstrap/FeatureContext.php index 638ad2b..fc238fe 100644 --- a/features/bootstrap/FeatureContext.php +++ b/features/bootstrap/FeatureContext.php @@ -81,7 +81,11 @@ public function createFile(string $filename, PyStringNode $content, bool $readab file_put_contents($filename, $content); if (!$readable) { - chmod($filename, 0000); + if (\PHP_OS_FAMILY === 'Windows') { + exec('icacls '.escapeshellarg($filename).' /deny Everyone:(R)'); + } else { + chmod($filename, 0000); + } } } @@ -218,7 +222,7 @@ private function getOutput(): string $output = $this->process->getErrorOutput().$this->process->getOutput(); - return trim((string) preg_replace('/ +$/m', '', $output)); + return trim((string) preg_replace(['/ +$/m', '/\r\n/'], ['', "\n"], $output)); } /** @@ -235,11 +239,11 @@ private static function rmdir(string $path): void if (is_dir($file)) { self::rmdir($file); } else { - unlink($file); + @unlink($file); } } // Remove the remaining directory - rmdir($path); + @rmdir($path); } } diff --git a/src/Exception/ArrayContainsComparatorException.php b/src/Exception/ArrayContainsComparatorException.php index fbd0bc4..f285cc6 100644 --- a/src/Exception/ArrayContainsComparatorException.php +++ b/src/Exception/ArrayContainsComparatorException.php @@ -7,7 +7,6 @@ use function sprintf; use const JSON_PRETTY_PRINT; -use const PHP_EOL; /** * Array contains comparator exception. @@ -16,7 +15,7 @@ class ArrayContainsComparatorException extends AssertionFailedException { public function __construct(string $message, int $code = 0, ?Throwable $previous = null, mixed $needle = null, mixed $haystack = null) { - $message .= PHP_EOL.PHP_EOL.sprintf( + $message .= "\n\n".sprintf( <<