PHP_Shell
[ class tree: PHP_Shell ] [ index: PHP_Shell ] [ all elements ]

Source for file Autoload.php

Documentation is available at Autoload.php

  1. <?php
  2. /**
  3. * Autoload Extension
  4. *
  5. * Note: shell wrapper has to create the __autoload() function when
  6. *       isAutoloadEnabled() is true
  7. *
  8. * handles the options to enable the internal autoload support
  9. *
  10. * :set al
  11. * :set autoload
  12. *
  13. * autoload can't be disabled
  14. */
  15.     
  16. class PHP_Shell_Extensions_Autoload implements PHP_Shell_Extension {
  17.     /**
  18.     * does the use want to use the internal autoload ?
  19.     *
  20.     * @var bool 
  21.     */
  22.     protected $autoload = false;
  23.  
  24.     public function register({
  25.         $opt = PHP_Shell_Options::getInstance();
  26.  
  27.         $opt->registerOption("autoload"$this"optSetAutoload");
  28.         $opt->registerOptionAlias("al""autoload");
  29.     }
  30.  
  31.     /**
  32.     * sets the autoload-flag
  33.     *
  34.     * - the $value is ignored and doesn't have to be set
  35.     * - if __autoload() is defined, the set fails
  36.     */
  37.     public function optSetAutoload($key$value{
  38.         if ($this->autoload{
  39.             print('autload is already enabled');
  40.             return;
  41.         }
  42.  
  43.         if (function_exists('__autoload')) {
  44.             print('can\'t enabled autoload as a external __autoload() function is already defined');
  45.             return;
  46.         }
  47.  
  48.         $this->autoload = true;
  49.     }
  50.  
  51.     /**
  52.     * is the autoload-flag set ?
  53.     *
  54.     * @return bool true if __autoload() should be set by the external wrapper
  55.     */
  56.     public function isAutoloadEnabled({
  57.         return $this->autoload;
  58.     }
  59. }

Documentation generated on Mon, 11 Mar 2019 14:40:32 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.