https://github.com/lstrojny/override-experiment
https://github.com/lstrojny/override-experiment
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/lstrojny/override-experiment
- Owner: lstrojny
- Created: 2023-11-09T14:20:41.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-10T05:28:15.000Z (over 1 year ago)
- Last Synced: 2024-10-10T14:23:39.719Z (8 months ago)
- Language: PHP
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Override attribute experiment
### About
- Use rector to automatically add the new PHP 8.3 `#[Override]` attribute
- Use PHPStan to check that methods marked with `#[Override]` actually override and the inverse that methods that override are marked with `#[Override]`### Usage
* Clone repository
* `composer install`
* Run `vendor/bin/phpstan` to show that the override attribute is verified (3 errors expected)
* Run `vendor/bin/rector` to add `Override` attribute (2 changes expected)
* Run `vendor/bin/phpstan` to show that the override attribute is verified (1 error expected)### How it works
* Rector is configured to add the `#[Override]` attribute for overridden methods (see [rector.php](./rector.php)
* Custom PHPStan rule to verify the `#[Override]` attribute (see [`nfq\ore\PhpStan\OverrideAttributeRule`](./src/PhpStan/OverrideAttributeRule.php))
* Registered in [phpstan.neon](./phpstan.neon)
* Polyfill for the `#[Override]` attribute (see [polyfill.php](./polyfill.php))
* Loaded in `autoload.files.0` (see [composer.json](./composer.json))