Code Monkey home page Code Monkey logo

Comments (5)

carlosas avatar carlosas commented on July 24, 2024 1

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.

hkdobrev avatar hkdobrev commented on July 24, 2024

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.

carlosas avatar carlosas commented on July 24, 2024

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.

hkdobrev avatar hkdobrev commented on July 24, 2024

FWIW, see this Twitter thread with PHPStan author: https://twitter.com/OndrejMirtes/status/1239531736981274626

from phpat.

carlosas avatar carlosas commented on July 24, 2024

Implemented in https://github.com/carlosas/phpat/releases/tag/0.10.1
More assertions on the way 🙂

from phpat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.