|
@@ 50-68 (lines=19) @@
|
| 47 |
|
/** |
| 48 |
|
* @test |
| 49 |
|
*/ |
| 50 |
|
public function it_marks_required_args_without_types_as_not_optional() |
| 51 |
|
{ |
| 52 |
|
$class = new \ReflectionClass('Fixtures\Prophecy\WithArguments'); |
| 53 |
|
|
| 54 |
|
$mirror = new ClassMirror(); |
| 55 |
|
|
| 56 |
|
$classNode = $mirror->reflect($class, array()); |
| 57 |
|
$methodNode = $classNode->getMethod('methodWithoutTypeHints'); |
| 58 |
|
$argNodes = $methodNode->getArguments(); |
| 59 |
|
|
| 60 |
|
$this->assertCount(1, $argNodes); |
| 61 |
|
|
| 62 |
|
$this->assertEquals('arg', $argNodes[0]->getName()); |
| 63 |
|
$this->assertNull($argNodes[0]->getTypeHint()); |
| 64 |
|
$this->assertFalse($argNodes[0]->isOptional()); |
| 65 |
|
$this->assertNull($argNodes[0]->getDefault()); |
| 66 |
|
$this->assertFalse($argNodes[0]->isPassedByReference()); |
| 67 |
|
$this->assertFalse($argNodes[0]->isVariadic()); |
| 68 |
|
} |
| 69 |
|
|
| 70 |
|
/** |
| 71 |
|
* @test |
|
@@ 138-155 (lines=18) @@
|
| 135 |
|
* @test |
| 136 |
|
* @requires PHP 5.6 |
| 137 |
|
*/ |
| 138 |
|
public function it_properly_reads_methods_variadic_arguments() |
| 139 |
|
{ |
| 140 |
|
$class = new \ReflectionClass('Fixtures\Prophecy\WithVariadicArgument'); |
| 141 |
|
|
| 142 |
|
$mirror = new ClassMirror(); |
| 143 |
|
|
| 144 |
|
$classNode = $mirror->reflect($class, array()); |
| 145 |
|
$methodNode = $classNode->getMethod('methodWithArgs'); |
| 146 |
|
$argNodes = $methodNode->getArguments(); |
| 147 |
|
|
| 148 |
|
$this->assertCount(1, $argNodes); |
| 149 |
|
|
| 150 |
|
$this->assertEquals('args', $argNodes[0]->getName()); |
| 151 |
|
$this->assertNull($argNodes[0]->getTypeHint()); |
| 152 |
|
$this->assertFalse($argNodes[0]->isOptional()); |
| 153 |
|
$this->assertFalse($argNodes[0]->isPassedByReference()); |
| 154 |
|
$this->assertTrue($argNodes[0]->isVariadic()); |
| 155 |
|
} |
| 156 |
|
|
| 157 |
|
/** |
| 158 |
|
* @test |