From 04b6f67f07802f4a4b580f74cf2502f5e0cbbb24 Mon Sep 17 00:00:00 2001 From: Robin McCorkell Date: Sat, 20 Jun 2015 23:44:02 +0100 Subject: [PATCH 1/2] Allow multiple whitespace in type hints in AppFramework Type hints such as `@param bool $doSomething` will now correctly get parsed, allowing for alignment of docblock parameters if the app developer so wishes. --- lib/private/appframework/utility/controllermethodreflector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/appframework/utility/controllermethodreflector.php b/lib/private/appframework/utility/controllermethodreflector.php index 93510093c08..e013a74253a 100644 --- a/lib/private/appframework/utility/controllermethodreflector.php +++ b/lib/private/appframework/utility/controllermethodreflector.php @@ -59,7 +59,7 @@ class ControllerMethodReflector implements IControllerMethodReflector{ $this->annotations = $matches[1]; // extract type parameter information - preg_match_all('/@param (?P\w+) \$(?P\w+)/', $docs, $matches); + preg_match_all('/@param\h+(?P\w+)\h+\$(?P\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()) { From f1e3e2515856816fabbd0836ddc24495d35c2edf Mon Sep 17 00:00:00 2001 From: Robin McCorkell Date: Sun, 21 Jun 2015 20:26:57 +0100 Subject: [PATCH 2/2] AppFramework annotation whitespace unit test --- .../utility/ControllerMethodReflectorTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/lib/appframework/utility/ControllerMethodReflectorTest.php b/tests/lib/appframework/utility/ControllerMethodReflectorTest.php index c513e23cd6b..a584b5481ba 100644 --- a/tests/lib/appframework/utility/ControllerMethodReflectorTest.php +++ b/tests/lib/appframework/utility/ControllerMethodReflectorTest.php @@ -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() {