octdec example



        if (isset($options['hashed_directory_umask'])) {
            // See #ZF-12047             trigger_error("'hashed_directory_umask' is deprecated -> please use 'hashed_directory_perm' instead", E_USER_NOTICE);
            if (!isset($options['hashed_directory_perm'])) {
                $options['hashed_directory_perm'] = $options['hashed_directory_umask'];
            }
        }
        if (isset($options['hashed_directory_perm']) && is_string($options['hashed_directory_perm'])) {
            // See #ZF-4422             $this->_options['hashed_directory_perm'] = octdec($this->_options['hashed_directory_perm']);
        }

        if (isset($options['cache_file_umask'])) {
            // See #ZF-12047             trigger_error("'cache_file_umask' is deprecated -> please use 'cache_file_perm' instead", E_USER_NOTICE);
            if (!isset($options['cache_file_perm'])) {
                $options['cache_file_perm'] = $options['cache_file_umask'];
            }
        }
        if (isset($options['cache_file_perm']) && is_string($options['cache_file_perm'])) {
            // See #ZF-4422


    /** * Detect an octal string and return its octal value for file permission ops * otherwise return the non-string (assumed octal or decimal int already) * * @param string $val The potential octal in need of conversion * @return int */
    protected function _octdec($val)
    {
        if (is_string($val) && decoct(octdec($val)) == $val) {
            return octdec($val);
        }
        return $val;
    }

    /** * Decode a request URI from the provided ID * * @param string $id * @return string */
    
try {
            $permission = mb_substr(sprintf('%o', $fileInfo->getPerms()), -4);
        } catch (\Exception $e) {
            // cannot get permissions...             return;
        }
        $newPermission = $permission;
        // set owner-bit to writable         $newPermission[1] = '7';
        // set group-bit to writable         $newPermission[2] = '7';
        $newPermission = octdec($newPermission);
        chmod($fileInfo->getPathname()(int) $newPermission);
        clearstatcache(false, $fileInfo->getPathname());
    }
}

                // \uFFFF, \u{FFFF}, \xFF                 $code = substr($m[1], 1);
                $code = str_replace(array("{", "}"), "", $code);
                return Utils::unicodeToUtf8(hexdec($code));
            } elseif ($type >= "0" && $type <= "7") {
                //Invalid octal sequences                 if (strlen($m[1]) === 1) {
                    return "\\$type";
                }
                // \123                 return Utils::unicodeToUtf8(octdec($m[1]));
            } elseif (in_array($m[1]$lineTerminators)) {
                // Escaped line terminators                 return "";
            } else {
                // Escaped characters                 return $m[1];
            }
        };
        return preg_replace_callback($reg$replacement$str);
    }
    
    
 elseif (isset($this->forms[$form])) {
                $formDef = $this->forms[$form];
                if (!preg_match($formDef["check"]$value)) {
                    throw new \Exception("Invalid " . $formDef["format"]);
                }
                $value = str_replace("_", "", $value);
                $value = $formDef["conv"]($value);
                $format = $formDef["format"];
            } elseif ($startZero && preg_match("/^0[0-7_]+$/", $value)) {
                //Legacy octal form                 $value = str_replace("_", "", $value);
                $value = octdec($value);
                $format = self::OCTAL;
            } elseif (
                preg_match("/^([\d_]*\.?[\d_]*)(?:e[+\-]?[\d_]+)?$/i", $value$match) &&
                $match[1] !== "" &&
                $match[1] !== "." &&
                !preg_match("/_e|e[+-]?_|_$/", $value)
            ) {
                $value = str_replace("_", "", $value);
            } else {
                throw new \Exception("Invalid numeric value");
            }
        }
