1
0
mirror of synced 2025-03-06 12:56:10 +03:00

#6068 hardened test logic to verify that nothing is present after the |null in @var and @return types

This commit is contained in:
Marco Pivetta 2016-11-26 06:35:23 +01:00
parent a4f76bda34
commit f8002ca27e

View File

@ -1080,17 +1080,25 @@ class
*/
private function assertPhpDocVarType($type, \ReflectionProperty $property)
{
$this->assertEquals(1, preg_match('/@var\s+([^\s]+)/',$property->getDocComment(), $matches));
$docComment = $property->getDocComment();
$regex = '/@var\s+([\S]+)$/m';
$this->assertRegExp($regex, $docComment);
$this->assertEquals(1, preg_match($regex, $docComment, $matches));
$this->assertEquals($type, $matches[1]);
}
/**
* @param string $type
* @param \ReflectionProperty $method
* @param \ReflectionMethod $method
*/
private function assertPhpDocReturnType($type, \ReflectionMethod $method)
{
$this->assertEquals(1, preg_match('/@return\s+([^\s]+)/', $method->getDocComment(), $matches));
$docComment = $method->getDocComment();
$regex = '/@return\s+([\S]+)(\s+.*)$/m';
$this->assertRegExp($regex, $docComment);
$this->assertEquals(1, preg_match($regex, $docComment, $matches));
$this->assertEquals($type, $matches[1]);
}