Skip to content

Commit

Permalink
Fixes after rebasing.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrolGenhald committed Jan 25, 2022
1 parent 0edf260 commit 0b81f46
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 18 deletions.
1 change: 0 additions & 1 deletion config.xsd
Expand Up @@ -410,7 +410,6 @@
<xs:element name="RedundantConditionGivenDocblockType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="RedundantFunctionCall" type="IssueHandlerType" minOccurs="0" />
<xs:element name="RedundantFunctionCallGivenDocblockType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="RedundantPropertyInitializationCheck" type="IssueHandlerType" minOccurs="0" />
<xs:element name="RedundantIdentityWithTrue" type="IssueHandlerType" minOccurs="0" />
<xs:element name="RedundantPropertyInitializationCheck" type="IssueHandlerType" minOccurs="0" />
<xs:element name="ReferenceConstraintViolation" type="IssueHandlerType" minOccurs="0" />
Expand Down
3 changes: 3 additions & 0 deletions docs/running_psalm/issues.md
Expand Up @@ -2,6 +2,7 @@

- [AbstractInstantiation](issues/AbstractInstantiation.md)
- [AbstractMethodCall](issues/AbstractMethodCall.md)
- [AmbiguousConstantInheritance](issues/AmbiguousConstantInheritance.md)
- [ArgumentTypeCoercion](issues/ArgumentTypeCoercion.md)
- [AssignmentToVoid](issues/AssignmentToVoid.md)
- [CircularReference](issues/CircularReference.md)
Expand Down Expand Up @@ -93,6 +94,7 @@
- [InvalidToString](issues/InvalidToString.md)
- [InvalidTraversableImplementation](issues/InvalidTraversableImplementation.md)
- [InvalidTypeImport](issues/InvalidTypeImport.md)
- [LessSpecificClassConstantType](issues/LessSpecificClassConstantType.md)
- [LessSpecificImplementedReturnType](issues/LessSpecificImplementedReturnType.md)
- [LessSpecificReturnStatement](issues/LessSpecificReturnStatement.md)
- [LessSpecificReturnType](issues/LessSpecificReturnType.md)
Expand Down Expand Up @@ -153,6 +155,7 @@
- [NullPropertyAssignment](issues/NullPropertyAssignment.md)
- [NullPropertyFetch](issues/NullPropertyFetch.md)
- [NullReference](issues/NullReference.md)
- [OverriddenInterfaceConstant](issues/OverriddenInterfaceConstant.md)
- [OverriddenMethodAccess](issues/OverriddenMethodAccess.md)
- [OverriddenPropertyAccess](issues/OverriddenPropertyAccess.md)
- [ParadoxicalCondition](issues/ParadoxicalCondition.md)
Expand Down
Expand Up @@ -722,15 +722,14 @@ public static function analyze(
): void {
foreach ($class_storage->constants as $const_name => $const_storage) {
// Check covariance
/** @psalm-suppress PossiblyNullArrayAccess https://github.com/vimeo/psalm/issues/7151 */
[$parent_classlike_storage, $parent_const_storage] = self::getOverriddenConstant(
$class_storage,
$const_storage,
$const_name,
$codebase
);
/** @psalm-suppress RedundantConditionGivenDocblockType https://github.com/vimeo/psalm/issues/7151 */
if ($parent_const_storage !== null) {
assert($parent_classlike_storage !== null);
$location = $const_storage->type_location ?? $const_storage->stmt_location;
if ($location !== null
&& $const_storage->type !== null
Expand Down Expand Up @@ -776,10 +775,7 @@ private static function getOverriddenConstant(
if ($parent_const_storage !== null) {
if ($const_storage->location
&& $const_storage !== $parent_const_storage
&& (
$codebase->php_major_version < 8
|| ($codebase->php_major_version === 8 && $codebase->php_minor_version < 1)
)
&& $codebase->analysis_php_version_id < 8_01_00
) {
$interface_overrides[strtolower($interface)] = new OverriddenInterfaceConstant(
"{$class_storage->name}::{$const_name} cannot override constant from $interface",
Expand Down
1 change: 1 addition & 0 deletions src/Psalm/Issue/AmbiguousConstantInheritance.php
@@ -1,4 +1,5 @@
<?php

namespace Psalm\Issue;

class AmbiguousConstantInheritance extends ClassConstantIssue
Expand Down
1 change: 1 addition & 0 deletions src/Psalm/Issue/LessSpecificClassConstantType.php
@@ -1,4 +1,5 @@
<?php

namespace Psalm\Issue;

class LessSpecificClassConstantType extends ClassConstantIssue
Expand Down
1 change: 1 addition & 0 deletions src/Psalm/Issue/OverriddenInterfaceConstant.php
@@ -1,4 +1,5 @@
<?php

namespace Psalm\Issue;

class OverriddenInterfaceConstant extends ClassConstantIssue
Expand Down
1 change: 0 additions & 1 deletion src/Psalm/Type/Atomic/TList.php
Expand Up @@ -39,7 +39,6 @@ public function __construct(Union $type_param)

public function getId(bool $exact = true, bool $nested = false): string
{
/** @psalm-suppress MixedOperand */
return static::KEY . '<' . $this->type_param->getId($exact) . '>';
}

Expand Down
19 changes: 9 additions & 10 deletions tests/ConstantTest.php
Expand Up @@ -1328,7 +1328,7 @@ function foo(array $arg): void {}
',
],
'classConstCovariant' => [
'<?php
'code' => '<?php
abstract class A {
/** @var string */
public const COVARIANT = "";
Expand All @@ -1349,7 +1349,7 @@ abstract class C extends B {
',
],
'overrideClassConstFromInterface' => [
'<?php
'code' => '<?php
interface Foo
{
/** @var non-empty-string */
Expand All @@ -1369,7 +1369,7 @@ class Baz implements Bar
'8.1',
],
'inheritedConstDoesNotOverride' => [
'<?php
'code' => '<?php
interface Foo
{
public const BAR="baz";
Expand Down Expand Up @@ -1473,9 +1473,8 @@ public function getC(): string {
}
}',
'error_message' => 'InvalidReturnStatement',
[],
false,
'8.1',
'ignored_issues' => [],
'php_version' => '8.1',
],
'outOfScopeDefinedConstant' => [
'code' => '<?php
Expand Down Expand Up @@ -1753,7 +1752,7 @@ class Foo
'error_message' => "InvalidConstantAssignmentValue",
],
'classConstContravariant' => [
'<?php
'code' => '<?php
abstract class A {
/** @var non-empty-string */
public const CONTRAVARIANT = "foo";
Expand All @@ -1769,7 +1768,7 @@ abstract class C extends B {
'error_message' => "LessSpecificClassConstantType",
],
'classConstAmbiguousInherit' => [
'<?php
'code' => '<?php
interface Foo
{
/** @var non-empty-string */
Expand All @@ -1791,7 +1790,7 @@ class BarBaz extends Baz implements Bar
'error_message' => 'AmbiguousConstantInheritance',
],
'overrideClassConstFromInterface' => [
'<?php
'code' => '<?php
interface Foo
{
/** @var non-empty-string */
Expand All @@ -1809,7 +1808,7 @@ class Baz implements Bar
'error_message' => 'OverriddenInterfaceConstant',
],
'overrideClassConstFromInterfaceWithInterface' => [
'<?php
'code' => '<?php
interface Foo
{
/** @var non-empty-string */
Expand Down

0 comments on commit 0b81f46

Please sign in to comment.