Skip to content

Commit

Permalink
require dev phpstan webmozart v2 and fix phsptan message return
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Nov 20, 2024
1 parent 7b5243d commit 2b4eab9
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 17 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"require-dev": {
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-webmozart-assert": "^2.0",
"phpunit/phpunit": "^10.5",
"rector/rector-src": "dev-upgrade-to-php-parser5-and-phpstan-2",
"symplify/easy-coding-standard": "^12.3",
Expand Down
4 changes: 0 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ parameters:
# see https://github.com/rectorphp/rector-src/actions/runs/11798721617/job/32865546672?pr=6422#step:5:110
- '#Doing instanceof PHPStan\\Type\\.+ is error\-prone and deprecated#'

# follow parent signature
-
identifier: return.unusedType

# phpstan instanceof
-
identifier: phpstanApi.instanceofAssumption
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function getNodeTypes(): array
/**
* @param ConstFetch|BitwiseOr|If_ $node
*/
public function refactor(Node $node): Expr|If_|null|int
public function refactor(Node $node): Expr|If_|null
{
if ($node instanceof If_) {
return $this->refactorIf($node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ public function getNodeTypes(): array

/**
* @param ConstFetch|BitwiseOr|If_|TryCatch|Expression $node
* @return int|null|Expr|If_|array<Expression|If_>
* @return null|Expr|If_|array<Expression|If_>
*/
public function refactor(Node $node): int|null|Expr|If_|array
public function refactor(Node $node): null|Expr|If_|array
{
if ($node instanceof If_) {
return $this->refactorIf($node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function getNodeTypes(): array
/**
* @param MethodCall|Ternary|Instanceof_ $node
*/
public function refactor(Node $node): Node|null|int
public function refactor(Node $node): Node|null
{
if ($node instanceof Instanceof_) {
return $this->refactorInstanceof($node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function getNodeTypes(): array
/**
* @param FuncCall $node
*/
public function refactor(Node $node): FuncCall|Ternary|null
public function refactor(Node $node): FuncCall|null
{
if (! $this->isName($node, 'array_filter')) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getNodeTypes(): array
/**
* @param Ternary|MethodCall $node
*/
public function refactor(Node $node): Ternary|null|int
public function refactor(Node $node): Ternary|null
{
if ($node instanceof Ternary) {
if ($node->if instanceof Expr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public function getNodeTypes(): array

/**
* @param Expression $node
* @return Node\Stmt[]|null|Expression
* @return Expression[]|null
*/
public function refactor(Node $node): array|null|Expression
public function refactor(Node $node): array|null
{
/** @var Assign[] $assigns */
$assigns = $this->betterNodeFinder->findInstancesOf($node, [Assign::class]);
Expand Down Expand Up @@ -123,7 +123,7 @@ private function isBetweenParentheses(Node $node): bool

/**
* @param Assign[] $assigns
* @return Node\Stmt[]|null
* @return Expression[]|null
*/
private function refactorAssign(array $assigns, Expression $expression): array|null
{
Expand Down Expand Up @@ -167,7 +167,7 @@ private function refactorAssign(array $assigns, Expression $expression): array|n
}

/**
* @return Node\Stmt[]|null
* @return Expression[]|null
*/
private function refactorInstanceof(Instanceof_ $instanceof, Expression $expression): ?array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function getNodeTypes(): array
/**
* @param NullsafeMethodCall|NullsafePropertyFetch $node
*/
public function refactor(Node $node): ?Ternary
public function refactor(Node $node): Ternary
{
$nullsafeVariable = $this->createNullsafeVariable();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Rector\DowngradePhp81\NodeFactory;

use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\ArrayItem;
use PhpParser\Node\Expr\Array_;
Expand All @@ -27,7 +26,7 @@ public function __construct(
) {
}

public function createFromArray(Array_ $array, MutatingScope $mutatingScope): ?Node
public function createFromArray(Array_ $array, MutatingScope $mutatingScope): FuncCall
{
$newArrayItems = $this->disolveArrayItems($array);
return $this->createArrayMergeFuncCall($newArrayItems, $mutatingScope);
Expand Down

0 comments on commit 2b4eab9

Please sign in to comment.