Annotation of embedaddon/php/ext/spl/tests/spl_autoload_005.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: SPL: spl_autoload() with methods
! 3: --INI--
! 4: include_path=.
! 5: --FILE--
! 6: <?php
! 7:
! 8: class MyAutoLoader {
! 9:
! 10: function autoLoad($className)
! 11: {
! 12: echo __METHOD__ . "($className)\n";
! 13: }
! 14:
! 15: function autoThrow($className)
! 16: {
! 17: echo __METHOD__ . "($className)\n";
! 18: throw new Exception("Unavailable");
! 19: }
! 20: }
! 21:
! 22: try
! 23: {
! 24: spl_autoload_register(array('MyAutoLoader', 'autoLoad'), true);
! 25: }
! 26: catch(Exception $e)
! 27: {
! 28: echo 'Exception: ' . $e->getMessage() . "\n";
! 29: }
! 30:
! 31: // and
! 32:
! 33: $myAutoLoader = new MyAutoLoader();
! 34:
! 35: spl_autoload_register(array($myAutoLoader, 'autoLoad'));
! 36: spl_autoload_register(array($myAutoLoader, 'autoThrow'));
! 37:
! 38: try
! 39: {
! 40: var_dump(class_exists("TestClass", true));
! 41: }
! 42: catch(Exception $e)
! 43: {
! 44: echo 'Exception: ' . $e->getMessage() . "\n";
! 45: }
! 46:
! 47: ?>
! 48: ===DONE===
! 49: <?php exit(0); ?>
! 50: --EXPECTF--
! 51: Exception: Passed array specifies a non static method but no object (non-static method MyAutoLoader::autoLoad() should not be called statically)
! 52: MyAutoLoader::autoLoad(TestClass)
! 53: MyAutoLoader::autoThrow(TestClass)
! 54: Exception: Unavailable
! 55: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>