Lines Matching refs:value

64    * Setting this to true will force YAMLDump to enclose any string value in
237 foreach ($array as $key => $value) {
239 $string .= $this->_yamlize($key,$value,0,$previous_key, $first_key, $array);
247 * Attempts to convert a key / value array item to YAML
251 * @param $value The value of the item
254 private function _yamlize($key,$value,$indent, $previous_key = -1, $first_key = 0, $source_array = null) {
255 if (is_array($value)) {
256 if (empty ($value))
264 $string .= $this->_yamlizeArray($value,$indent);
265 } elseif (!is_array($value)) {
267 $string = $this->_dumpNode($key, $value, $indent, $previous_key, $first_key, $source_array);
283 foreach ($array as $key => $value) {
285 $string .= $this->_yamlize($key, $value, $indent, $previous_key, $first_key, $array);
295 * Returns YAML from a key and a value
299 * @param $value The value of the item
302 private function _dumpNode($key, $value, $indent, $previous_key = -1, $first_key = 0, $source_array = null) {
304 if (is_string ($value) && ((strpos($value,"\n") !== false || strpos($value,": ") !== false || strpos($value,"- ") !== false ||
305 strpos($value,"*") !== false || strpos($value,"#") !== false || strpos($value,"<") !== false || strpos($value,">") !== false || strpos ($value, ' ') !== false ||
306 strpos($value,"[") !== false || strpos($value,"]") !== false || strpos($value,"{") !== false || strpos($value,"}") !== false) || strpos($value,"&") !== false || strpos($value, "'") !== false || strpos($value, "!") === 0 ||
307 substr ($value, -1, 1) == ':')
309 $value = $this->_doLiteralBlock($value,$indent);
311 $value = $this->_doFolding($value,$indent);
314 if ($value === array()) $value = '[ ]';
315 if (in_array ($value, array ('true', 'TRUE', 'false', 'FALSE', 'y', 'Y', 'n', 'N', 'null', 'NULL'), true)) {
316 $value = $this->_doLiteralBlock($value,$indent);
318 if (trim ($value) != $value)
319 $value = $this->_doLiteralBlock($value,$indent);
321 if (is_bool($value)) {
322 $value = ($value) ? "true" : "false";
325 if ($value === null) $value = 'null';
326 if ($value === "'" . self::REMPTY . "'") $value = null;
333 $string = $spaces.'- '.$value."\n";
338 $string = rtrim ($spaces.$key.': '.$value)."\n";
347 * @param $value
348 * @param $indent int The value of the indent
350 private function _doLiteralBlock($value,$indent) {
351 if ($value === "\n") return '\n';
352 if (strpos($value, "\n") === false && strpos($value, "'") === false) {
353 return sprintf ("'%s'", $value);
355 if (strpos($value, "\n") === false && strpos($value, '"') === false) {
356 return sprintf ('"%s"', $value);
358 $exploded = explode("\n",$value);
372 * @param $value The string you wish to fold
374 private function _doFolding($value,$indent) {
377 if ($this->_dumpWordWrap !== 0 && is_string ($value) && strlen($value) > $this->_dumpWordWrap) {
380 $wrapped = wordwrap($value,$this->_dumpWordWrap,"\n$indent");
381 $value = ">\n".$indent.$wrapped;
383 if ($this->setting_dump_force_quotes && is_string ($value) && $value !== self::REMPTY)
384 $value = '"' . $value . '"';
388 return $value;
516 * Finds the type of the passed value, returns the value as the new type.
518 * @param string $value
521 private function _toType($value) {
522 if ($value === '') return null;
523 $first_character = $value[0];
524 $last_character = substr($value, -1, 1);
528 if (!$value) break;
535 return strtr(substr ($value, 1, -1), array ('\\"' => '"', '\'\'' => '\'', '\\\'' => '\''));
537 if (strpos($value, ' #') !== false && !$is_quoted)
538 $value = preg_replace('/\s+#(.+)$/','',$value);
540 if (!$is_quoted) $value = str_replace('\n', "\n", $value);
544 $innerValue = trim(substr ($value, 1, -1));
547 // Propagate value array
548 $value = array();
550 $value[] = $this->_toType($v);
552 return $value;
555 if (strpos($value,': ')!==false && $first_character != '{') {
556 $array = explode(': ',$value);
559 $value = trim(implode(': ',$array));
560 $value = $this->_toType($value);
561 return array($key => $value);
565 $innerValue = trim(substr ($value, 1, -1));
570 // Propagate value array
583 if ($value == 'null' || $value == 'NULL' || $value == 'Null' || $value == '' || $value == '~') {
587 if ( is_numeric($value) && preg_match ('/^(-|)[1-9]+[0-9]*$/', $value) ){
588 $intvalue = (int)$value;
590 $value = $intvalue;
591 return $value;
594 if (in_array($value,
599 if (in_array(strtolower($value),
604 if (is_numeric($value)) {
605 if ($value === '0') return 0;
606 if (rtrim ($value, 0) === $value)
607 $value = (float)$value;
608 return $value;
611 return $value;
663 foreach ($explode as $key => $value) {
664 if (strpos($value,'YAMLSeq') !== false) {
666 $explode[$key] = str_replace(('YAMLSeq'.$seqk.'s'),$seq,$value);
667 $value = $explode[$key];
675 foreach ($explode as $key => $value) {
676 if (strpos($value,'YAMLMap') !== false) {
678 $explode[$key] = str_replace(('YAMLMap'.$mapk.'s'), $map, $value);
679 $value = $explode[$key];
688 foreach ($explode as $key => $value) {
689 while (strpos($value,'YAMLString') !== false) {
690 $explode[$key] = preg_replace('/YAMLString/',$saved_strings[$stringi],$value, 1);
693 $value = $explode[$key];
699 foreach ($explode as $key => $value) {
700 if (strpos($value,'YAMLSeq') !== false) {
703 if (strpos($value,'YAMLMap') !== false) {
706 if (strpos($value,'YAMLString') !== false) {
730 $value = $this->result;
732 $value = $value[$k];
735 return $value;
757 $value = isset($incoming_data[$key]) ? $incoming_data[$key] : null;
762 $this->result[$key] = $value;
764 $this->result[] = $value; end ($this->result); $key = key ($this->result);
780 $value = $this->referenceContentsByAlias($this->_containsGroupAlias);
789 $_arr = array_merge ($_arr, $value);
792 $_arr = array ($key=>$value);
794 $_arr[$key] = $value;
796 if (!is_array ($_arr)) { $_arr = array ($value); $key = 0; }
797 else { $_arr[] = $value; end ($_arr); $key = key ($_arr); }
813 if (is_array ($value)) {
814 $k = key ($value);
933 private static function unquote ($value) {
934 if (!$value) return $value;
935 if (!is_string($value)) return $value;
936 if ($value[0] == '\'') return trim ($value, '\'');
937 if ($value[0] == '"') return trim ($value, '"');
938 return $value;
976 // It's a key/value pair most likely
979 $value = trim(str_replace($matches[1],'',$line));
982 // Do some guesswork as to the key and the value
986 $value = trim(implode(':',$explode));
988 // Set the type of the value. Int, string, etc
989 $value = $this->_toType($value);
991 $array[$key] = $value;
1003 $value = trim(substr($line,1));
1004 $value = $this->_toType($value);
1005 $array[] = $value;