From d2f0f6ce30ffe05adc221d80803c8c5ee1f2086c Mon Sep 17 00:00:00 2001 From: Evan Shaw Date: Thu, 4 May 2023 21:49:03 +1200 Subject: [PATCH] Fix OverriddenPropertyAccess error message The message previously didn't mention the base class, which made it confusing. --- src/Psalm/Internal/Analyzer/ClassAnalyzer.php | 2 +- tests/ClassTest.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php index 9ec347fc4..3d120c893 100644 --- a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php @@ -702,7 +702,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer new OverriddenPropertyAccess( 'Property ' . $fq_class_name . '::$' . $property_name . ' has different access level than ' - . $storage->name . '::$' . $property_name, + . $guide_class_name . '::$' . $property_name, $property_storage->location, ), ); diff --git a/tests/ClassTest.php b/tests/ClassTest.php index 6a697b63e..50adaa48a 100644 --- a/tests/ClassTest.php +++ b/tests/ClassTest.php @@ -5,6 +5,8 @@ namespace Psalm\Tests; use Psalm\Tests\Traits\InvalidCodeAnalysisTestTrait; use Psalm\Tests\Traits\ValidCodeAnalysisTestTrait; +use const DIRECTORY_SEPARATOR; + class ClassTest extends TestCase { use InvalidCodeAnalysisTestTrait; @@ -936,7 +938,7 @@ class ClassTest extends TestCase /** @var string|null */ private $foo; }', - 'error_message' => 'OverriddenPropertyAccess', + 'error_message' => 'OverriddenPropertyAccess - src' . DIRECTORY_SEPARATOR . 'somefile.php:9:33 - Property B::$foo has different access level than A::$foo', ], 'overridePublicPropertyAccessLevelToProtected' => [ 'code' => '