Reflection.toString.phpt 815 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * Test: Nette\Utils\Reflection::toString()
  4. */
  5. declare(strict_types=1);
  6. use Nette\Utils\Reflection;
  7. use Tester\Assert;
  8. require __DIR__ . '/../bootstrap.php';
  9. class Foo
  10. {
  11. public $var;
  12. public function method($param)
  13. {
  14. }
  15. }
  16. function func($param)
  17. {
  18. }
  19. Assert::same('Foo', Reflection::toString(new ReflectionClass('Foo')));
  20. Assert::same('Foo::method()', Reflection::toString(new ReflectionMethod('Foo', 'method')));
  21. Assert::same('$param in Foo::method()', Reflection::toString(new ReflectionParameter(['Foo', 'method'], 'param')));
  22. Assert::same('Foo::$var', Reflection::toString(new ReflectionProperty('Foo', 'var')));
  23. Assert::same('func()', Reflection::toString(new ReflectionFunction('func')));
  24. Assert::same('$param in func()', Reflection::toString(new ReflectionParameter('func', 'param')));