StaticClass.php 643 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * This file is part of the Nette Framework (https://nette.org)
  4. * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
  5. */
  6. declare(strict_types=1);
  7. namespace Nette;
  8. /**
  9. * Static class.
  10. */
  11. trait StaticClass
  12. {
  13. /**
  14. * @return never
  15. * @throws \Error
  16. */
  17. final public function __construct()
  18. {
  19. throw new \Error('Class ' . static::class . ' is static and cannot be instantiated.');
  20. }
  21. /**
  22. * Call to undefined static method.
  23. * @return void
  24. * @throws MemberAccessException
  25. */
  26. public static function __callStatic(string $name, array $args)
  27. {
  28. Utils\ObjectHelpers::strictStaticCall(static::class, $name);
  29. }
  30. }