Chris@13: value = $value; Chris@0: } Chris@0: Chris@13: public function getSubNodeNames() : array { Chris@13: return ['value']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * @internal Chris@0: * Chris@0: * Parses a DNUMBER token like PHP would. Chris@0: * Chris@0: * @param string $str A string number Chris@0: * Chris@0: * @return float The parsed number Chris@0: */ Chris@13: public static function parse(string $str) : float { Chris@0: // if string contains any of .eE just cast it to float Chris@0: if (false !== strpbrk($str, '.eE')) { Chris@0: return (float) $str; Chris@0: } Chris@0: Chris@0: // otherwise it's an integer notation that overflowed into a float Chris@0: // if it starts with 0 it's one of the special integer notations Chris@0: if ('0' === $str[0]) { Chris@0: // hex Chris@0: if ('x' === $str[1] || 'X' === $str[1]) { Chris@0: return hexdec($str); Chris@0: } Chris@0: Chris@0: // bin Chris@0: if ('b' === $str[1] || 'B' === $str[1]) { Chris@0: return bindec($str); Chris@0: } Chris@0: Chris@0: // oct Chris@0: // substr($str, 0, strcspn($str, '89')) cuts the string at the first invalid digit (8 or 9) Chris@0: // so that only the digits before that are used Chris@0: return octdec(substr($str, 0, strcspn($str, '89'))); Chris@0: } Chris@0: Chris@0: // dec Chris@0: return (float) $str; Chris@0: } Chris@13: Chris@13: public function getType() : string { Chris@13: return 'Scalar_DNumber'; Chris@13: } Chris@0: }