|
@@ 46-60 (lines=15) @@
|
| 43 |
|
/** |
| 44 |
|
* @test |
| 45 |
|
*/ |
| 46 |
|
public function it_reflects_public_static_methods() |
| 47 |
|
{ |
| 48 |
|
$class = new \ReflectionClass('Fixtures\Prophecy\WithStaticMethod'); |
| 49 |
|
|
| 50 |
|
$mirror = new ClassMirror(); |
| 51 |
|
|
| 52 |
|
$classNode = $mirror->reflect($class, array()); |
| 53 |
|
|
| 54 |
|
$this->assertEquals('Fixtures\Prophecy\WithStaticMethod', $classNode->getParentClass()); |
| 55 |
|
|
| 56 |
|
$methodNodes = $classNode->getMethods(); |
| 57 |
|
$this->assertCount(1, $methodNodes); |
| 58 |
|
|
| 59 |
|
$this->assertTrue($methodNodes['innerDetail']->isStatic()); |
| 60 |
|
} |
| 61 |
|
|
| 62 |
|
/** |
| 63 |
|
* @test |
|
@@ 380-391 (lines=12) @@
|
| 377 |
|
/** |
| 378 |
|
* @test |
| 379 |
|
*/ |
| 380 |
|
public function it_doesnt_use_scalar_typehints() |
| 381 |
|
{ |
| 382 |
|
$mirror = new ClassMirror(); |
| 383 |
|
|
| 384 |
|
$classNode = $mirror->reflect(new \ReflectionClass('ReflectionMethod'), array()); |
| 385 |
|
$method = $classNode->getMethod('export'); |
| 386 |
|
$arguments = $method->getArguments(); |
| 387 |
|
|
| 388 |
|
$this->assertNull($arguments[0]->getTypeHint()); |
| 389 |
|
$this->assertNull($arguments[1]->getTypeHint()); |
| 390 |
|
$this->assertNull($arguments[2]->getTypeHint()); |
| 391 |
|
} |
| 392 |
|
|
| 393 |
|
/** |
| 394 |
|
* @test |
|
@@ 410-419 (lines=10) @@
|
| 407 |
|
* @test |
| 408 |
|
* @requires PHP 7.1 |
| 409 |
|
*/ |
| 410 |
|
public function it_doesnt_fail_on_array_nullable_parameter_with_not_null_default_value() |
| 411 |
|
{ |
| 412 |
|
$mirror = new ClassMirror(); |
| 413 |
|
|
| 414 |
|
$classNode = $mirror->reflect(new \ReflectionClass('Fixtures\Prophecy\NullableArrayParameter'), array()); |
| 415 |
|
$method = $classNode->getMethod('iHaveNullableArrayParameterWithNotNullDefaultValue'); |
| 416 |
|
$arguments = $method->getArguments(); |
| 417 |
|
$this->assertSame('array', $arguments[0]->getTypeHint()); |
| 418 |
|
$this->assertTrue($arguments[0]->isNullable()); |
| 419 |
|
} |
| 420 |
|
|
| 421 |
|
/** |
| 422 |
|
* @test |
|
@@ 438-451 (lines=14) @@
|
| 435 |
|
* @test |
| 436 |
|
* @requires PHP 7.2 |
| 437 |
|
*/ |
| 438 |
|
function it_doesnt_fail_when_method_is_extended_with_more_params() |
| 439 |
|
{ |
| 440 |
|
$mirror = new ClassMirror(); |
| 441 |
|
|
| 442 |
|
$classNode = $mirror->reflect( |
| 443 |
|
new \ReflectionClass('Fixtures\Prophecy\MethodWithAdditionalParam'), |
| 444 |
|
array(new \ReflectionClass('Fixtures\Prophecy\Named')) |
| 445 |
|
); |
| 446 |
|
$method = $classNode->getMethod('getName'); |
| 447 |
|
$this->assertCount(1, $method->getArguments()); |
| 448 |
|
|
| 449 |
|
$method = $classNode->getMethod('methodWithoutTypeHints'); |
| 450 |
|
$this->assertCount(2, $method->getArguments()); |
| 451 |
|
} |
| 452 |
|
|
| 453 |
|
/** |
| 454 |
|
* @test |