Skip to content

Commit

Permalink
Fix OverriddenPropertyAccess error message
Browse files Browse the repository at this point in the history
The message previously didn't mention the base class, which made it
confusing.
  • Loading branch information
edsrzf committed May 4, 2023
1 parent fc233da commit d2f0f6c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Analyzer/ClassAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ public static function addContextProperties(
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,
),
);
Expand Down
4 changes: 3 additions & 1 deletion tests/ClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use Psalm\Tests\Traits\InvalidCodeAnalysisTestTrait;
use Psalm\Tests\Traits\ValidCodeAnalysisTestTrait;

use const DIRECTORY_SEPARATOR;

class ClassTest extends TestCase
{
use InvalidCodeAnalysisTestTrait;
Expand Down Expand Up @@ -936,7 +938,7 @@ class B extends A {
/** @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' => '<?php
Expand Down

0 comments on commit d2f0f6c

Please sign in to comment.