8000 [PropertyInfo] ignore const expressions read by phpdocumentor by xabbuh · Pull Request #48251 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[PropertyInfo] ignore const expressions read by phpdocumentor #48251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Symfony/Component/PropertyInfo/Util/PhpDocTypeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\PropertyInfo\Util;

use phpDocumentor\Reflection\PseudoTypes\ConstExpression;
use phpDocumentor\Reflection\PseudoTypes\List_;
use phpDocumentor\Reflection\Type as DocType;
use phpDocumentor\Reflection\Types\Array_;
Expand Down Expand Up @@ -39,6 +40,11 @@ final class PhpDocTypeHelper
*/
public function getTypes(DocType $varType): array
{
if ($varType instanceof ConstExpression) {
// It's safer to fall back to other extractors here, as resolving const types correctly is not easy at the moment
return [];
}

$types = [];
$nullable = false;

Expand All @@ -64,6 +70,11 @@ public function getTypes(DocType $varType): array
for ($typeIndex = 0; $varType->has($typeIndex); ++$typeIndex) {
$type = $varType->get($typeIndex);

if ($type instanceof ConstExpression) {
// It's safer to fall back to other extractors here, as resolving const types correctly is not easy at the moment
return [];
}

// If null is present, all types are nullable
if ($type instanceof Null_) {
$nullable = true;
Expand Down
0