@@ 65-83 (lines=19) @@ | ||
62 | /** |
|
63 | * @test |
|
64 | */ |
|
65 | public function it_marks_required_args_without_types_as_not_optional() |
|
66 | { |
|
67 | $class = new \ReflectionClass('Fixtures\Prophecy\WithArguments'); |
|
68 | ||
69 | $mirror = new ClassMirror(); |
|
70 | ||
71 | $classNode = $mirror->reflect($class, array()); |
|
72 | $methodNode = $classNode->getMethod('methodWithoutTypeHints'); |
|
73 | $argNodes = $methodNode->getArguments(); |
|
74 | ||
75 | $this->assertCount(1, $argNodes); |
|
76 | ||
77 | $this->assertEquals('arg', $argNodes[0]->getName()); |
|
78 | $this->assertNull($argNodes[0]->getTypeHint()); |
|
79 | $this->assertFalse($argNodes[0]->isOptional()); |
|
80 | $this->assertNull($argNodes[0]->getDefault()); |
|
81 | $this->assertFalse($argNodes[0]->isPassedByReference()); |
|
82 | $this->assertFalse($argNodes[0]->isVariadic()); |
|
83 | } |
|
84 | ||
85 | /** |
|
86 | * @test |
|
@@ 153-170 (lines=18) @@ | ||
150 | * @test |
|
151 | * @requires PHP 5.6 |
|
152 | */ |
|
153 | public function it_properly_reads_methods_variadic_arguments() |
|
154 | { |
|
155 | $class = new \ReflectionClass('Fixtures\Prophecy\WithVariadicArgument'); |
|
156 | ||
157 | $mirror = new ClassMirror(); |
|
158 | ||
159 | $classNode = $mirror->reflect($class, array()); |
|
160 | $methodNode = $classNode->getMethod('methodWithArgs'); |
|
161 | $argNodes = $methodNode->getArguments(); |
|
162 | ||
163 | $this->assertCount(1, $argNodes); |
|
164 | ||
165 | $this->assertEquals('args', $argNodes[0]->getName()); |
|
166 | $this->assertNull($argNodes[0]->getTypeHint()); |
|
167 | $this->assertFalse($argNodes[0]->isOptional()); |
|
168 | $this->assertFalse($argNodes[0]->isPassedByReference()); |
|
169 | $this->assertTrue($argNodes[0]->isVariadic()); |
|
170 | } |
|
171 | ||
172 | /** |
|
173 | * @test |