SmartObject.undeclaredMethod.hints.phpt 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * Test: Nette\SmartObject undeclared method hints.
  4. */
  5. declare(strict_types=1);
  6. use Tester\Assert;
  7. require __DIR__ . '/../bootstrap.php';
  8. class TestClass
  9. {
  10. use Nette\SmartObject;
  11. private function methodO()
  12. {
  13. }
  14. public function methodO2()
  15. {
  16. }
  17. private static function methodS()
  18. {
  19. }
  20. public static function methodS2()
  21. {
  22. }
  23. }
  24. $obj = new TestClass;
  25. Assert::exception(
  26. fn() => $obj->abc(),
  27. Nette\MemberAccessException::class,
  28. 'Call to undefined method TestClass::abc().',
  29. );
  30. Assert::exception(
  31. fn() => $obj->method(),
  32. Nette\MemberAccessException::class,
  33. 'Call to undefined method TestClass::method(), did you mean methodO2()?',
  34. );
  35. Assert::exception(
  36. fn() => TestClass::abc(),
  37. Nette\MemberAccessException::class,
  38. 'Call to undefined static method TestClass::abc().',
  39. );
  40. Assert::exception(
  41. fn() => TestClass::method(),
  42. Nette\MemberAccessException::class,
  43. 'Call to undefined static method TestClass::method(), did you mean methodS2()?',
  44. );
  45. if (extension_loaded('gd')) {
  46. Assert::exception(
  47. fn() => Nette\Utils\Image::fromBlank(1, 1)->filledElippse(),
  48. Nette\MemberAccessException::class,
  49. 'Call to undefined method Nette\Utils\Image::filledElippse(), did you mean filledEllipse()?',
  50. );
  51. }