diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..deb86b8 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,121 @@ +### +# https://github.com/gitattributes/gitattributes/blob/master/Common.gitattributes +### + +# Auto detect text files and perform LF normalization +* text=auto + +# +# The above will handle all files NOT found below +# + +# Documents +*.bibtex text diff=bibtex +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain +*.md text diff=markdown +*.mdx text diff=markdown +*.tex text diff=tex +*.adoc text +*.textile text +*.mustache text +*.csv text eol=crlf +*.tab text +*.tsv text +*.txt text +*.sql text +*.epub diff=astextplain + +# Graphics +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.tif binary +*.tiff binary +*.ico binary +# SVG treated as text by default. +*.svg text +# If you want to treat it as binary, +# use the following line instead. +# *.svg binary +*.eps binary + +# Scripts +*.bash text eol=lf +*.fish text eol=lf +*.ksh text eol=lf +*.sh text eol=lf +*.zsh text eol=lf +# These are explicitly windows files and should use crlf +*.bat text eol=crlf +*.cmd text eol=crlf +*.ps1 text eol=crlf + +# Serialisation +*.json text +*.toml text +*.xml text +*.yaml text +*.yml text + +# Archives +*.7z binary +*.gz binary +*.tar binary +*.tgz binary +*.zip binary + +# Text files where line endings should be preserved +*.patch -text + +# +# Exclude files from exporting +# + +.gitattributes export-ignore +.gitignore export-ignore +.gitkeep export-ignore + +### +# https://github.com/gitattributes/gitattributes/blob/master/PHP.gitattributes +### + +# PHP files +*.php text eol=lf diff=php +*.phpt text eol=lf diff=php +*.phtml text eol=lf diff=html +*.twig text eol=lf +*.phar binary + +# Configuration +phpcs.xml text eol=lf +phpunit.xml text eol=lf +phpstan.neon text eol=lf +psalm.xml text eol=lf + +### +# Open Culture Consulting custom additions +### + +# Configuration +.editorconfig text eol=lf +*.dist.xml text eol=lf +*.xml.dist text eol=lf +*.neon text eol=lf + +# Generated documentation +doc/* linguist-generated=true + +# Exclude files from exporting +.github/* export-ignore +.phpdoc/* export-ignore +phpdoc.dist.xml export-ignore diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 33f1a33..f30f38c 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,6 +4,7 @@ updates: directory: "/" schedule: interval: "weekly" + versioning-strategy: "increase-if-necessary" assignees: - "sebastian-meyer" labels: [ ] diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml new file mode 100644 index 0000000..351f907 --- /dev/null +++ b/.github/workflows/phpcs.yml @@ -0,0 +1,35 @@ +name: PHP Code Sniffer + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + PHPCS: + name: PHPCS Scanner + runs-on: ubuntu-latest + permissions: + contents: read + actions: read + + steps: + - name: Checkout Source Code + uses: actions/checkout@v4 + + - name: Setup Environment + uses: php-actions/composer@v6 + with: + command: update + php_version: "8.1" + + - name: Run PHPCS + uses: php-actions/phpcs@v1 + with: + php_version: "8.1" + path: src/ + standard: phpcs.xml.dist diff --git a/.github/workflows/phpmd.yml b/.github/workflows/phpmd.yml index d9baa5c..9efa973 100644 --- a/.github/workflows/phpmd.yml +++ b/.github/workflows/phpmd.yml @@ -25,7 +25,7 @@ jobs: - name: Setup Environment uses: shivammathur/setup-php@v2 with: - php-version: "8.0" + php-version: "8.1" coverage: none tools: phpmd diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index a42088b..795fd42 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -26,7 +26,7 @@ jobs: uses: php-actions/composer@v6 with: command: update - php_version: "8.0" + php_version: "8.1" - name: Run PHPStan uses: php-actions/phpstan@v3 diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml new file mode 100644 index 0000000..6b5f5be --- /dev/null +++ b/.github/workflows/psalm.yml @@ -0,0 +1,35 @@ +name: Psalm Static Analyzer + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + Psalm: + name: Psalm Scanner + runs-on: ubuntu-latest + permissions: + contents: read + security-events: write + actions: read + + steps: + - name: Checkout Source Code + uses: actions/checkout@v4 + + - name: Run Psalm + uses: docker://ghcr.io/psalm/psalm-github-actions + with: + security_analysis: true + report_file: psalm-results.sarif + + - name: Upload Analysis Results + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: psalm-results.sarif + wait-for-processing: true diff --git a/.gitignore b/.gitignore index 3eed260..cb378ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,10 @@ +/.phpdoc/cache/ /.vscode/ /vendor/ .php-cs-fixer.php composer.lock +phpcs.xml +phpdoc.xml phpstan.neon +psalm.xml +TODO diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index bac0ef1..385bca2 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,8 +1,8 @@ + * PHP Basics + * Copyright (C) 2024 Sebastian Meyer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -11,11 +11,11 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ declare(strict_types=1); @@ -24,15 +24,15 @@ namespace PhpCsFixer; /** * Configuration for PHP-CS-Fixer. + * * @see https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/config.rst * * @return ConfigInterface */ -return (new Config()) +$config = new Config(); +$finder = new Finder(); + +return $config ->setRiskyAllowed(true) - ->setRules([ - '@PSR12' => true, - ]) - ->setFinder( - (new Finder())->in(__DIR__) - ); + ->setRules(['@PSR12' => true]) + ->setFinder($finder->in([__DIR__ . '/src'])); diff --git a/composer.json b/composer.json index ace4ddb..4630332 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,7 @@ "request", "handler", "middleware", + "queue", "http-server-handler", "http-server-middleware" ], @@ -25,19 +26,21 @@ "support": { "issues": "https://github.com/opencultureconsulting/psr-15/issues", "source": "https://github.com/opencultureconsulting/psr-15", - "docs": "https://github.com/opencultureconsulting/psr-15/blob/main/README.md" + "docs": "https://opencultureconsulting.github.io/psr-15/" }, "require": { - "php": "^8.0", + "php": "^8.1", "guzzlehttp/psr7": "^2.6", - "opencultureconsulting/basics": "^1.1", + "opencultureconsulting/basics": "^2.0", "psr/http-server-handler": "^1.0", "psr/http-server-middleware": "^1.0" }, "require-dev": { "phpstan/phpstan": "^1.10", "phpstan/phpstan-strict-rules": "^1.5", - "friendsofphp/php-cs-fixer": "^3.48" + "friendsofphp/php-cs-fixer": "^3.52", + "squizlabs/php_codesniffer": "^3.9", + "vimeo/psalm": "^5.23" }, "provide": { "psr/http-server-handler-implementation": "1.0", diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..0e5fe24 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,10 @@ + + + Open Culture Consulting strictly follows PSR standards. + ./src + + + + + + diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml new file mode 100644 index 0000000..5c96b82 --- /dev/null +++ b/phpdoc.dist.xml @@ -0,0 +1,39 @@ + + + PSR-15 Queue + + doc + .phpdoc/cache + + + + + /src + + + php + + PSR15 + true + + extends + implements + phpstan-require-implements + psalm-suppress + + + + + /.phpdoc/guide + + guides + + + + + + diff --git a/psalm.xml.dist b/psalm.xml.dist new file mode 100644 index 0000000..606f492 --- /dev/null +++ b/psalm.xml.dist @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + diff --git a/src/AbstractMiddleware.php b/src/AbstractMiddleware.php index 572d9b8..43eec9c 100644 --- a/src/AbstractMiddleware.php +++ b/src/AbstractMiddleware.php @@ -31,7 +31,7 @@ use Psr\Http\Server\RequestHandlerInterface; * Abstract class implementing Psr\Http\Server\MiddlewareInterface. * * @author Sebastian Meyer - * @package opencultureconsulting/psr15 + * @package PSR15 */ abstract class AbstractMiddleware implements MiddlewareInterface { diff --git a/src/MiddlewareQueue.php b/src/MiddlewareQueue.php index d99aa6f..6cfe80d 100644 --- a/src/MiddlewareQueue.php +++ b/src/MiddlewareQueue.php @@ -30,7 +30,7 @@ use Psr\Http\Server\MiddlewareInterface; * Queue of PSR-15 Middlewares to process HTTP Server Requests. * * @author Sebastian Meyer - * @package opencultureconsulting/psr15 + * @package PSR15 * * @extends StrictQueue */ diff --git a/src/QueueRequestHandler.php b/src/QueueRequestHandler.php index 358a04b..eb70b12 100644 --- a/src/QueueRequestHandler.php +++ b/src/QueueRequestHandler.php @@ -36,7 +36,7 @@ use Psr\Http\Server\RequestHandlerInterface; * A queue-based PSR-15 HTTP Server Request Handler. * * @author Sebastian Meyer - * @package opencultureconsulting/psr15 + * @package PSR15 * * @property-read MiddlewareQueue $queue * @property-read ServerRequestInterface $request