Advertisement
fruffl

Untitled

Jan 9th, 2012
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.76 KB | None | 0 0
  1. Problem in 5.3.8
  2.  
  3. <?PHP
  4. print ILLI_Constructeur::get_Instance(self::c_CNSTCNFG)->_ENVIRONMENT_MODE; // 'PRODUCTION'
  5. ?>
  6. run:
  7. <?PHP
  8.             if(ILLI_Constructeur::get_Instance(self::c_CNSTCNFG)->_ENVIRONMENT_MODE == 'PRODUCTION')
  9.                 print 'email';
  10.             else
  11.                 print 'exception';
  12. ?>
  13.  
  14. expected: email
  15. actual: email
  16.  
  17.  
  18. bug:
  19. <?PHP
  20.             if(isset(ILLI_Constructeur::get_Instance(self::c_CNSTCNFG)->_ENVIRONMENT_MODE)
  21.             && ILLI_Constructeur::get_Instance(self::c_CNSTCNFG)->_ENVIRONMENT_MODE == 'PRODUCTION')
  22.                 print 'email';
  23.             else
  24.                 print 'exception';
  25. ?>
  26. expected: email
  27. actual: exception
  28.  
  29.  
  30. solution:
  31. <?PHP
  32.             if(ILLI_Constructeur::get_Instance(self::c_CNSTCNFG)->offsetExists('ENVIRONMENT_MODE')
  33.             && ILLI_Constructeur::get_Instance(self::c_CNSTCNFG)->_ENVIRONMENT_MODE == 'PRODUCTION')
  34.                 print 'email';
  35.             else
  36.                 print 'exception';
  37. ?>
  38.  
  39.  
  40. The original-code
  41. <?PHP
  42.  
  43.     ABSTRACT CLASS ILLI_Container_Abstract IMPLEMENTS ILLI_Container_Interface, ILLI_Interface
  44.     {
  45.         /**
  46.          * data-cache
  47.          *
  48.          * @var array
  49.          */
  50.         private $cache
  51.             = array();
  52.  
  53.            
  54.         /**
  55.          * @param $name string var-name
  56.          * @return bool if offset exists in {@link ILLI_Container_Abstract::$cache} or getter-method exists
  57.          */
  58.         public function __isset($name)
  59.         {
  60.             if($name{0} === '_')
  61.                 return $this->offsetExists
  62.                 (
  63.                     substr
  64.                     (
  65.                         $name,
  66.                         1
  67.                     )
  68.                 );
  69.             else
  70.                 return $this->methodExists($name);
  71.         }
  72.  
  73.         /**
  74.          * @param $name string var-name
  75.          * @return  bool array-key exists in {@link ILLI_Container_Abstract::$cache}
  76.          */
  77.         public function offsetExists($name)
  78.         {
  79.             $name =
  80.                 str_replace
  81.                 (
  82.                     '-',
  83.                     '_',
  84.                     $name
  85.                 );
  86.                
  87.             return array_key_exists
  88.             (
  89.                 $name,
  90.                 $this->cache
  91.             );
  92.         }
  93.  
  94. ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement