From e461709b21ccbb2e542ab11bc4453ab592394ac3 Mon Sep 17 00:00:00 2001 From: Larry Garfield Date: Sat, 6 Sep 2025 11:45:08 -0500 Subject: [PATCH 01/10] Initial project structure. --- .editorconfig | 15 +++++++ .gitattributes | 16 +++++++ .github/workflows/quality-assurance.yaml | 55 ++++++++++++++++++++++++ .gitignore | 9 ++++ .php-cs-fixer.php | 43 ++++++++++++++++++ CONTRIBUTING.md | 34 +++++++++++++++ LICENSE.md | 21 +++++++++ README.md | 48 ++++++++++++++++++++- SECURITY.md | 37 ++++++++++++++++ composer.json | 40 +++++++++++++++++ phpstan.neon | 31 +++++++++++++ phpunit.xml | 31 +++++++++++++ src/Placeholder.php | 12 ++++++ tests/.gitkeep | 0 14 files changed, 391 insertions(+), 1 deletion(-) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/workflows/quality-assurance.yaml create mode 100644 .gitignore create mode 100644 .php-cs-fixer.php create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE.md create mode 100644 SECURITY.md create mode 100644 composer.json create mode 100644 phpstan.neon create mode 100644 phpunit.xml create mode 100644 src/Placeholder.php create mode 100644 tests/.gitkeep diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..cd8eb86 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +; This file is for unifying the coding style for different editors and IDEs. +; More information at http://editorconfig.org + +root = true + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8cfe851 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,16 @@ +# Path-based git attributes +# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html + +# Ignore all test and documentation with "export-ignore". +/.gitattributes export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore +/phpunit.xml.dist export-ignore +/.scrutinizer.yml export-ignore +/tests export-ignore +/docs export-ignore +/docker export-ignore +/benchmarks export-ignore +/docker-compose.yml export-ignore +/phpbench.json export-ignore +/profile.php export-ignore diff --git a/.github/workflows/quality-assurance.yaml b/.github/workflows/quality-assurance.yaml new file mode 100644 index 0000000..ee3b70f --- /dev/null +++ b/.github/workflows/quality-assurance.yaml @@ -0,0 +1,55 @@ +--- +name: Quality assurance +on: + push: + branches: ['main'] + pull_request: ~ + +jobs: + phpunit: + name: PHPUnit tests on ${{ matrix.php }} ${{ matrix.composer-flags }} + runs-on: ubuntu-latest + strategy: + matrix: + php: [ '8.2', '8.3', '8.4' ] + composer-flags: [ '' ] + phpunit-flags: [ '--coverage-text' ] + steps: + - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: xdebug + tools: composer:v2 + - run: composer install --no-progress ${{ matrix.composer-flags }} + - run: vendor/bin/phpunit ${{ matrix.phpunit-flags }} + phpstan: + name: PHPStan checks on ${{ matrix.php }} + runs-on: ubuntu-latest + strategy: + matrix: + php: [ '8.2', '8.3', '8.4' ] + composer-flags: [ '' ] + steps: + - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer:v2 + - run: composer install --no-progress ${{ matrix.composer-flags }} + - run: composer phpstan + cs: + name: PHPStan checks on ${{ matrix.php }} + runs-on: ubuntu-latest + strategy: + matrix: + php: [ '8.2', '8.3', '8.4' ] + composer-flags: [ '' ] + steps: + - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer:v2 + - run: composer install --no-progress ${{ matrix.composer-flags }} + - run: composer cs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cfe36af --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +.env +vendor +.phpunit.result.cache +.phpunit.cache/ +build +composer.lock + +.idea +*.iml diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..c52b0d6 --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,43 @@ +in(__DIR__) + ->name(__FILE__) + ->exclude([ + 'build', + ]) +; + +$config = new PhpCsFixer\Config(); + +$config + ->setFinder($finder) + ->setCacheFile('build/php-cs-fixer.cache') + ->setLineEnding("\n") + ->setRiskyAllowed(true) + ->setRules([ + '@PER-CS' => true, + 'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'], + 'void_return' => true, + 'array_syntax' => ['syntax' => 'short'], + + // apply stricter whitespace rules + 'array_indentation' => true, + 'binary_operator_spaces' => true, + 'cast_spaces' => true, + 'concat_space' => ['spacing' => 'one'], + 'function_declaration' => ['closure_fn_spacing' => 'none'], + 'method_argument_space' => true, + 'no_extra_blank_lines' => true, + 'no_spaces_around_offset' => true, + 'no_trailing_whitespace_in_string' => true, + 'no_whitespace_before_comma_in_array' => true, + 'object_operator_without_whitespace' => true, + 'trim_array_spaces' => true, + 'type_declaration_spaces' => true, + 'types_spaces' => true, + 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true, + ]); + +return $config; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..a546e9a --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,34 @@ +# Contributing + +Contributions are **welcome** and will be fully **credited**. + +We accept contributions via Pull Requests on [Github](https://github.com/php-fig/per-attributes). + +## Pull Requests + +- **[PER-Coding Standards](https://www.php-fig.org/per/coding-style/)** - Check the code style with `$ composer cs` and fix it with `$ composer cs-fix`. + +- **Add tests!** - Your patch won't be accepted if it doesn't have tests. + +- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. + +- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. + +- **Create feature branches** - Don't ask us to pull from your master branch. + +- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. + +- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. + + +## Running Tests + +``` bash +$ composer test +``` + +## AI Policy + +This project respects the copyright of all Open Source contributors. The legality of using Open Source data to train Code-generation AIs (including but not limited to GitHub Copilot) or of using Code-generation AIs to produce Open Source code is still very murky and unclear. For that reason, *AI-generated code is not welcome in this project and will be rejected on sight*. By submitting a PR, you affirm that the code was written 100% by you, and that you have the legal permission to offer it under the licensing terms of this project. Violation of this policy may result in your banning from the project. + +**Happy coding**! diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..b9e9dfe --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 PHP-FIG + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index f040313..bbe905b 100644 --- a/README.md +++ b/README.md @@ -1 +1,47 @@ -# PER Attributes +# PHP Evolving Recommendation - Attributes + +[![Latest Version on Packagist][ico-version]][link-packagist] +[![Software License][ico-license]](LICENSE.md) +[![Total Downloads][ico-downloads]][link-downloads] + +This package contains PHP attribute definitions published by the PHP Framework Interoperability Group (PHP-FIG). They are intended to have widespread applicability across the PHP ecosystem. + +Any attribute proposed must be approved by a majority of the working group, and in some cases by the PHP-FIG Core Committee. Any submitted attribute must follow these guidelines: + +* It MUST have applicability and relevance for more than one project or application. +* It SHOULD have two or more projects to which the attribute would be relevant that state their intent to use it if approved. +* It MUST be parsable and usable with raw PHP. No third party attribute library requirements are allowed. +* It MUST follow PER-CS coding guidelines. +* It MUST adhere to PHPStan Level 10 levels of code tidiness. +* It MUST be extensively documented through docblocks on the attribute itself. +* It MAY have functionality beyond just the constructor, if relevant. +* If the required PHP version for a specific attribute is higher than that of the package, that MUST be specified in the class docblock. + +Ideally, proposals should be discussed in the [PHP-FIG Discord](https://discord.gg/php-fig), `#per-attributes` channel, prior to proposal. + +## Contributing + +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. + +## Security + +If you discover any security related issues, please use the [GitHub security reporting form](https://github.com/php-fig/fp/security) rather than the issue queue. + +## Working Group + + +- [Larry Garfield][link-crell] +- [All Contributors][link-contributors] + +## License + +The Lesser GPL version 3 or later. Please see [License File](LICENSE.md) for more information. + +[ico-version]: https://img.shields.io/packagist/v/fig/attributes.svg?style=flat-square +[ico-license]: https://img.shields.io/badge/License-MIT-green.svg?style=flat-square +[ico-downloads]: https://img.shields.io/packagist/dt/fig/attributes.svg?style=flat-square + +[link-packagist]: https://packagist.org/packages/fig/attributes +[link-downloads]: https://packagist.org/packages/fig/attributes +[link-crell]: https://github.com/Crell +[link-contributors]: ../../contributors diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..6c72660 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,37 @@ +# Brand Promise + +Perfect security is not an achievable goal, but it is a goal to strive for nonetheless. To that end, we welcome responsible security reports from both users and external security researchers. + +# Scope + +If you believe you've found a security issue in software that is maintained in this repository, we encourage you to notify us. + +| Version | In scope | Source code | +| ------- | -------- |-------------------------------------------| +| latest | ✅ | https://github.com/php-fig/per-attributes | + +Only the latest stable release of this library is supported. In general, bug and security fixes will not be backported unless there is a substantial imminent threat to users in not doing so. + +# How to Submit a Report + +To submit a vulnerability report, please contact us through [GitHub](https://github.com/php-fig/per-attributes/security). Your submission will be reviewed as soon as feasible, but as this is a volunteer project we cannot guarantee a response time. + +# Safe Harbor + +We support safe harbor for security researchers who: + +* Make a good faith effort to avoid privacy violations, destruction of data, and interruption or degradation of our services. +* Only interact with accounts you own or with explicit permission of the account holder. If you do encounter Personally Identifiable Information (PII) contact us immediately, do not proceed with access, and immediately purge any local information. +* Provide us with a reasonable amount of time to resolve vulnerabilities prior to any disclosure to the public or a third-party. + +We will consider activities conducted consistent with this policy to constitute "authorized" conduct and will not pursue civil action or initiate a complaint to law enforcement. We will help to the extent we can if legal action is initiated by a third party against you. + +Please submit a report to us before engaging in conduct that may be inconsistent with or unaddressed by this policy. + +# Preferences + +* Please provide detailed reports with reproducible steps and a clearly defined impact. +* Include the version number of the vulnerable package in your report. +* Providing a suggested fix is welcome, but not required, and we may choose to implement our own, based on your submitted fix or not. +* This is a volunteer project. We will make every effort to respond to security reports in a timely manner, but that may be a week or two on the first contact. + diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..d1ca9a3 --- /dev/null +++ b/composer.json @@ -0,0 +1,40 @@ +{ + "name": "fig/attributes", + "require": { + "php": "~8.2" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^v3.87.1", + "php-cs-fixer/shim": "^3.85", + "phpmetrics/phpmetrics": "^2.9", + "phpstan/phpstan": "^2.1.11", + "phpunit/phpunit": "^11.1.0" + }, + "autoload": { + "psr-4": { + "Fig\\Attributes\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "Fig\\Attributes\\": "tests" + } + }, + "scripts": { + "benchmarks": "vendor/bin/phpbench run benchmarks --report=aggregate", + "test": "vendor/bin/phpunit", + "test-coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --coverage-clover=coverage-clover.xml", + "coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --coverage-html=\"build/coverage\"", + "phpstan": "vendor/bin/phpstan analyze --memory-limit=-1", + "cs": "vendor/bin/php-cs-fixer check --diff", + "cs-fix": "vendor/bin/php-cs-fixer fix --diff", + "all-checks": [ + "@test", + "@phpstan", + "@cs" + ] + }, + "config": { + "sort-packages": true + } +} diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..d6765cd --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,31 @@ +parameters: + level: 10 + tmpDir: build/phpstan.cache + paths: + - src + - tests + ignoreErrors: + - message: '#(Array shape contains unspecified keys|Parameter .+ of method .+ contains unspecified keys|Array shape is not compatible with|Property .+ type with generic class .+ does not specify its types|Cannot access offset .+ on array\{.+\}|array\{.+\} does not accept key .+|Array has no value type specified in iterable type array)#' + paths: + - tests/* + reportUnmatched: false + + - message: '#Method [a-zA-Z0-9\\_\\\\:\\(\\)]+ (has parameter \\\$[a-zA-Z0-9_]+|return type) with no value type specified in iterable type array#' + paths: + - tests/* + reportUnmatched: false + + - message: '#Property [a-zA-Z0-9\\\$\\_\\\\:\\(\\)]+ type has no value type specified in iterable type array#' + paths: + - tests/* + reportUnmatched: false + # PHPStan doesn't understand PHPUnit's self-termination methods. + - message: '#Unreachable statement - code above always terminates.#' + paths: + - tests/* + reportUnmatched: false + # PHPStan is overly aggressive on readonly properties. + - message: '#Class (.*) has an uninitialized readonly property (.*). Assign it in the constructor.#' + reportUnmatched: false + - message: '#Readonly property (.*) is assigned outside of the constructor.#' + reportUnmatched: false diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..3639b6e --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,31 @@ + + + + + tests + + + + + + + + + + + src + + + diff --git a/src/Placeholder.php b/src/Placeholder.php new file mode 100644 index 0000000..2296fd1 --- /dev/null +++ b/src/Placeholder.php @@ -0,0 +1,12 @@ + Date: Mon, 8 Sep 2025 17:54:25 -0500 Subject: [PATCH 02/10] Revise git-attribute excludes. --- .gitattributes | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/.gitattributes b/.gitattributes index 8cfe851..bee9bdb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,15 +2,11 @@ # https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html # Ignore all test and documentation with "export-ignore". -/.gitattributes export-ignore -/.gitignore export-ignore -/.travis.yml export-ignore -/phpunit.xml.dist export-ignore -/.scrutinizer.yml export-ignore -/tests export-ignore -/docs export-ignore -/docker export-ignore -/benchmarks export-ignore -/docker-compose.yml export-ignore -/phpbench.json export-ignore -/profile.php export-ignore +/.editorconfig export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.php-cs-fixer.php export-ignore +/phpunit.xml export-ignore +/tests export-ignore +/docs export-ignore +/phpstan.neon export-ignore From 59bfc81ca769a43a3d294dde3dccad114a53227f Mon Sep 17 00:00:00 2001 From: Larry Garfield Date: Mon, 8 Sep 2025 18:07:01 -0500 Subject: [PATCH 03/10] Assorted fixes from review. --- .github/workflows/quality-assurance.yaml | 15 +++++---------- .gitignore | 2 -- .php-cs-fixer.php | 1 - README.md | 4 ++-- composer.json | 1 - 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/.github/workflows/quality-assurance.yaml b/.github/workflows/quality-assurance.yaml index ee3b70f..72ccb38 100644 --- a/.github/workflows/quality-assurance.yaml +++ b/.github/workflows/quality-assurance.yaml @@ -12,15 +12,12 @@ jobs: strategy: matrix: php: [ '8.2', '8.3', '8.4' ] - composer-flags: [ '' ] - phpunit-flags: [ '--coverage-text' ] steps: - uses: actions/checkout@v2 - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} coverage: xdebug - tools: composer:v2 - run: composer install --no-progress ${{ matrix.composer-flags }} - run: vendor/bin/phpunit ${{ matrix.phpunit-flags }} phpstan: @@ -28,28 +25,26 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: [ '8.2', '8.3', '8.4' ] + php: [ '8.4' ] composer-flags: [ '' ] steps: - uses: actions/checkout@v2 - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - tools: composer:v2 + coverage: none - run: composer install --no-progress ${{ matrix.composer-flags }} - run: composer phpstan cs: - name: PHPStan checks on ${{ matrix.php }} + name: Code Style checks on ${{ matrix.php }} runs-on: ubuntu-latest strategy: matrix: - php: [ '8.2', '8.3', '8.4' ] - composer-flags: [ '' ] + php: [ '8.4' ] steps: - uses: actions/checkout@v2 - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - tools: composer:v2 - - run: composer install --no-progress ${{ matrix.composer-flags }} + - run: composer install --no-progress - run: composer cs diff --git a/.gitignore b/.gitignore index cfe36af..f2f5e5a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,5 @@ .env vendor -.phpunit.result.cache -.phpunit.cache/ build composer.lock diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index c52b0d6..287fe7a 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -35,7 +35,6 @@ 'object_operator_without_whitespace' => true, 'trim_array_spaces' => true, 'type_declaration_spaces' => true, - 'types_spaces' => true, 'unary_operator_spaces' => true, 'whitespace_after_comma_in_array' => true, ]); diff --git a/README.md b/README.md index bbe905b..054e038 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details. ## Security -If you discover any security related issues, please use the [GitHub security reporting form](https://github.com/php-fig/fp/security) rather than the issue queue. +If you discover any security related issues, please use the [GitHub security reporting form](https://github.com/php-fig/per-attributes/security) rather than the issue queue. ## Working Group @@ -35,7 +35,7 @@ If you discover any security related issues, please use the [GitHub security rep ## License -The Lesser GPL version 3 or later. Please see [License File](LICENSE.md) for more information. +The MIT License. Please see [License File](LICENSE.md) for more information. [ico-version]: https://img.shields.io/packagist/v/fig/attributes.svg?style=flat-square [ico-license]: https://img.shields.io/badge/License-MIT-green.svg?style=flat-square diff --git a/composer.json b/composer.json index d1ca9a3..d893803 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,6 @@ } }, "scripts": { - "benchmarks": "vendor/bin/phpbench run benchmarks --report=aggregate", "test": "vendor/bin/phpunit", "test-coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --coverage-clover=coverage-clover.xml", "coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --coverage-html=\"build/coverage\"", From 34f7d614977d1225cfa01c75f9c603932f25f25d Mon Sep 17 00:00:00 2001 From: Larry Garfield Date: Mon, 8 Sep 2025 18:09:02 -0500 Subject: [PATCH 04/10] Assorted fixes from review. --- phpunit.xml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 3639b6e..bb0ca6b 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -8,9 +8,15 @@ requireCoverageMetadata="true" beStrictAboutCoverageMetadata="true" beStrictAboutOutputDuringTests="true" - displayDetailsOnPhpunitDeprecations="true" - failOnPhpunitDeprecation="true" failOnRisky="true" + displayDetailsOnTestsThatTriggerErrors="true" + displayDetailsOnTestsThatTriggerWarnings="true" + displayDetailsOnTestsThatTriggerNotices="true" + displayDetailsOnTestsThatTriggerDeprecations="true" + displayDetailsOnPhpunitDeprecations="false" + failOnNotice="true" + failOnDeprecation="true" + failOnPhpunitDeprecation="false" failOnWarning="true"> @@ -22,6 +28,8 @@ + + From 2f57ad87dbd2d8886be7ff0ae1d7f6c52ed02608 Mon Sep 17 00:00:00 2001 From: Larry Garfield Date: Mon, 8 Sep 2025 18:20:54 -0500 Subject: [PATCH 05/10] Use phpstan identifiers. --- phpstan.neon | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index d6765cd..f2c52a5 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,27 +5,20 @@ parameters: - src - tests ignoreErrors: - - message: '#(Array shape contains unspecified keys|Parameter .+ of method .+ contains unspecified keys|Array shape is not compatible with|Property .+ type with generic class .+ does not specify its types|Cannot access offset .+ on array\{.+\}|array\{.+\} does not accept key .+|Array has no value type specified in iterable type array)#' - paths: - - tests/* + # PHPStan is overly aggressive on readonly properties. + - identifier: property.uninitializedReadonly reportUnmatched: false - - - message: '#Method [a-zA-Z0-9\\_\\\\:\\(\\)]+ (has parameter \\\$[a-zA-Z0-9_]+|return type) with no value type specified in iterable type array#' - paths: - - tests/* + - identifier: property.readOnlyAssignNotInConstructor reportUnmatched: false - - message: '#Property [a-zA-Z0-9\\\$\\_\\\\:\\(\\)]+ type has no value type specified in iterable type array#' + # We don't need to be pedantic about iterable types in tests. + - identifier: missingType.iterableValue paths: - tests/* reportUnmatched: false + # PHPStan doesn't understand PHPUnit's self-termination methods. - - message: '#Unreachable statement - code above always terminates.#' + - identifier: deadCode.unreachable paths: - tests/* reportUnmatched: false - # PHPStan is overly aggressive on readonly properties. - - message: '#Class (.*) has an uninitialized readonly property (.*). Assign it in the constructor.#' - reportUnmatched: false - - message: '#Readonly property (.*) is assigned outside of the constructor.#' - reportUnmatched: false From eb2bbd9992ce632416a8a8cb242e2ce577502ddd Mon Sep 17 00:00:00 2001 From: Larry Garfield Date: Tue, 9 Sep 2025 09:55:57 -0500 Subject: [PATCH 06/10] Remove a few more unnecessary bits --- .github/workflows/quality-assurance.yaml | 4 ++-- .gitignore | 3 --- composer.json | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/quality-assurance.yaml b/.github/workflows/quality-assurance.yaml index 72ccb38..4cc8c8d 100644 --- a/.github/workflows/quality-assurance.yaml +++ b/.github/workflows/quality-assurance.yaml @@ -18,7 +18,7 @@ jobs: with: php-version: ${{ matrix.php }} coverage: xdebug - - run: composer install --no-progress ${{ matrix.composer-flags }} + - run: composer install --no-progress - run: vendor/bin/phpunit ${{ matrix.phpunit-flags }} phpstan: name: PHPStan checks on ${{ matrix.php }} @@ -33,7 +33,7 @@ jobs: with: php-version: ${{ matrix.php }} coverage: none - - run: composer install --no-progress ${{ matrix.composer-flags }} + - run: composer install --no-progress - run: composer phpstan cs: name: Code Style checks on ${{ matrix.php }} diff --git a/.gitignore b/.gitignore index f2f5e5a..a930c3e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,3 @@ vendor build composer.lock - -.idea -*.iml diff --git a/composer.json b/composer.json index d893803..99167d4 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,6 @@ "require-dev": { "friendsofphp/php-cs-fixer": "^v3.87.1", "php-cs-fixer/shim": "^3.85", - "phpmetrics/phpmetrics": "^2.9", "phpstan/phpstan": "^2.1.11", "phpunit/phpunit": "^11.1.0" }, From aecfed5d8c6adfea383ad5c9de28c83dd1edbc59 Mon Sep 17 00:00:00 2001 From: Larry Garfield Date: Wed, 10 Sep 2025 14:25:31 -0500 Subject: [PATCH 07/10] Add Jaap Co-authored-by: Jaap van Otterdijk --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 054e038..59b856b 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ If you discover any security related issues, please use the [GitHub security rep - [Larry Garfield][link-crell] - [All Contributors][link-contributors] - +- [Jaap van Otterdijk][link-jaapio] ## License The MIT License. Please see [License File](LICENSE.md) for more information. @@ -44,4 +44,5 @@ The MIT License. Please see [License File](LICENSE.md) for more information. [link-packagist]: https://packagist.org/packages/fig/attributes [link-downloads]: https://packagist.org/packages/fig/attributes [link-crell]: https://github.com/Crell +[link-jaapio]: https://github.com/Jaapio [link-contributors]: ../../contributors From 246de5bbfd8778441255890a5cfc3caec064feb2 Mon Sep 17 00:00:00 2001 From: Larry Garfield Date: Wed, 10 Sep 2025 14:26:00 -0500 Subject: [PATCH 08/10] main vs master Co-authored-by: Jaap van Otterdijk --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a546e9a..1da1f4c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,7 +14,7 @@ We accept contributions via Pull Requests on [Github](https://github.com/php-fig - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. -- **Create feature branches** - Don't ask us to pull from your master branch. +- **Create feature branches** - Don't ask us to pull from your main branch. - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. From 453afd0ee13e587e0bc851a485df3227c63a7761 Mon Sep 17 00:00:00 2001 From: Larry Garfield Date: Wed, 10 Sep 2025 16:06:12 -0500 Subject: [PATCH 09/10] Assorted fixes Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com> --- .gitattributes | 1 + .github/workflows/quality-assurance.yaml | 6 +++--- SECURITY.md | 2 +- composer.json | 1 - 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitattributes b/.gitattributes index bee9bdb..f5e4f44 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10,3 +10,4 @@ /tests export-ignore /docs export-ignore /phpstan.neon export-ignore +/.github export-ignore diff --git a/.github/workflows/quality-assurance.yaml b/.github/workflows/quality-assurance.yaml index 4cc8c8d..07ed0f5 100644 --- a/.github/workflows/quality-assurance.yaml +++ b/.github/workflows/quality-assurance.yaml @@ -7,7 +7,7 @@ on: jobs: phpunit: - name: PHPUnit tests on ${{ matrix.php }} ${{ matrix.composer-flags }} + name: PHPUnit tests on ${{ matrix.php }} runs-on: ubuntu-latest strategy: matrix: @@ -19,14 +19,13 @@ jobs: php-version: ${{ matrix.php }} coverage: xdebug - run: composer install --no-progress - - run: vendor/bin/phpunit ${{ matrix.phpunit-flags }} + - run: vendor/bin/phpunit phpstan: name: PHPStan checks on ${{ matrix.php }} runs-on: ubuntu-latest strategy: matrix: php: [ '8.4' ] - composer-flags: [ '' ] steps: - uses: actions/checkout@v2 - uses: shivammathur/setup-php@v2 @@ -46,5 +45,6 @@ jobs: - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} + coverage: none - run: composer install --no-progress - run: composer cs diff --git a/SECURITY.md b/SECURITY.md index 6c72660..d053c09 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -8,7 +8,7 @@ If you believe you've found a security issue in software that is maintained in t | Version | In scope | Source code | | ------- | -------- |-------------------------------------------| -| latest | ✅ | https://github.com/php-fig/per-attributes | +| latest | ✅ | https://github.com/php-fig/per-attributes | Only the latest stable release of this library is supported. In general, bug and security fixes will not be backported unless there is a substantial imminent threat to users in not doing so. diff --git a/composer.json b/composer.json index 99167d4..bbb4c22 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,6 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^v3.87.1", - "php-cs-fixer/shim": "^3.85", "phpstan/phpstan": "^2.1.11", "phpunit/phpunit": "^11.1.0" }, From 58c04e0ebfd0bf3fb1622c2a7e40a601d1181181 Mon Sep 17 00:00:00 2001 From: Larry Garfield Date: Wed, 10 Sep 2025 16:43:31 -0500 Subject: [PATCH 10/10] Rename to dist files. --- .gitattributes | 4 ++-- phpstan.neon => phpstan.neon.dist | 0 phpunit.xml => phpunit.xml.dist | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename phpstan.neon => phpstan.neon.dist (100%) rename phpunit.xml => phpunit.xml.dist (100%) diff --git a/.gitattributes b/.gitattributes index f5e4f44..3eca6c6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,8 +6,8 @@ /.gitattributes export-ignore /.gitignore export-ignore /.php-cs-fixer.php export-ignore -/phpunit.xml export-ignore +/phpunit.xml.dist export-ignore /tests export-ignore /docs export-ignore -/phpstan.neon export-ignore +/phpstan.neon.dist export-ignore /.github export-ignore diff --git a/phpstan.neon b/phpstan.neon.dist similarity index 100% rename from phpstan.neon rename to phpstan.neon.dist diff --git a/phpunit.xml b/phpunit.xml.dist similarity index 100% rename from phpunit.xml rename to phpunit.xml.dist