From 23c754aed3bfa5c795a03e63183158d028a6a408 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 2 Jul 2015 11:54:17 +0200 Subject: prefer scalar type hints over phpdoc annotation use method exists lookup to be safe and not break on old hhvm versions add test that checks if type hint is preferred over annotation --- .../utility/ControllerMethodReflectorTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests') diff --git a/tests/lib/appframework/utility/ControllerMethodReflectorTest.php b/tests/lib/appframework/utility/ControllerMethodReflectorTest.php index a584b5481ba..38bd537e073 100644 --- a/tests/lib/appframework/utility/ControllerMethodReflectorTest.php +++ b/tests/lib/appframework/utility/ControllerMethodReflectorTest.php @@ -104,6 +104,25 @@ class ControllerMethodReflectorTest extends \Test\TestCase { $this->assertEquals('int', $reader->getType('test')); } + /** + * @Annotation + * @param int $a + * @param int $b + * @requires PHP 7 + */ + public function testReadTypeIntAnnotationsScalarTypes($a, float $b, int $c, $d){ + $reader = new ControllerMethodReflector(); + $reader->reflect( + '\OC\AppFramework\Utility\ControllerMethodReflectorTest', + 'testReadTypeIntAnnotationsScalarTypes' + ); + + $this->assertEquals('int', $reader->getType('a')); + $this->assertEquals('float', $reader->getType('b')); + $this->assertEquals('int', $reader->getType('c')); + $this->assertNull($reader->getType('d')); + } + /** * @Annotation -- cgit v1.2.3