PageRenderTime 46ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/system/php/spl/miscellaneous/autoload.php

http://github.com/facebook/hiphop-php
PHP | 27 lines | 19 code | 1 blank | 7 comment | 1 complexity | aa63fd4798d2713276526216993282a8 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?php
  2. /**
  3. * This function is intended to be used as a default implementation for
  4. * __autoload(). If nothing else is specified and spl_autoload_register()
  5. * is called without any parameters then this functions will be used for
  6. * any later call to __autoload().
  7. */
  8. function spl_autoload(string $class, ?string $extensions = null) {
  9. if ($extensions === null) {
  10. $extensions = spl_autoload_extensions();
  11. }
  12. $extensions = explode(',', $extensions);
  13. // Lowercase, convert namespace separators to path separators
  14. $normalized = str_replace(
  15. '\\',
  16. '/',
  17. strtolower($class),
  18. );
  19. foreach ($extensions as $ext) {
  20. $filename = $normalized.$ext;
  21. @include($filename);
  22. if (class_exists($class)) {
  23. return;
  24. }
  25. }
  26. }