You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a use case where used traits are being incorrectly detected as namespace imports.
Looking at ContextFactory->createForNamespace, it seems that the check is simply looking for all T_USE tokens, and not checking whether they are within the context of a T_CLASS token.
For example, given this PHP code:
<?phpnamespaceFoo;
trait FooTrait {}
class FooClass {
use FooTrait;
}
... when creating context for this, the namespace aliases should be simply empty array [] as there ARE no namespace aliases. However, ContextFactory currently picks up the use FooTrait; and thinks it is a namespace alias.
I have provided a failing test case that can be added to tests/unit/Types/ContextFactoryTest.php:
I have a use case where used traits are being incorrectly detected as namespace imports.
Looking at
ContextFactory->createForNamespace
, it seems that the check is simply looking for allT_USE
tokens, and not checking whether they are within the context of aT_CLASS
token.For example, given this PHP code:
... when creating context for this, the namespace aliases should be simply empty array
[]
as there ARE no namespace aliases. However,ContextFactory
currently picks up theuse FooTrait;
and thinks it is a namespace alias.I have provided a failing test case that can be added to
tests/unit/Types/ContextFactoryTest.php
:The text was updated successfully, but these errors were encountered: