示例#1
0
 /**
  * Returns a value for $name
  *
  * @param string $name A name indentifying a value in this stack.
  * @return A value for $name
  */
 public function lazyGet($name)
 {
     if (property_exists($this->_object, $name)) {
         return $this->_object->{$name};
     }
     if ($this->_throwOnMiss) {
         throw new \MUtil_Lazy_LazyException("No lazy stack variable defined for '{$name}' parameter.");
     }
     if (\MUtil_Lazy::$verbose) {
         $class = get_class($this->_object);
         \MUtil_Echo::header("No lazy stack variable defined for '{$name}' parameter using a '{$class}' object.");
     }
     return null;
 }
示例#2
0
 /**
  * Returns a value for $name
  *
  * @param string $name A name indentifying a value in this stack.
  * @return A value for $name
  */
 public function lazyGet($name)
 {
     // \MUtil_Echo::track($name, $this->offsetExists($name), $this->offsetGet($name), $this->getArrayCopy());
     if ($this->offsetExists($name)) {
         return $this->offsetGet($name);
     }
     if ($this->_throwOnMiss) {
         throw new \MUtil_Lazy_LazyException("No lazy stack variable defined for '{$name}' parameter.");
     }
     if (\MUtil_Lazy::$verbose) {
         \MUtil_Echo::header("No lazy stack variable defined for '{$name}' parameter.");
     }
     return null;
 }
示例#3
0
 /**
  * The functions that fixes and returns a value.
  *
  * Be warned: this function may return a lazy value.
  *
  * @param \MUtil_Lazy_StackInterface $stack A \MUtil_Lazy_StackInterface object providing variable data
  * @return mixed
  */
 public function __toValue(\MUtil_Lazy_StackInterface $stack)
 {
     $array = $this->_array;
     $offset = $this->_offset;
     while ($offset instanceof \MUtil_Lazy_LazyInterface) {
         $offset = $offset->__toValue($stack);
     }
     while ($array instanceof \MUtil_Lazy_LazyInterface) {
         $array = $array->__toValue($stack);
     }
     if (\MUtil_Lazy::$verbose) {
         \MUtil_Echo::header('Lazy offset get for offset: <em>' . $offset . '</em>');
         \MUtil_Echo::classToName($array);
     }
     if (null === $offset) {
         if (isset($array[''])) {
             $value = $array[''];
         } else {
             $value = null;
         }
     } elseif (is_array($offset)) {
         // When the offset is itself an array, return an
         // array of values applied to this offset.
         $value = array();
         foreach (\MUtil_Lazy::riseRa($offset, $stack) as $key => $val) {
             if (isset($array[$val])) {
                 $value[$key] = $val;
             }
         }
     } elseif (isset($array[$offset])) {
         $value = $array[$offset];
     } else {
         $value = null;
     }
     while ($value instanceof \MUtil_Lazy_LazyInterface) {
         $value = $value->__toValue($stack);
     }
     if (is_array($value)) {
         $value = \MUtil_Lazy::riseRa($value, $stack);
     }
     return $value;
 }