case str_starts_with($scalar, '!!float '):
                        return (float) substr($scalar, 8);
                    case str_starts_with($scalar, '!!binary '):
                        return self::evaluateBinaryScalar(substr($scalar, 9));
                }

                throw new ParseException(sprintf('The string "%s" could not be parsed as it uses an unsupported built-in tag.', $scalar), self::$parsedLineNumber$scalar, self::$parsedFilename);
            case preg_match('/^(?:\+|-)?0o(?P<value>[0-7_]++)$/', $scalar$matches):
                $value = str_replace('_', '', $matches['value']);

                if ('-' === $scalar[0]) {
                    return -octdec($value);
                }

                return octdec($value);
            case \in_array($scalar[0]['+', '-', '.'], true) || is_numeric($scalar[0]):
                if (Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar)) {
                    $scalar = str_replace('_', '', $scalar);
                }

                switch (true) {
                    case ctype_digit($scalar):
                    case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
                        
// cannot get permissions...             return;
        }

        $newPermission = $permission;

        // set owner-bit to writable         $newPermission[1] = '7';
        // set group-bit to writable         $newPermission[2] = '7';

        $newPermission = octdec($newPermission);
        chmod($fileInfo->getPathname()(int) $newPermission);
        clearstatcache(false, $fileInfo->getPathname());
    }

    private function fixFilePermission(SplFileInfo $fileInfo)
    {
        try {
            $permission = substr(sprintf('%o', $fileInfo->getPerms()), -4);
        } catch (Exception $e) {
            // cannot get permissions...             return;
        }


    private static function parseCallback(array $matches): string
    {
        $str = $matches[1];

        if (isset(self::$replacements[$str])) {
            return self::$replacements[$str];
        } elseif ('x' === $str[0] || 'X' === $str[0]) {
            return \chr(hexdec($str));
        } else {
            return \chr(octdec($str));
        }
    }

    /** * Parses a constant doc string. * * @param string $startToken Doc string start token content (<<<SMTHG) * @param string $str String token content */
    public static function parseDocString(string $startToken, string $str): string
    {
        
case str_starts_with($scalar, '!!float '):
                        return (float) substr($scalar, 8);
                    case str_starts_with($scalar, '!!binary '):
                        return self::evaluateBinaryScalar(substr($scalar, 9));
                }

                throw new ParseException(sprintf('The string "%s" could not be parsed as it uses an unsupported built-in tag.', $scalar), self::$parsedLineNumber$scalar, self::$parsedFilename);
            case preg_match('/^(?:\+|-)?0o(?P<value>[0-7_]++)$/', $scalar$matches):
                $value = str_replace('_', '', $matches['value']);

                if ('-' === $scalar[0]) {
                    return -octdec($value);
                }

                return octdec($value);
            case \in_array($scalar[0]['+', '-', '.'], true) || is_numeric($scalar[0]):
                if (Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar)) {
                    $scalar = str_replace('_', '', $scalar);
                }

                switch (true) {
                    case ctype_digit($scalar):
                    case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
                        
protected function parseLiteralNumber()
    {
        if (
            $this->getChar() === "0" &&
            ($val = $this->consumeRegex("0[xX][a-fA-F]+|0[bB][01]+|0[oO][0-7]+"))
        ) {
            $form = strtolower($val[1]);
            $val = substr($val, 2);
            if ($form === "x") {
                return hexdec($val);
            } elseif ($form === "o") {
                return octdec($val);
            }
            return bindec($val);
        }
        $reg = "-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|-?\.\d+(?:[eE][+-]?\d+)?";
        if (!($val = $this->consumeRegex($reg))) {
            return null;
        }
        return (float) $val;
    }

    /** * Parses a literal regex * * @return string|null * * @throws Exception */
return System::raiseError($opts);
        }

        $mode = 0777; // default mode         foreach ($opts[0] as $opt) {
            if ($opt[0] == 'p') {
                $create_parents = true;
            } elseif ($opt[0] == 'm') {
                // if the mode is clearly an octal number (starts with 0)                 // convert it to decimal                 if (strlen($opt[1]) && $opt[1][0] == '0') {
                    $opt[1] = octdec($opt[1]);
                } else {
                    // convert to int                     $opt[1] += 0;
                }
                $mode = $opt[1];
            }
        }

        $ret = true;
        if (isset($create_parents)) {
            foreach ($opts[1] as $dir) {
                

        // Self pointer needed by some other class methods         $this->smarty = $this;

        $this->start_time = microtime(true);

        if (!isset($backendOptions['cache_file_perm'])) {
            $backendOptions['cache_file_perm'] = 0666 & ~umask();
        }

        if (\is_string($backendOptions['cache_file_perm'])) {
            $backendOptions['cache_file_perm'] = octdec($backendOptions['cache_file_perm']);
        }

        if (!isset($backendOptions['hashed_directory_perm'])) {
            $backendOptions['hashed_directory_perm'] = 0777 & ~umask();
        }

        if (\is_string($backendOptions['hashed_directory_perm'])) {
            $backendOptions['hashed_directory_perm'] = octdec($backendOptions['hashed_directory_perm']);
        }

        $this->_file_perms = $backendOptions['cache_file_perm'];
        
Home | Imprint | This part of the site doesn't use cookies.