Skip to content

Commit

Permalink
fix class-string compare
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Dec 12, 2024
1 parent 75860ba commit ed8ebe7
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 93 deletions.
20 changes: 0 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,37 +50,17 @@
"phpstan/phpstan-webmozart-assert": "^2.0",
"phpunit/phpunit": "^11.5",
"rector/release-notes-generator": "^0.3.0",
<<<<<<< HEAD
<<<<<<< HEAD
"rector/swiss-knife": "^2.0",
=======
<<<<<<< HEAD
"rector/swiss-knife": "^0.2.16",
>>>>>>> 7745041b3b (restore dev static analysis tools)
"rector/type-perfect": "^2.0",
"shipmonk/composer-dependency-analyser": "^1.8",
"symplify/easy-coding-standard": "^12.5",
"symplify/phpstan-extensions": "^12.0",
<<<<<<< HEAD
"symplify/phpstan-rules": "^14.0",
"symplify/rule-doc-generator": "^12.2.5",
"symplify/vendor-patches": "^11.3",
"tomasvotruba/class-leak": "^2.0",
=======
=======
"rector/type-perfect": "^2.0",
>>>>>>> d8ba100b89 (bump deps)
"symplify/phpstan-rules": "^14.0.2",
"rector/swiss-knife": "^2.0",
"shipmonk/composer-dependency-analyser": "^1.8",
"symplify/easy-coding-standard": "^12.4",
"symplify/phpstan-extensions": "^12.0",
"symplify/rule-doc-generator": "^12.2",
"symplify/vendor-patches": "^11.3",
"tomasvotruba/class-leak": "^2.0",
"tomasvotruba/type-coverage": "^2.0",
"tomasvotruba/unused-public": "^2.0",
>>>>>>> 7745041b3b (restore dev static analysis tools)
"tracy/tracy": "^2.9"
},
"replace": {
Expand Down
24 changes: 1 addition & 23 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,7 @@ includes:
parameters:
level: 8
errorFormat: symplify
<<<<<<< HEAD

<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 4e3ac08b3c (fix few reported static errors)
reportUnmatchedIgnoredErrors: false
errorFormat: symplify
=======
# reportUnmatchedIgnoredErrors: false
>>>>>>> 7a1a2b4658 (cleanup fixed phpstan errors)
=======
reportUnmatchedIgnoredErrors: false
>>>>>>> 95bce6d377 (use config param to set error format)

# requires exact closure types
checkMissingCallableSignature: true
Expand Down Expand Up @@ -323,7 +310,6 @@ parameters:
- '#Method Rector\\.*::providePolyfillPackage\(\) never returns#'
- '#Method Rector\\.*::filterPolyfillPackages\(\) should return array\<#'

<<<<<<< HEAD
-
identifier: typePerfect.noMixedMethodCaller
paths:
Expand All @@ -332,14 +318,11 @@ parameters:
-
path: src/NodeTypeResolver/PHPStan/Type/TypeFactory.php
message: '#Method Rector\\NodeTypeResolver\\PHPStan\\Type\\TypeFactory\:\:uniquateTypes\(\) should return array<TType of PHPStan\\Type\\Type> but returns list<PHPStan\\Type\\Type>#'
=======

# collection of Type
-
message: '#Method Rector\\NodeTypeResolver\\PHPStan\\Type\\TypeFactory::uniquateTypes\(\) should return array\<TType of PHPStan\\Type\\Type\> but returns list\<PHPStan\\Type\\Type>#'
path: src/NodeTypeResolver/PHPStan/Type/TypeFactory.php
<<<<<<< HEAD
>>>>>>> 7a1a2b4658 (cleanup fixed phpstan errors)
=======

# known native PHP type
-
Expand All @@ -355,12 +338,7 @@ parameters:
-
message: '#Possibly invalid array key type array<mixed>\|PHPStan\\PhpDocParser\\Ast\\ConstExpr\\ConstExprNode\|Rector\\BetterPhpDocParser\\PhpDoc\\DoctrineAnnotationTagValueNode\|Rector\\BetterPhpDocParser\\PhpDoc\\StringNode\|Rector\\BetterPhpDocParser\\ValueObject\\PhpDoc\\DoctrineAnnotation\\CurlyListNode\|string#'
path: src/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser.php
<<<<<<< HEAD
>>>>>>> 4e3ac08b3c (fix few reported static errors)
=======

# overly detailed
- '#expects (non\-empty\-string|class-string), string given#'
- '#expects list<(.*?)>, array<(.*?)> given#'

>>>>>>> e70cfd86c4 (add few static fixes)

This file was deleted.

17 changes: 7 additions & 10 deletions rules/DeadCode/Rector/If_/RemoveAlwaysTrueIfConditionRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,13 @@ private function shouldSkipFromVariable(Expr $expr): bool

private function shouldSkipExpr(Expr $expr): bool
{
return (bool) $this->betterNodeFinder->findInstancesOf(
$expr,
[
PropertyFetch::class,
StaticPropertyFetch::class,
ArrayDimFetch::class,
MethodCall::class,
StaticCall::class,
]
);
return (bool) $this->betterNodeFinder->findInstancesOf($expr, [
PropertyFetch::class,
StaticPropertyFetch::class,
ArrayDimFetch::class,
MethodCall::class,
StaticCall::class,
]);
}

private function refactorIfWithBooleanAnd(If_ $if): ?If_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ public function narrow(Type $paramType): Type

if ($className === 'PhpCsFixer\Tokenizer\Tokens') {
$types[] = new ObjectType('PhpCsFixer\Tokenizer\Token');
}

if ($className === 'PhpCsFixer\Doctrine\Annotation\Tokens') {
} elseif ($className === 'PhpCsFixer\Doctrine\Annotation\Tokens') {
$types[] = new ObjectType('PhpCsFixer\Doctrine\Annotation\Token');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,11 @@ public function enterNode(Node $node): ?Node

foreach ($this->oldToNewTypes as $oldToNewType) {
$oldType = $oldToNewType->getOldType();
<<<<<<< HEAD
if (! $oldType instanceof ObjectType) {
continue;
}

if (! $objectType->equals($oldType)) {
=======
if (! $oldType instanceof ObjectType || ! $objectType->equals($oldType)) {
>>>>>>> e07c5f96d4 (add few static fixes)
continue;
}

Expand Down
10 changes: 0 additions & 10 deletions src/NodeTypeResolver/TypeComparator/TypeComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
{
public function __construct(
private TypeHasher $typeHasher,
<<<<<<< HEAD
=======
// private TypeNormalizer $typeNormalizer,
>>>>>>> e07c5f96d4 (add few static fixes)
private StaticTypeMapper $staticTypeMapper,
private ArrayTypeComparator $arrayTypeComparator,
private ScalarTypeComparator $scalarTypeComparator,
Expand Down Expand Up @@ -58,12 +54,6 @@ public function areTypesEqual(Type $firstType, Type $secondType): bool
return true;
}

<<<<<<< HEAD
=======
// $firstType = $this->typeNormalizer->normalizeArrayOfUnionToUnionArray($firstType);
// $secondType = $this->typeNormalizer->normalizeArrayOfUnionToUnionArray($secondType);

>>>>>>> e07c5f96d4 (add few static fixes)
if ($this->typeHasher->areTypesEqual($firstType, $secondType)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

final class ClassNameFromObjectTypeResolver
{
/**
* @return class-string|null
*/
public static function resolve(Type $type): ?string
{
/** @var array<class-string> $objectClassNames */
Expand Down
12 changes: 12 additions & 0 deletions stubs/Twig/Extension/SandboxExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Twig\Extension;

if (class_exists('Twig\Extension\SandboxExtension')) {
return;
}

class SandboxExtension
{

}

0 comments on commit ed8ebe7

Please sign in to comment.