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
Currently, @internal annotations in Psalm work well for classes, methods, and properties, but the same behavior does not seem to apply to traits.
According to the docs, traits should also be supported, but in practice Psalm does not report any issue when a trait marked as @internal is used from another namespace.
I would expect Psalm to raise an error similar to how it does with internal classes:
ERROR: InternalTrait - A\C\UsesTrait uses internal trait A\B\InternalTrait from A\B
Actual behavior
No issue is reported, even though the trait is annotated with @internal and is being used outside of its declaring namespace.
Why this matters
Traits are a common way to share code internally in frameworks (e.g. Laravel).
Being able to mark them as @internal is important for package authors who want to expose only certain APIs while keeping others private.
This would align trait behavior with class/method @internal enforcement.
Suggested solutions / questions
Is this a missing feature in Psalm’s internal visibility checks?
Should trait usage be treated the same way as class inheritance when resolving @internal?
Would maintainers accept a PR to add this behavior?
Thanks for considering!
Would you like me to frame it as a bug report (“this doesn’t work, even though docs imply it should”) or as a feature request (“it would be nice if traits supported @internal like classes”)?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Context
Currently,
@internal
annotations in Psalm work well for classes, methods, and properties, but the same behavior does not seem to apply to traits.According to the docs, traits should also be supported, but in practice Psalm does not report any issue when a trait marked as
@internal
is used from another namespace.Example
https://psalm.dev/r/937049bbb3
Expected behavior
I would expect Psalm to raise an error similar to how it does with internal classes:
Actual behavior
No issue is reported, even though the trait is annotated with
@internal
and is being used outside of its declaring namespace.Why this matters
@internal
is important for package authors who want to expose only certain APIs while keeping others private.@internal
enforcement.Suggested solutions / questions
@internal
?Thanks for considering!
Would you like me to frame it as a bug report (“this doesn’t work, even though docs imply it should”) or as a feature request (“it would be nice if traits supported
@internal
like classes”)?Beta Was this translation helpful? Give feedback.
All reactions