From 2c083216031ce5946c93a9bde16ab1180bca7d22 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Wed, 27 Nov 2019 00:00:46 -0500 Subject: [PATCH] Ignore union types for now --- composer.json | 2 +- src/Psalm/Internal/Visitor/ReflectorVisitor.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7143e7fdf..50e33215e 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "php": "^7.1.3", - "nikic/php-parser": "^4.2.3||^4.3", + "nikic/php-parser": "^4.3", "openlss/lib-array2xml": "^1.0", "ocramius/package-versions": "^1.2", "composer/xdebug-handler": "^1.1", diff --git a/src/Psalm/Internal/Visitor/ReflectorVisitor.php b/src/Psalm/Internal/Visitor/ReflectorVisitor.php index 0b0a902e8..2a16ccff1 100644 --- a/src/Psalm/Internal/Visitor/ReflectorVisitor.php +++ b/src/Psalm/Internal/Visitor/ReflectorVisitor.php @@ -1945,6 +1945,9 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse if ($parser_return_type instanceof PhpParser\Node\Identifier) { $return_type_string = $parser_return_type->name . $suffix; + } elseif ($parser_return_type instanceof PhpParser\Node\UnionType) { + // for now unsupported + $return_type_string = 'mixed'; } else { $return_type_fq_classlike_name = ClassLikeAnalyzer::getFQCLNFromNameObject( $parser_return_type, @@ -2691,6 +2694,9 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse $this->codebase->scanner->queueClassLikeForScanning($param_type_string, $this->file_path); $this->file_storage->referenced_classlikes[strtolower($param_type_string)] = $param_type_string; + } elseif ($param_typehint instanceof PhpParser\Node\UnionType) { + // not yet supported + $param_type_string = 'mixed'; } else { if ($this->classlike_storages && strtolower($param_typehint->parts[0]) === 'self' @@ -3060,6 +3066,9 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse if ($parser_property_type instanceof PhpParser\Node\Identifier) { $property_type_string = $parser_property_type->name . $suffix; + } elseif ($parser_property_type instanceof PhpParser\Node\UnionType) { + // not yet supported + $property_type_string = 'mixed'; } else { $property_type_fq_classlike_name = ClassLikeAnalyzer::getFQCLNFromNameObject( $parser_property_type,