Comments (5)
This is right in the limit between class relations and pure static code analysis 🤔
Theoretically the same assertion could be done with 'App\*' must not extend 'App\Entity\*'
. On the other hand, this opens a door for mustBeAbstract
, mustBeAnInterface
, etc... which can help you in case you want to organise your classes in some specific way.
I will put a debate
label on this issue for some time and I will ask for opinion to more people. Feel free to share this issue on social networks so that more people can discuss the usefulness of this kind of features (and if it has place on this tool).
from phpat.
I agree this is may be suitable for a static code analysis tool like PHPStan.
which can help you in case you want to organise your classes in some specific way.
I'm looking at phpat as a tool specifically to enforce a certain class organisation in addition to enforcing dependency rules between modules.
The PHP Architecture Tester is really good at easy composition of selectors of class types and providing generic assertions. Other static code analysis tools are not structured to be configured so easily. For example, in order to configure PHPStan to check for certain classes to be final you need to create a new rule class, detect the class via AST rather than an easy selector, very possibly you'd need a new class representing the classes matching the AST selection and it's not as easy to extend the rule to other class groups.
This could be an argument that PHPStan should be making things easier to configure (e.g. similarly to how you'd configure a predefined rector), but also phpat could add this because of how it provides easy selection of class groups.
from phpat.
Ok, I think some little static checks can be suitable for phpat, because they define how classes are able to relate with others. This can be done but there is previous work to do to accept rules without destination classes.
I will put this enhancement on hold until the tool is ready to handle it 😄
from phpat.
FWIW, see this Twitter thread with PHPStan author: https://twitter.com/OndrejMirtes/status/1239531736981274626
from phpat.
Implemented in https://github.com/carlosas/phpat/releases/tag/0.10.1
More assertions on the way 🙂
from phpat.
Related Issues (20)
- Stringable not included in ignore_built_in_classes HOT 3
- should the config files be moved to their default locations / Makefile? HOT 1
- PHP enums should not be final HOT 1
- Built-in classes should not be ignored when specifically requested in rules
- Readonly class requirement HOT 2
- After update psalm dies to unknown class HOT 1
- "shouldExtend" assertion not applying to classes that do not have parent class HOT 3
- PHPStan throws violation on accessing `->because()` after `->excluding()` HOT 2
- Extending the rules HOT 8
- Testing the arch tests HOT 2
- Ability to combine assertions HOT 3
- Add an ability to check class naming HOT 4
- `Selector::inNamespace` incorrectly matches classes outside namespace with a similar name
- Report old `includeTrait` or newer `mustInclude` functions in 0.10+ version
- shouldBeNamed assertion not functioning on second run HOT 3
- Plugins should not be able to referance other plugins HOT 6
- Ability to restrict method calls HOT 1
- Ability to dynamically create tests like phpunit data providers HOT 1
- Ability to fail all classes based on selectors HOT 3
- Namespace naming assertions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phpat.