Skip to content

Commit

Permalink
Add alpha support for psalm v6 and php-parser v5
Browse files Browse the repository at this point in the history
See #52
  • Loading branch information
kkmuffme committed Feb 18, 2024
1 parent 86763ef commit 693c173
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use PhpParser\Node\Stmt\GroupUse;
use PhpParser\Node\Stmt\Namespace_;
use PhpParser\Node\Stmt\Return_;
use PhpParser\Node\Stmt\UseUse;
use PhpParser\Node\UseItem;
use Psalm;
use Psalm\CodeLocation;
use Psalm\Config;
Expand Down Expand Up @@ -382,7 +382,7 @@ public static function getDynamicHookName( object $arg ) : ?string {
return '{$' . $arg->name . '}';
}

if ( $arg instanceof PhpParser\Node\Scalar\Encapsed ) {
if ( $arg instanceof PhpParser\Node\Scalar\Encapsed || $arg instanceof PhpParser\Node\Scalar\InterpolatedString ) {
$hook_name = '';
foreach ( $arg->parts as $part ) {
$resolved_part = static::getDynamicHookName( $part );
Expand Down Expand Up @@ -412,7 +412,7 @@ public static function getDynamicHookName( object $arg ) : ?string {
return $hook_name;
}

if ( $arg instanceof String_ || $arg instanceof PhpParser\Node\Scalar\EncapsedStringPart || $arg instanceof PhpParser\Node\Scalar\LNumber ) {
if ( $arg instanceof String_ || $arg instanceof PhpParser\Node\Scalar\EncapsedStringPart || $arg instanceof PhpParser\Node\InterpolatedStringPart || $arg instanceof PhpParser\Node\Scalar\LNumber || $arg instanceof PhpParser\Node\Scalar\Int_ ) {
return $arg->value;
}

Expand Down Expand Up @@ -1352,7 +1352,7 @@ public function enterNode( PhpParser\Node $node ) {
}

// normal "use" statements
if ( $node instanceof UseUse ) {
if ( $node instanceof PhpParser\Node\Stmt\UseUse || $node instanceof UseItem ) {
// must implode, before we remove the class name from the array
$fqcn = $node->name->toString();

Expand Down Expand Up @@ -1499,9 +1499,9 @@ public function enterNode( PhpParser\Node $node ) {
$types[] = Type::getString();
} elseif ( $item->value instanceof Array_ || $item->value instanceof PhpParser\Node\Expr\Cast\Array_ ) {
$types[] = Type::getArray();
} elseif ( $item->value instanceof PhpParser\Node\Scalar\LNumber || $item->value instanceof PhpParser\Node\Expr\Cast\Int_ ) {
} elseif ( $item->value instanceof PhpParser\Node\Scalar\LNumber || $item->value instanceof PhpParser\Node\Scalar\Int_ || $item->value instanceof PhpParser\Node\Expr\Cast\Int_ ) {
$types[] = Type::getInt();
} elseif ( $item->value instanceof PhpParser\Node\Scalar\DNumber || $item->value instanceof PhpParser\Node\Expr\Cast\Double ) {
} elseif ( $item->value instanceof PhpParser\Node\Scalar\DNumber || $item->value instanceof PhpParser\Node\Scalar\Float_ || $item->value instanceof PhpParser\Node\Expr\Cast\Double ) {
$types[] = Type::getFloat();
} elseif ( ( $item->value instanceof PhpParser\Node\Expr\ConstFetch && in_array( strtolower( $item->value->name->toString() ), [ 'false', 'true' ], true ) ) || $item->value instanceof PhpParser\Node\Expr\Cast\Bool_ ) {
$types[] = Type::getBool();
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"php-stubs/wordpress-stubs": "^6.0",
"php-stubs/wordpress-globals": "^0.2.0",
"php-stubs/wp-cli-stubs": "^2.7",
"vimeo/psalm": "^5"
"vimeo/psalm": "^5 || ^6"
},
"require-dev": {
"humanmade/coding-standards": "^1.2",
Expand Down

0 comments on commit 693c173

Please sign in to comment.