Merge pull request #17056 from owncloud/appframework-type-cast

Allow multiple whitespace in type hints in AppFramework
This commit is contained in:
Bernhard Posselt 2015-06-22 10:35:28 +02:00
commit 7fe5ab4d4a
2 changed files with 15 additions and 1 deletions

View File

@ -59,7 +59,7 @@ class ControllerMethodReflector implements IControllerMethodReflector{
$this->annotations = $matches[1];
// extract type parameter information
preg_match_all('/@param (?P<type>\w+) \$(?P<var>\w+)/', $docs, $matches);
preg_match_all('/@param\h+(?P<type>\w+)\h+\$(?P<var>\w+)/', $docs, $matches);
// this is just a fix for PHP 5.3 (array_combine raises warning if called with
// two empty arrays
if($matches['var'] === array() && $matches['type'] === array()) {

View File

@ -119,6 +119,20 @@ class ControllerMethodReflectorTest extends \Test\TestCase {
$this->assertEquals('double', $reader->getType('test'));
}
/**
* @Annotation
* @param string $foo
*/
public function testReadTypeWhitespaceAnnotations(){
$reader = new ControllerMethodReflector();
$reader->reflect(
'\OC\AppFramework\Utility\ControllerMethodReflectorTest',
'testReadTypeWhitespaceAnnotations'
);
$this->assertEquals('string', $reader->getType('foo'));
}
public function arguments($arg, $arg2='hi') {}
public function testReflectParameters() {