On 6 January 2022 15:21:28 GMT, Robert Korulczyk <rob...@korulczyk.pl> wrote:
> It should also make it easier for SCA tools to understand 
>the code since they no longer need to know the whole project to understand 
>that method from trait is implementation of method from interface (which is 
>really tricky right now since it depends on context - trait can at the same 
>implement and not implement the interface, because it depends on class 
>where it is used).

Your other points make sense, but I don't think this one does - there are no 
implicit interfaces in PHP*, so all any tool cares about is:

1) Does the class declaration say that it implements an interface?
2) Does it actually contain the methods needed to do so, through any 
combination of direct implementation, inheritance, and trait usage?

Knowing that a particular trait *could be* used to implement a particular 
interface without further code doesn't really tell the tool anything - it still 
has to resolve the list of methods on the class itself, and test those against 
the "implements" clause. This is particularly true if the class uses the "as" 
and "insteadOf" clauses when including the trait, which nullify any promises 
the trait could make.


* other than "Stringable", whose purpose and implementation continue to baffle 
me

Regards,

-- 
Rowan Tommins
[IMSoP]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to