Download the PHP package atournayre/phpstan-elegant-object without Composer
On this page you can find all versions of the php package atournayre/phpstan-elegant-object. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package phpstan-elegant-object
This extension is a work in progress. Use at your own risk.
PHPStan Elegant Object Rules
This PHPStan extension adds custom rules to encourage and validate elegant object design principles in your PHP code.
It's based on Yegor Bugayenko's books :
- Elegant Objects (Volume 1)
- Elegant Objects (Volume 2)
Installation
Configuration
Include the extension in your phpstan.neon file:
It is recommended to configure each rule separately.
Available Rules
See configuration for a list of available rules.
Creating Custom Rules
To create a new rule:
- Create a class in the
src/Analyzer/folder that implementsAtournayre\PHPStan\ElegantObject\Analyzer\RuleAnalyzer - Define the node type to analyze with
getNodeType() - Override
shouldSkipAnalysis()if necessary - Implement your analysis logic in
analyze() - Create a class in the
src/Rules/folder that extendsAtournayre\PHPStan\ElegantObject\Rules\ComposableRule(see existing rules for examples) - Register your rule in
phpstan.neon
Tests
To run the tests:
Rules
From the book:
- [x] Never use -er names (chapter 1.1)
- [x] Keep constructors code-free (chapter 1.3)
- [x] Always use interface (chapter 2.3)
- [x] Don't use public constant (chapter 2.5)
- [x] Be immutable (chapter 2.6)
- [x] Keep interfaces short (chapter 2.9)
- [x] Expose fewer than 5 public methods (chapter 3.1)
- [x] Don't use static methods (chapter 3.2)
- [x] Never accept null arguments (chapter 3.3)
- [x] Never use getters and setters (chapter 3.5)
- [x] Don't use new outside of secondary constructors (chapter 3.6)
- [ ] Avoid type introspection and casting (chapter 3.7)
- [x] Never return Null (chapter 4.1)
- [ ] Throw only checked exceptions (chapter 4.2)
- [x] Be either final or abstract (chapter 4.3)
- [ ] Private static literals (chapter 5.4)
Other:
- [x] All properties must be private
- [ ] Constructor objects only
All versions of phpstan-elegant-object with dependencies
PHP Build Version
Package Version
The package atournayre/phpstan-elegant-object contains the following files
Loading the files please wait ...