function init($arr) { $len = count($arr); if ($len === 1) { $value = $arr[0]; if (is_int_or_float($value)) { $this->_initFromMiliseconds($value); } else { $this->_initFromString($value); } } else { $this->_initFromParts($arr); } }
/** * Creates the global constructor used in user-land * @return Func */ static function getGlobalConstructor() { $Array = new Func(function ($value = null) { $arr = new Arr(); $len = func_num_args(); if ($len === 1 && is_int_or_float($value)) { $arr->length = (int) $value; } else { if ($len > 0) { $arr->init(func_get_args()); } } return $arr; }); $Array->set('prototype', Arr::$protoObject); $Array->setMethods(Arr::$classMethods, true, false, true); return $Array; }
$opts->level -= 1; $opts->gap = $prevGap; return $result; }; $methods = array('parse' => function ($string, $reviver = null) use(&$decode) { $string = '{"_":' . $string . '}'; $value = json_decode($string); if ($value === null) { throw new Ex(SyntaxError::create('Unexpected end of input')); } return $decode($value->_); }, 'stringify' => function ($value, $replacer = null, $space = null) use(&$encode) { $opts = new stdClass(); $opts->indent = null; $opts->gap = null; if (is_int_or_float($space)) { $space = floor($space); if ($space > 0) { $space = str_repeat(' ', $space); } } if (is_string($space)) { $length = strlen($space); if ($length > 10) { $space = substr($space, 0, 10); } if ($length > 0) { $opts->indent = $space; $opts->gap = ''; } }