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