Missing.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Set Kodoc_Missing::create_class as an autoloading to prevent missing classes
  4. * from crashing the api browser. Classes that are missing a parent will
  5. * extend this class, and get a warning in the API browser.
  6. *
  7. * @package Kohana/Userguide
  8. * @category Undocumented
  9. * @author Kohana Team
  10. * @copyright (c) Kohana Team
  11. * @license https://koseven.ga/LICENSE.md
  12. * @since 3.0.7
  13. */
  14. abstract class Kohana_Kodoc_Missing {
  15. /**
  16. * Creates classes when they are otherwise not found.
  17. *
  18. * Kodoc::create_class('ThisClassDoesNotExist');
  19. *
  20. * [!!] All classes created will extend [Kodoc_Missing].
  21. *
  22. * @param string class name
  23. * @return boolean
  24. * @since 3.0.7
  25. */
  26. public static function create_class($class)
  27. {
  28. if ( ! class_exists($class))
  29. {
  30. // Create a new missing class
  31. if (FALSE === strpos($class, '\\'))
  32. {
  33. eval("class {$class} extends Kodoc_Missing {}");
  34. }
  35. else
  36. {
  37. $namespace = explode('\\', $class);
  38. $class = array_pop($namespace);
  39. eval("namespace ".implode('\\', $namespace)."; class {$class} extends \Kodoc_Missing {}");
  40. }
  41. }
  42. return TRUE;
  43. }
  44. } // End Kohana_Kodoc_Missing