mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-24 03:35:01 +01:00
Add failing test in trait.
This commit is contained in:
parent
3650ad07c9
commit
567f8dda6d
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Php72\Tests\Rector\FuncCall\GetClassOnNullRector\Fixture;
|
||||
|
||||
trait SomeTrait
|
||||
{
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
private function someMethodInTrait(?object $objectInTrait)
|
||||
{
|
||||
if (null === $objectInTrait) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return get_class($objectInTrait);
|
||||
}
|
||||
}
|
||||
|
||||
final class SomeClassUsingTheTrait
|
||||
{
|
||||
use SomeTrait;
|
||||
|
||||
public function __invoke()
|
||||
{
|
||||
$object = new \stdClass();
|
||||
$object->id = 42;
|
||||
|
||||
$fromClass = $this->someMethodInClass($object);
|
||||
$fromTrait = $this->someMethodInTrait($object);
|
||||
}
|
||||
|
||||
public function someMethodInClass(?object $objectInClass)
|
||||
{
|
||||
if (null === $objectInClass) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return get_class($objectInClass);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user