File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
tests/PHPStan/Rules/Properties/data Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -430,7 +430,8 @@ private function createProperty(
430430 && $ this ->annotationsPropertiesClassReflectionExtension ->hasProperty ($ classReflection , $ propertyName )
431431 && (
432432 $ nativeProperty ->isPublic ()
433- || ($ scope ->isInClass () && $ scope ->getClassReflection ()->getName () !== $ declaringClassReflection ->getName ())
433+ || !$ scope ->isInClass ()
434+ || $ scope ->getClassReflection ()->getName () !== $ declaringClassReflection ->getName ()
434435 )
435436 ) {
436437 $ hierarchyDistances = $ classReflection ->getClassHierarchyDistances ();
@@ -451,7 +452,7 @@ private function createProperty(
451452 if (
452453 $ hierarchyDistances [$ annotationProperty ->getDeclaringClass ()->getName ()] <= $ hierarchyDistances [$ distanceDeclaringClass ]
453454 ) {
454- if ($ nativeType ->isSuperTypeOf ($ annotationProperty ->getReadableType ())->yes ()) {
455+ if ($ nativeType ->isSuperTypeOf ($ annotationProperty ->getReadableType ())->yes () || ! $ scope -> canReadProperty ( $ nativeProperty ) ) {
455456 $ nativeType = new MixedType ();
456457 }
457458
Original file line number Diff line number Diff line change @@ -62,3 +62,14 @@ function (): void {
6262
6363 assertType (stdClass::class, $ bar ->attributes );
6464};
65+
66+ class Test
67+ {
68+ public function doFoo (): void
69+ {
70+ $ bar = new Bar2 ();
71+ echo $ bar ->attributes ->foo ;
72+
73+ assertType (stdClass::class, $ bar ->attributes );
74+ }
75+ }
You can’t perform that action at this time.
0 commit comments