Skip to content

Commit

Permalink
Merge pull request #9740 from edsrzf/better-property-error
Browse files Browse the repository at this point in the history
Fix OverriddenPropertyAccess error message
  • Loading branch information
orklah committed May 4, 2023
2 parents f8895ed + d2f0f6c commit 7483f4d
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 7483f4d

Please sign in to comment.