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
{{ message }}
Repository navigation
[Bug]: Class constant check reads private/protected constants from file scope (fatal "Cannot access private constant") #135
Version: typephp/typephp v0.14.0, PHP 8.5 (worked on v0.11.2)
Description
For a class constant with an @var docblock that cannot be proven statically, ContractVisitor::collectUnprovenClassConstantChecks() appends a check statement after the class body, at file scope:
The method does not check the constant's visibility. For a private or protected
constant, \App\Example::MAP is not accessible from file scope, so loading the
file fails with a fatal error, even though the code is valid.
Expected
Either check non-public constants from inside the class scope (e.g. a scope-bound
closure via Closure::bind(..., null, Example::class)), or skip the check for
non-public constants.
Workaround @typephp-ignore on the constant's docblock (with respect_ignore_tags enabled).
Activity
rcalicdan commentedon Nov 22, 2026
@klunejko Hello this now resolve in recent v0.14.1 release..
Note this release brings massive performance improvement..