-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Symfony version(s) affected: 5.2.6
Description
According to https://docs.phpdoc.org/latest/guide/references/phpdoc/types.html true
and false
are valid property types in PhpDoc, but PhpDocExtractor
fails to extract them properly.
How to reproduce
For example \Symfony\Component\HttpFoundation\Request::$content
is described as @var string|resource|false|null
, but:
$phpDocExtractor = new PhpDocExtractor();
$types = $phpDocExtractor->getTypes(Request::class, 'content');
dump($types);
returns:
^ array:3 [
0 => Symfony\Component\PropertyInfo\Type^ {#919
-builtinType: "string"
-nullable: true
-class: null
-collection: false
-collectionKeyType: []
-collectionValueType: []
}
1 => Symfony\Component\PropertyInfo\Type^ {#918
-builtinType: "resource"
-nullable: true
-class: null
-collection: false
-collectionKeyType: []
-collectionValueType: []
}
2 => Symfony\Component\PropertyInfo\Type^ {#934
-builtinType: "object"
-nullable: true
-class: "alse"
-collection: false
-collectionKeyType: []
-collectionValueType: []
}
]
See last type's builtinType: "object"
and class: "alse"
.
Possible Solution
This seems to fix it - #40943 - at least in this specific use case - with the following result:
^ array:3 [
0 => Symfony\Component\PropertyInfo\Type^ {#919
-builtinType: "string"
-nullable: true
-class: null
-collection: false
-collectionKeyType: []
-collectionValueType: []
}
1 => Symfony\Component\PropertyInfo\Type^ {#918
-builtinType: "resource"
-nullable: true
-class: null
-collection: false
-collectionKeyType: []
-collectionValueType: []
}
2 => Symfony\Component\PropertyInfo\Type^ {#934
-builtinType: "false"
-nullable: true
-class: null
-collection: false
-collectionKeyType: []
-collectionValueType: []
}
]