One Hat Cyber Team
Your IP:
216.73.216.102
Server IP:
198.54.114.155
Server:
Linux server71.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
Server Software:
LiteSpeed
PHP Version:
5.6.40
Create File
|
Create Folder
Execute
Dir :
~
/
home
/
fluxyjvi
/
www
/
assets
/
images
/
View File Name :
Formatter.tar
BitcoinMoneyFormatter.php 0000644 00000004450 15107306300 0011536 0 ustar 00 <?php declare(strict_types=1); namespace Money\Formatter; use Money\Currencies; use Money\Currencies\BitcoinCurrencies; use Money\Exception\FormatterException; use Money\Money; use Money\MoneyFormatter; use Money\Number; use function str_pad; use function strlen; use function strpos; use function substr; /** * Formats Money to Bitcoin currency. */ final class BitcoinMoneyFormatter implements MoneyFormatter { private int $fractionDigits; private Currencies $currencies; public function __construct(int $fractionDigits, Currencies $currencies) { $this->fractionDigits = $fractionDigits; $this->currencies = $currencies; } public function format(Money $money): string { if ($money->getCurrency()->getCode() !== BitcoinCurrencies::CODE) { throw new FormatterException('Bitcoin Formatter can only format Bitcoin currency'); } $valueBase = $money->getAmount(); $negative = false; if ($valueBase[0] === '-') { $negative = true; $valueBase = substr($valueBase, 1); } $subunit = $this->currencies->subunitFor($money->getCurrency()); $valueBase = Number::roundMoneyValue($valueBase, $this->fractionDigits, $subunit); $valueLength = strlen($valueBase); if ($valueLength > $subunit) { $formatted = substr($valueBase, 0, $valueLength - $subunit); if ($subunit) { $formatted .= '.'; $formatted .= substr($valueBase, $valueLength - $subunit); } } else { $formatted = '0.' . str_pad('', $subunit - $valueLength, '0') . $valueBase; } if ($this->fractionDigits === 0) { $formatted = substr($formatted, 0, (int) strpos($formatted, '.')); } elseif ($this->fractionDigits > $subunit) { $formatted .= str_pad('', $this->fractionDigits - $subunit, '0'); } elseif ($this->fractionDigits < $subunit) { $lastDigit = (int) strpos($formatted, '.') + $this->fractionDigits + 1; $formatted = substr($formatted, 0, $lastDigit); } $formatted = BitcoinCurrencies::SYMBOL . $formatted; if ($negative) { $formatted = '-' . $formatted; } return $formatted; } } DecimalMoneyFormatter.php 0000644 00000002715 15107306301 0011510 0 ustar 00 <?php declare(strict_types=1); namespace Money\Formatter; use Money\Currencies; use Money\Money; use Money\MoneyFormatter; use function assert; use function str_pad; use function strlen; use function substr; /** * Formats a Money object as a decimal string. */ final class DecimalMoneyFormatter implements MoneyFormatter { private Currencies $currencies; public function __construct(Currencies $currencies) { $this->currencies = $currencies; } /** @psalm-return numeric-string */ public function format(Money $money): string { $valueBase = $money->getAmount(); $negative = $valueBase[0] === '-'; if ($negative) { $valueBase = substr($valueBase, 1); } $subunit = $this->currencies->subunitFor($money->getCurrency()); $valueLength = strlen($valueBase); if ($valueLength > $subunit) { $formatted = substr($valueBase, 0, $valueLength - $subunit); $decimalDigits = substr($valueBase, $valueLength - $subunit); if (strlen($decimalDigits) > 0) { $formatted .= '.' . $decimalDigits; } } else { $formatted = '0.' . str_pad('', $subunit - $valueLength, '0') . $valueBase; } if ($negative) { $formatted = '-' . $formatted; } assert($formatted !== ''); /** @psalm-var numeric-string $formatted */ return $formatted; } } AggregateMoneyFormatter.php 0000644 00000002312 15107306301 0012031 0 ustar 00 <?php declare(strict_types=1); namespace Money\Formatter; use Money\Exception\FormatterException; use Money\Money; use Money\MoneyFormatter; /** * Formats a Money object using other Money formatters. */ final class AggregateMoneyFormatter implements MoneyFormatter { /** * @var MoneyFormatter[] indexed by currency code * @psalm-var non-empty-array<non-empty-string, MoneyFormatter> indexed by currency code */ private array $formatters; /** * @param MoneyFormatter[] $formatters indexed by currency code * @psalm-param non-empty-array<non-empty-string, MoneyFormatter> $formatters indexed by currency code */ public function __construct(array $formatters) { $this->formatters = $formatters; } public function format(Money $money): string { $currencyCode = $money->getCurrency()->getCode(); if (isset($this->formatters[$currencyCode])) { return $this->formatters[$currencyCode]->format($money); } if (isset($this->formatters['*'])) { return $this->formatters['*']->format($money); } throw new FormatterException('No formatter found for currency ' . $currencyCode); } } IntlLocalizedDecimalFormatter.php 0000644 00000003161 15107306301 0013152 0 ustar 00 <?php declare(strict_types=1); namespace Money\Formatter; use Money\Currencies; use Money\Money; use Money\MoneyFormatter; use NumberFormatter; use function assert; use function is_string; use function str_pad; use function strlen; use function substr; /** * Formats a Money object using intl extension. */ final class IntlLocalizedDecimalFormatter implements MoneyFormatter { private NumberFormatter $formatter; private Currencies $currencies; public function __construct(NumberFormatter $formatter, Currencies $currencies) { $this->formatter = $formatter; $this->currencies = $currencies; } public function format(Money $money): string { $valueBase = $money->getAmount(); $negative = $valueBase[0] === '-'; if ($negative) { $valueBase = substr($valueBase, 1); } $subunit = $this->currencies->subunitFor($money->getCurrency()); $valueLength = strlen($valueBase); if ($valueLength > $subunit) { $formatted = substr($valueBase, 0, $valueLength - $subunit); $decimalDigits = substr($valueBase, $valueLength - $subunit); if (strlen($decimalDigits) > 0) { $formatted .= '.' . $decimalDigits; } } else { $formatted = '0.' . str_pad('', $subunit - $valueLength, '0') . $valueBase; } if ($negative) { $formatted = '-' . $formatted; } $formatted = $this->formatter->format((float) $formatted); assert(is_string($formatted) && $formatted !== ''); return $formatted; } } IntlMoneyFormatter.php 0000644 00000003137 15107306302 0011060 0 ustar 00 <?php declare(strict_types=1); namespace Money\Formatter; use Money\Currencies; use Money\Money; use Money\MoneyFormatter; use NumberFormatter; use function assert; use function str_pad; use function strlen; use function substr; /** * Formats a Money object using intl extension. */ final class IntlMoneyFormatter implements MoneyFormatter { private NumberFormatter $formatter; private Currencies $currencies; public function __construct(NumberFormatter $formatter, Currencies $currencies) { $this->formatter = $formatter; $this->currencies = $currencies; } public function format(Money $money): string { $valueBase = $money->getAmount(); $negative = $valueBase[0] === '-'; if ($negative) { $valueBase = substr($valueBase, 1); } $subunit = $this->currencies->subunitFor($money->getCurrency()); $valueLength = strlen($valueBase); if ($valueLength > $subunit) { $formatted = substr($valueBase, 0, $valueLength - $subunit); $decimalDigits = substr($valueBase, $valueLength - $subunit); if (strlen($decimalDigits) > 0) { $formatted .= '.' . $decimalDigits; } } else { $formatted = '0.' . str_pad('', $subunit - $valueLength, '0') . $valueBase; } if ($negative) { $formatted = '-' . $formatted; } $formatted = $this->formatter->formatCurrency((float) $formatted, $money->getCurrency()->getCode()); assert($formatted !== ''); return $formatted; } } TraceFormatter.php 0000644 00000006431 15107345071 0010206 0 ustar 00 <?php /* * This file is part of Psy Shell. * * (c) 2012-2023 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Psy\Formatter; use Psy\Input\FilterOptions; use Symfony\Component\Console\Formatter\OutputFormatter; /** * Output formatter for exception traces. */ class TraceFormatter { /** * Format the trace of the given exception. * * @param \Throwable $throwable The error or exception with a backtrace * @param FilterOptions $filter (default: null) * @param int $count (default: PHP_INT_MAX) * @param bool $includePsy (default: true) * * @return string[] Formatted stacktrace lines */ public static function formatTrace(\Throwable $throwable, FilterOptions $filter = null, int $count = null, bool $includePsy = true): array { if ($cwd = \getcwd()) { $cwd = \rtrim($cwd, \DIRECTORY_SEPARATOR).\DIRECTORY_SEPARATOR; } if ($count === null) { $count = \PHP_INT_MAX; } $lines = []; $trace = $throwable->getTrace(); \array_unshift($trace, [ 'function' => '', 'file' => $throwable->getFile() !== null ? $throwable->getFile() : 'n/a', 'line' => $throwable->getLine() !== null ? $throwable->getLine() : 'n/a', 'args' => [], ]); if (!$includePsy) { for ($i = \count($trace) - 1; $i >= 0; $i--) { $thing = isset($trace[$i]['class']) ? $trace[$i]['class'] : $trace[$i]['function']; if (\preg_match('/\\\\?Psy\\\\/', $thing)) { $trace = \array_slice($trace, $i + 1); break; } } } for ($i = 0, $count = \min($count, \count($trace)); $i < $count; $i++) { $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : ''; $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : ''; $function = $trace[$i]['function']; $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a'; $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a'; // Make file paths relative to cwd if ($cwd !== false) { $file = \preg_replace('/^'.\preg_quote($cwd, '/').'/', '', $file); } // Leave execution loop out of the `eval()'d code` lines if (\preg_match("#/src/Execution(?:Loop)?Closure.php\(\d+\) : eval\(\)'d code$#", \str_replace('\\', '/', $file))) { $file = "eval()'d code"; } // Skip any lines that don't match our filter options if ($filter !== null && !$filter->match(\sprintf('%s%s%s() at %s:%s', $class, $type, $function, $file, $line))) { continue; } $lines[] = \sprintf( ' <class>%s</class>%s%s() at <info>%s:%s</info>', OutputFormatter::escape($class), OutputFormatter::escape($type), OutputFormatter::escape($function), OutputFormatter::escape($file), OutputFormatter::escape($line) ); } return $lines; } } DocblockFormatter.php 0000644 00000011060 15107345071 0010662 0 ustar 00 <?php /* * This file is part of Psy Shell. * * (c) 2012-2023 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Psy\Formatter; use Psy\Util\Docblock; use Symfony\Component\Console\Formatter\OutputFormatter; /** * A pretty-printer for docblocks. */ class DocblockFormatter implements ReflectorFormatter { private static $vectorParamTemplates = [ 'type' => 'info', 'var' => 'strong', ]; /** * Format a docblock. * * @param \Reflector $reflector * * @return string Formatted docblock */ public static function format(\Reflector $reflector): string { $docblock = new Docblock($reflector); $chunks = []; if (!empty($docblock->desc)) { $chunks[] = '<comment>Description:</comment>'; $chunks[] = self::indent(OutputFormatter::escape($docblock->desc), ' '); $chunks[] = ''; } if (!empty($docblock->tags)) { foreach ($docblock::$vectors as $name => $vector) { if (isset($docblock->tags[$name])) { $chunks[] = \sprintf('<comment>%s:</comment>', self::inflect($name)); $chunks[] = self::formatVector($vector, $docblock->tags[$name]); $chunks[] = ''; } } $tags = self::formatTags(\array_keys($docblock::$vectors), $docblock->tags); if (!empty($tags)) { $chunks[] = $tags; $chunks[] = ''; } } return \rtrim(\implode("\n", $chunks)); } /** * Format a docblock vector, for example, `@throws`, `@param`, or `@return`. * * @see DocBlock::$vectors * * @param array $vector * @param array $lines */ private static function formatVector(array $vector, array $lines): string { $template = [' ']; foreach ($vector as $type) { $max = 0; foreach ($lines as $line) { $chunk = $line[$type]; $cur = empty($chunk) ? 0 : \strlen($chunk) + 1; if ($cur > $max) { $max = $cur; } } $template[] = self::getVectorParamTemplate($type, $max); } $template = \implode(' ', $template); return \implode("\n", \array_map(function ($line) use ($template) { $escaped = \array_map(function ($l) { if ($l === null) { return ''; } return OutputFormatter::escape($l); }, $line); return \rtrim(\vsprintf($template, $escaped)); }, $lines)); } /** * Format docblock tags. * * @param array $skip Tags to exclude * @param array $tags Tags to format * * @return string formatted tags */ private static function formatTags(array $skip, array $tags): string { $chunks = []; foreach ($tags as $name => $values) { if (\in_array($name, $skip)) { continue; } foreach ($values as $value) { $chunks[] = \sprintf('<comment>%s%s</comment> %s', self::inflect($name), empty($value) ? '' : ':', OutputFormatter::escape($value)); } $chunks[] = ''; } return \implode("\n", $chunks); } /** * Get a docblock vector template. * * @param string $type Vector type * @param int $max Pad width */ private static function getVectorParamTemplate(string $type, int $max): string { if (!isset(self::$vectorParamTemplates[$type])) { return \sprintf('%%-%ds', $max); } return \sprintf('<%s>%%-%ds</%s>', self::$vectorParamTemplates[$type], $max, self::$vectorParamTemplates[$type]); } /** * Indent a string. * * @param string $text String to indent * @param string $indent (default: ' ') */ private static function indent(string $text, string $indent = ' '): string { return $indent.\str_replace("\n", "\n".$indent, $text); } /** * Convert underscored or whitespace separated words into sentence case. * * @param string $text */ private static function inflect(string $text): string { $words = \trim(\preg_replace('/[\s_-]+/', ' ', \preg_replace('/([a-z])([A-Z])/', '$1 $2', $text))); return \implode(' ', \array_map('ucfirst', \explode(' ', $words))); } } ReflectorFormatter.php 0000644 00000000662 15107345071 0011075 0 ustar 00 <?php /* * This file is part of Psy Shell. * * (c) 2012-2023 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Psy\Formatter; /** * Reflector formatter interface. */ interface ReflectorFormatter { /** * @param \Reflector $reflector */ public static function format(\Reflector $reflector): string; } CodeFormatter.php 0000644 00000023537 15107345071 0010030 0 ustar 00 <?php /* * This file is part of Psy Shell. * * (c) 2012-2023 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Psy\Formatter; use Psy\Exception\RuntimeException; use Symfony\Component\Console\Formatter\OutputFormatter; /** * A pretty-printer for code. */ class CodeFormatter implements ReflectorFormatter { const LINE_MARKER = ' <urgent>></urgent> '; const NO_LINE_MARKER = ' '; const HIGHLIGHT_DEFAULT = 'default'; const HIGHLIGHT_KEYWORD = 'keyword'; const HIGHLIGHT_PUBLIC = 'public'; const HIGHLIGHT_PROTECTED = 'protected'; const HIGHLIGHT_PRIVATE = 'private'; const HIGHLIGHT_CONST = 'const'; const HIGHLIGHT_NUMBER = 'number'; const HIGHLIGHT_STRING = 'string'; const HIGHLIGHT_COMMENT = 'code_comment'; const HIGHLIGHT_INLINE_HTML = 'inline_html'; private static $tokenMap = [ // Not highlighted \T_OPEN_TAG => self::HIGHLIGHT_DEFAULT, \T_OPEN_TAG_WITH_ECHO => self::HIGHLIGHT_DEFAULT, \T_CLOSE_TAG => self::HIGHLIGHT_DEFAULT, \T_STRING => self::HIGHLIGHT_DEFAULT, \T_VARIABLE => self::HIGHLIGHT_DEFAULT, \T_NS_SEPARATOR => self::HIGHLIGHT_DEFAULT, // Visibility \T_PUBLIC => self::HIGHLIGHT_PUBLIC, \T_PROTECTED => self::HIGHLIGHT_PROTECTED, \T_PRIVATE => self::HIGHLIGHT_PRIVATE, // Constants \T_DIR => self::HIGHLIGHT_CONST, \T_FILE => self::HIGHLIGHT_CONST, \T_METHOD_C => self::HIGHLIGHT_CONST, \T_NS_C => self::HIGHLIGHT_CONST, \T_LINE => self::HIGHLIGHT_CONST, \T_CLASS_C => self::HIGHLIGHT_CONST, \T_FUNC_C => self::HIGHLIGHT_CONST, \T_TRAIT_C => self::HIGHLIGHT_CONST, // Types \T_DNUMBER => self::HIGHLIGHT_NUMBER, \T_LNUMBER => self::HIGHLIGHT_NUMBER, \T_ENCAPSED_AND_WHITESPACE => self::HIGHLIGHT_STRING, \T_CONSTANT_ENCAPSED_STRING => self::HIGHLIGHT_STRING, // Comments \T_COMMENT => self::HIGHLIGHT_COMMENT, \T_DOC_COMMENT => self::HIGHLIGHT_COMMENT, // @todo something better here? \T_INLINE_HTML => self::HIGHLIGHT_INLINE_HTML, ]; /** * Format the code represented by $reflector for shell output. * * @param \Reflector $reflector * @param string|null $colorMode (deprecated and ignored) * * @return string formatted code */ public static function format(\Reflector $reflector, string $colorMode = null): string { if (self::isReflectable($reflector)) { if ($code = @\file_get_contents($reflector->getFileName())) { return self::formatCode($code, self::getStartLine($reflector), $reflector->getEndLine()); } } throw new RuntimeException('Source code unavailable'); } /** * Format code for shell output. * * Optionally, restrict by $startLine and $endLine line numbers, or pass $markLine to add a line marker. * * @param string $code * @param int $startLine * @param int|null $endLine * @param int|null $markLine * * @return string formatted code */ public static function formatCode(string $code, int $startLine = 1, int $endLine = null, int $markLine = null): string { $spans = self::tokenizeSpans($code); $lines = self::splitLines($spans, $startLine, $endLine); $lines = self::formatLines($lines); $lines = self::numberLines($lines, $markLine); return \implode('', \iterator_to_array($lines)); } /** * Get the start line for a given Reflector. * * Tries to incorporate doc comments if possible. * * This is typehinted as \Reflector but we've narrowed the input via self::isReflectable already. * * @param \ReflectionClass|\ReflectionFunctionAbstract $reflector */ private static function getStartLine(\Reflector $reflector): int { $startLine = $reflector->getStartLine(); if ($docComment = $reflector->getDocComment()) { $startLine -= \preg_match_all('/(\r\n?|\n)/', $docComment) + 1; } return \max($startLine, 1); } /** * Split code into highlight spans. * * Tokenize via \token_get_all, then map these tokens to internal highlight types, combining * adjacent spans of the same highlight type. * * @todo consider switching \token_get_all() out for PHP-Parser-based formatting at some point. * * @param string $code * * @return \Generator [$spanType, $spanText] highlight spans */ private static function tokenizeSpans(string $code): \Generator { $spanType = null; $buffer = ''; foreach (\token_get_all($code) as $token) { $nextType = self::nextHighlightType($token, $spanType); $spanType = $spanType ?: $nextType; if ($spanType !== $nextType) { yield [$spanType, $buffer]; $spanType = $nextType; $buffer = ''; } $buffer .= \is_array($token) ? $token[1] : $token; } if ($spanType !== null && $buffer !== '') { yield [$spanType, $buffer]; } } /** * Given a token and the current highlight span type, compute the next type. * * @param array|string $token \token_get_all token * @param string|null $currentType * * @return string|null */ private static function nextHighlightType($token, $currentType) { if ($token === '"') { return self::HIGHLIGHT_STRING; } if (\is_array($token)) { if ($token[0] === \T_WHITESPACE) { return $currentType; } if (\array_key_exists($token[0], self::$tokenMap)) { return self::$tokenMap[$token[0]]; } } return self::HIGHLIGHT_KEYWORD; } /** * Group highlight spans into an array of lines. * * Optionally, restrict by start and end line numbers. * * @param \Generator $spans as [$spanType, $spanText] pairs * @param int $startLine * @param int|null $endLine * * @return \Generator lines, each an array of [$spanType, $spanText] pairs */ private static function splitLines(\Generator $spans, int $startLine = 1, int $endLine = null): \Generator { $lineNum = 1; $buffer = []; foreach ($spans as list($spanType, $spanText)) { foreach (\preg_split('/(\r\n?|\n)/', $spanText) as $index => $spanLine) { if ($index > 0) { if ($lineNum >= $startLine) { yield $lineNum => $buffer; } $lineNum++; $buffer = []; if ($endLine !== null && $lineNum > $endLine) { return; } } if ($spanLine !== '') { $buffer[] = [$spanType, $spanLine]; } } } if (!empty($buffer)) { yield $lineNum => $buffer; } } /** * Format lines of highlight spans for shell output. * * @param \Generator $spanLines lines, each an array of [$spanType, $spanText] pairs * * @return \Generator Formatted lines */ private static function formatLines(\Generator $spanLines): \Generator { foreach ($spanLines as $lineNum => $spanLine) { $line = ''; foreach ($spanLine as list($spanType, $spanText)) { if ($spanType === self::HIGHLIGHT_DEFAULT) { $line .= OutputFormatter::escape($spanText); } else { $line .= \sprintf('<%s>%s</%s>', $spanType, OutputFormatter::escape($spanText), $spanType); } } yield $lineNum => $line.\PHP_EOL; } } /** * Prepend line numbers to formatted lines. * * Lines must be in an associative array with the correct keys in order to be numbered properly. * * Optionally, pass $markLine to add a line marker. * * @param \Generator $lines Formatted lines * @param int|null $markLine * * @return \Generator Numbered, formatted lines */ private static function numberLines(\Generator $lines, int $markLine = null): \Generator { $lines = \iterator_to_array($lines); // Figure out how much space to reserve for line numbers. \end($lines); $pad = \strlen(\key($lines)); // If $markLine is before or after our line range, don't bother reserving space for the marker. if ($markLine !== null) { if ($markLine > \key($lines)) { $markLine = null; } \reset($lines); if ($markLine < \key($lines)) { $markLine = null; } } foreach ($lines as $lineNum => $line) { $mark = ''; if ($markLine !== null) { $mark = ($markLine === $lineNum) ? self::LINE_MARKER : self::NO_LINE_MARKER; } yield \sprintf("%s<aside>%{$pad}s</aside>: %s", $mark, $lineNum, $line); } } /** * Check whether a Reflector instance is reflectable by this formatter. * * @phpstan-assert-if-true \ReflectionClass|\ReflectionFunctionAbstract $reflector * * @param \Reflector $reflector */ private static function isReflectable(\Reflector $reflector): bool { return ($reflector instanceof \ReflectionClass || $reflector instanceof \ReflectionFunctionAbstract) && \is_file($reflector->getFileName()); } } Formatter.php 0000644 00000000646 15107345071 0007231 0 ustar 00 <?php /* * This file is part of Psy Shell. * * (c) 2012-2023 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Psy\Formatter; /** * Formatter interface. * * @deprecated this interface only exists for backwards compatibility. Use ReflectorFormatter. */ interface Formatter extends ReflectorFormatter { } SignatureFormatter.php 0000644 00000025407 15107345071 0011115 0 ustar 00 <?php /* * This file is part of Psy Shell. * * (c) 2012-2023 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Psy\Formatter; use Psy\Reflection\ReflectionClassConstant; use Psy\Reflection\ReflectionConstant_; use Psy\Reflection\ReflectionLanguageConstruct; use Psy\Util\Json; use Symfony\Component\Console\Formatter\OutputFormatter; /** * An abstract representation of a function, class or property signature. */ class SignatureFormatter implements ReflectorFormatter { /** * Format a signature for the given reflector. * * Defers to subclasses to do the actual formatting. * * @param \Reflector $reflector * * @return string Formatted signature */ public static function format(\Reflector $reflector): string { switch (true) { case $reflector instanceof \ReflectionFunction: case $reflector instanceof ReflectionLanguageConstruct: return self::formatFunction($reflector); case $reflector instanceof \ReflectionClass: // this case also covers \ReflectionObject return self::formatClass($reflector); case $reflector instanceof ReflectionClassConstant: case $reflector instanceof \ReflectionClassConstant: return self::formatClassConstant($reflector); case $reflector instanceof \ReflectionMethod: return self::formatMethod($reflector); case $reflector instanceof \ReflectionProperty: return self::formatProperty($reflector); case $reflector instanceof ReflectionConstant_: return self::formatConstant($reflector); default: throw new \InvalidArgumentException('Unexpected Reflector class: '.\get_class($reflector)); } } /** * Print the signature name. * * @param \ReflectionClass|ReflectionClassConstant|\ReflectionClassConstant|\ReflectionFunctionAbstract $reflector * * @return string Formatted name */ public static function formatName(\Reflector $reflector): string { return $reflector->getName(); } /** * Print the method, property or class modifiers. * * @param \ReflectionMethod|\ReflectionProperty|\ReflectionClass $reflector * * @return string Formatted modifiers */ private static function formatModifiers(\Reflector $reflector): string { return \implode(' ', \array_map(function ($modifier) { return \sprintf('<keyword>%s</keyword>', $modifier); }, \Reflection::getModifierNames($reflector->getModifiers()))); } /** * Format a class signature. * * @param \ReflectionClass $reflector * * @return string Formatted signature */ private static function formatClass(\ReflectionClass $reflector): string { $chunks = []; if ($modifiers = self::formatModifiers($reflector)) { $chunks[] = $modifiers; } if ($reflector->isTrait()) { $chunks[] = 'trait'; } else { $chunks[] = $reflector->isInterface() ? 'interface' : 'class'; } $chunks[] = \sprintf('<class>%s</class>', self::formatName($reflector)); if ($parent = $reflector->getParentClass()) { $chunks[] = 'extends'; $chunks[] = \sprintf('<class>%s</class>', $parent->getName()); } $interfaces = $reflector->getInterfaceNames(); if (!empty($interfaces)) { \sort($interfaces); $chunks[] = $reflector->isInterface() ? 'extends' : 'implements'; $chunks[] = \implode(', ', \array_map(function ($name) { return \sprintf('<class>%s</class>', $name); }, $interfaces)); } return \implode(' ', $chunks); } /** * Format a constant signature. * * @param ReflectionClassConstant|\ReflectionClassConstant $reflector * * @return string Formatted signature */ private static function formatClassConstant($reflector): string { $value = $reflector->getValue(); $style = self::getTypeStyle($value); return \sprintf( '<keyword>const</keyword> <const>%s</const> = <%s>%s</%s>', self::formatName($reflector), $style, OutputFormatter::escape(Json::encode($value)), $style ); } /** * Format a constant signature. * * @param ReflectionConstant_ $reflector * * @return string Formatted signature */ private static function formatConstant(ReflectionConstant_ $reflector): string { $value = $reflector->getValue(); $style = self::getTypeStyle($value); return \sprintf( '<keyword>define</keyword>(<string>%s</string>, <%s>%s</%s>)', OutputFormatter::escape(Json::encode($reflector->getName())), $style, OutputFormatter::escape(Json::encode($value)), $style ); } /** * Helper for getting output style for a given value's type. * * @param mixed $value */ private static function getTypeStyle($value): string { if (\is_int($value) || \is_float($value)) { return 'number'; } elseif (\is_string($value)) { return 'string'; } elseif (\is_bool($value) || $value === null) { return 'bool'; } else { return 'strong'; // @codeCoverageIgnore } } /** * Format a property signature. * * @param \ReflectionProperty $reflector * * @return string Formatted signature */ private static function formatProperty(\ReflectionProperty $reflector): string { return \sprintf( '%s <strong>$%s</strong>', self::formatModifiers($reflector), $reflector->getName() ); } /** * Format a function signature. * * @param \ReflectionFunction $reflector * * @return string Formatted signature */ private static function formatFunction(\ReflectionFunctionAbstract $reflector): string { return \sprintf( '<keyword>function</keyword> %s<function>%s</function>(%s)%s', $reflector->returnsReference() ? '&' : '', self::formatName($reflector), \implode(', ', self::formatFunctionParams($reflector)), self::formatFunctionReturnType($reflector) ); } /** * Format a function signature's return type (if available). * * @param \ReflectionFunctionAbstract $reflector * * @return string Formatted return type */ private static function formatFunctionReturnType(\ReflectionFunctionAbstract $reflector): string { if (!\method_exists($reflector, 'hasReturnType') || !$reflector->hasReturnType()) { return ''; } return \sprintf(': %s', self::formatReflectionType($reflector->getReturnType())); } /** * Format a method signature. * * @param \ReflectionMethod $reflector * * @return string Formatted signature */ private static function formatMethod(\ReflectionMethod $reflector): string { return \sprintf( '%s %s', self::formatModifiers($reflector), self::formatFunction($reflector) ); } /** * Print the function params. * * @param \ReflectionFunctionAbstract $reflector * * @return array */ private static function formatFunctionParams(\ReflectionFunctionAbstract $reflector): array { $params = []; foreach ($reflector->getParameters() as $param) { $hint = ''; try { if (\method_exists($param, 'getType')) { $hint = self::formatReflectionType($param->getType()); } else { if ($param->isArray()) { $hint = '<keyword>array</keyword>'; } elseif ($class = $param->getClass()) { $hint = \sprintf('<class>%s</class>', $class->getName()); } } } catch (\Throwable $e) { // sometimes we just don't know... // bad class names, or autoloaded classes that haven't been loaded yet, or whathaveyou. // come to think of it, the only time I've seen this is with the intl extension. // Hax: we'll try to extract it :P // @codeCoverageIgnoreStart $chunks = \explode('$'.$param->getName(), (string) $param); $chunks = \explode(' ', \trim($chunks[0])); $guess = \end($chunks); $hint = \sprintf('<urgent>%s</urgent>', OutputFormatter::escape($guess)); // @codeCoverageIgnoreEnd } if ($param->isOptional()) { if (!$param->isDefaultValueAvailable()) { $value = 'unknown'; $typeStyle = 'urgent'; } else { $value = $param->getDefaultValue(); $typeStyle = self::getTypeStyle($value); $value = \is_array($value) ? '[]' : ($value === null ? 'null' : \var_export($value, true)); } $default = \sprintf(' = <%s>%s</%s>', $typeStyle, OutputFormatter::escape($value), $typeStyle); } else { $default = ''; } $params[] = \sprintf( '%s%s%s<strong>$%s</strong>%s', $param->isPassedByReference() ? '&' : '', $hint, $hint !== '' ? ' ' : '', $param->getName(), $default ); } return $params; } /** * Print function param or return type(s). * * @param \ReflectionType $type */ private static function formatReflectionType(\ReflectionType $type = null): string { if ($type === null) { return ''; } $types = $type instanceof \ReflectionUnionType ? $type->getTypes() : [$type]; $formattedTypes = []; foreach ($types as $type) { $typeStyle = $type->isBuiltin() ? 'keyword' : 'class'; // PHP 7.0 didn't have `getName` on reflection types, so wheee! $typeName = \method_exists($type, 'getName') ? $type->getName() : (string) $type; // @todo Do we want to include the ? for nullable types? Maybe only sometimes? $formattedTypes[] = \sprintf('<%s>%s</%s>', $typeStyle, OutputFormatter::escape($typeName), $typeStyle); } return \implode('|', $formattedTypes); } } MessageFormatter.php 0000644 00000003144 15107410215 0010523 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Translation\Formatter; use Symfony\Component\Translation\IdentityTranslator; use Symfony\Contracts\Translation\TranslatorInterface; // Help opcache.preload discover always-needed symbols class_exists(IntlFormatter::class); /** * @author Abdellatif Ait boudad <a.aitboudad@gmail.com> */ class MessageFormatter implements MessageFormatterInterface, IntlFormatterInterface { private TranslatorInterface $translator; private IntlFormatterInterface $intlFormatter; /** * @param TranslatorInterface|null $translator An identity translator to use as selector for pluralization */ public function __construct(TranslatorInterface $translator = null, IntlFormatterInterface $intlFormatter = null) { $this->translator = $translator ?? new IdentityTranslator(); $this->intlFormatter = $intlFormatter ?? new IntlFormatter(); } public function format(string $message, string $locale, array $parameters = []): string { if ($this->translator instanceof TranslatorInterface) { return $this->translator->trans($message, $parameters, null, $locale); } return strtr($message, $parameters); } public function formatIntl(string $message, string $locale, array $parameters = []): string { return $this->intlFormatter->formatIntl($message, $locale, $parameters); } } IntlFormatter.php 0000644 00000004102 15107410215 0010040 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Translation\Formatter; use Symfony\Component\Translation\Exception\InvalidArgumentException; use Symfony\Component\Translation\Exception\LogicException; /** * @author Guilherme Blanco <guilhermeblanco@hotmail.com> * @author Abdellatif Ait boudad <a.aitboudad@gmail.com> */ class IntlFormatter implements IntlFormatterInterface { private $hasMessageFormatter; private $cache = []; public function formatIntl(string $message, string $locale, array $parameters = []): string { // MessageFormatter constructor throws an exception if the message is empty if ('' === $message) { return ''; } if (!$formatter = $this->cache[$locale][$message] ?? null) { if (!$this->hasMessageFormatter ??= class_exists(\MessageFormatter::class)) { throw new LogicException('Cannot parse message translation: please install the "intl" PHP extension or the "symfony/polyfill-intl-messageformatter" package.'); } try { $this->cache[$locale][$message] = $formatter = new \MessageFormatter($locale, $message); } catch (\IntlException $e) { throw new InvalidArgumentException(sprintf('Invalid message format (error #%d): ', intl_get_error_code()).intl_get_error_message(), 0, $e); } } foreach ($parameters as $key => $value) { if (\in_array($key[0] ?? null, ['%', '{'], true)) { unset($parameters[$key]); $parameters[trim($key, '%{ }')] = $value; } } if (false === $message = $formatter->format($parameters)) { throw new InvalidArgumentException(sprintf('Unable to format message (error #%s): ', $formatter->getErrorCode()).$formatter->getErrorMessage()); } return $message; } } error_log 0000644 00000002772 15107410215 0006465 0 ustar 00 [19-Nov-2025 04:16:08 UTC] PHP Fatal error: Uncaught Error: Interface "Symfony\Component\Translation\Formatter\MessageFormatterInterface" not found in /home/fluxyjvi/public_html/project/vendor/symfony/translation/Formatter/MessageFormatter.php:23 Stack trace: #0 {main} thrown in /home/fluxyjvi/public_html/project/vendor/symfony/translation/Formatter/MessageFormatter.php on line 23 [19-Nov-2025 04:16:10 UTC] PHP Fatal error: Uncaught Error: Interface "Symfony\Component\Translation\Formatter\IntlFormatterInterface" not found in /home/fluxyjvi/public_html/project/vendor/symfony/translation/Formatter/IntlFormatter.php:21 Stack trace: #0 {main} thrown in /home/fluxyjvi/public_html/project/vendor/symfony/translation/Formatter/IntlFormatter.php on line 21 [19-Nov-2025 11:05:13 UTC] PHP Fatal error: Uncaught Error: Interface "Symfony\Component\Translation\Formatter\MessageFormatterInterface" not found in /home/fluxyjvi/public_html/project/vendor/symfony/translation/Formatter/MessageFormatter.php:23 Stack trace: #0 {main} thrown in /home/fluxyjvi/public_html/project/vendor/symfony/translation/Formatter/MessageFormatter.php on line 23 [19-Nov-2025 11:05:17 UTC] PHP Fatal error: Uncaught Error: Interface "Symfony\Component\Translation\Formatter\IntlFormatterInterface" not found in /home/fluxyjvi/public_html/project/vendor/symfony/translation/Formatter/IntlFormatter.php:21 Stack trace: #0 {main} thrown in /home/fluxyjvi/public_html/project/vendor/symfony/translation/Formatter/IntlFormatter.php on line 21 IntlFormatterInterface.php 0000644 00000001262 15107410216 0011666 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Translation\Formatter; /** * Formats ICU message patterns. * * @author Nicolas Grekas <p@tchwork.com> */ interface IntlFormatterInterface { /** * Formats a localized message using rules defined by ICU MessageFormat. * * @see http://icu-project.org/apiref/icu4c/classMessageFormat.html#details */ public function formatIntl(string $message, string $locale, array $parameters = []): string; } MessageFormatterInterface.php 0000644 00000001526 15107410216 0012347 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Translation\Formatter; /** * @author Guilherme Blanco <guilhermeblanco@hotmail.com> * @author Abdellatif Ait boudad <a.aitboudad@gmail.com> */ interface MessageFormatterInterface { /** * Formats a localized message pattern with given arguments. * * @param string $message The message (may also be an object that can be cast to string) * @param string $locale The message locale * @param array $parameters An array of parameters for the message */ public function format(string $message, string $locale, array $parameters = []): string; }