File manager - Edit - /home/opticamezl/www/newok/CLI.tar
Back
Output/Stdout.php 0000644 00000002151 15172723751 0010050 0 ustar 00 <?php /** * Joomla! Content Management System * * @copyright (C) 2014 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Application\CLI\Output; use Joomla\CMS\Application\CLI\CliOutput; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Output handler for writing command line output to the stdout interface * * @since 4.0.0 * * @deprecated 4.3 will be removed in 6.0 * Use the `joomla/console` package instead */ class Stdout extends CliOutput { /** * Write a string to standard output * * @param string $text The text to display. * @param boolean $nl True (default) to append a new line at the end of the output string. * * @return $this * * @codeCoverageIgnore * @since 4.0.0 */ public function out($text = '', $nl = true) { fwrite(STDOUT, $this->getProcessor()->process($text) . ($nl ? "\n" : null)); return $this; } } Output/Processor/ProcessorInterface.php 0000644 00000001470 15172723751 0014350 0 ustar 00 <?php /** * Joomla! Content Management System * * @copyright (C) 2014 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Application\CLI\Output\Processor; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Interface for a command line output processor * * @since 4.0.0 * * @deprecated 4.3 will be removed in 6.0 * Use the `joomla/console` package instead */ interface ProcessorInterface { /** * Process the provided output into a string. * * @param string $output The string to process. * * @return string * * @since 4.0.0 */ public function process($output); } Output/Processor/ColorProcessor.php 0000644 00000011045 15172723751 0013525 0 ustar 00 <?php /** * Joomla! Content Management System * * @copyright (C) 2014 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Application\CLI\Output\Processor; use Joomla\CMS\Application\CLI\ColorStyle; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Command line output processor supporting ANSI-colored output * * @since 4.0.0 * * @deprecated 4.3 will be removed in 6.0 * Use the `joomla/console` package instead */ class ColorProcessor implements ProcessorInterface { /** * Flag to remove color codes from the output * * @var boolean * @since 4.0.0 */ public $noColors = false; /** * Regex to match tags * * @var string * @since 4.0.0 */ protected $tagFilter = '/<([a-z=;]+)>(.*?)<\/\\1>/s'; /** * Regex used for removing color codes * * @var string * @since 4.0.0 */ protected static $stripFilter = '/<[\/]?[a-z=;]+>/'; /** * Array of ColorStyle objects * * @var ColorStyle[] * @since 4.0.0 */ protected $styles = []; /** * Class constructor * * @param boolean $noColors Defines non-colored mode on construct * * @since 4.0.0 */ public function __construct($noColors = null) { if ($noColors === null) { /* * By default windows cmd.exe and PowerShell does not support ANSI-colored output * if the variable is not set explicitly colors should be disabled on Windows */ $noColors = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'); } $this->noColors = $noColors; $this->addPredefinedStyles(); } /** * Add a style. * * @param string $name The style name. * @param ColorStyle $style The color style. * * @return $this * * @since 4.0.0 */ public function addStyle($name, ColorStyle $style) { $this->styles[$name] = $style; return $this; } /** * Strip color tags from a string. * * @param string $string The string. * * @return string * * @since 4.0.0 */ public static function stripColors($string) { return preg_replace(static::$stripFilter, '', $string); } /** * Process a string. * * @param string $string The string to process. * * @return string * * @since 4.0.0 */ public function process($string) { preg_match_all($this->tagFilter, $string, $matches); if (!$matches) { return $string; } foreach ($matches[0] as $i => $m) { if (\array_key_exists($matches[1][$i], $this->styles)) { $string = $this->replaceColors($string, $matches[1][$i], $matches[2][$i], $this->styles[$matches[1][$i]]); } elseif (strpos($matches[1][$i], '=')) { // Custom format $string = $this->replaceColors($string, $matches[1][$i], $matches[2][$i], ColorStyle::fromString($matches[1][$i])); } } return $string; } /** * Replace color tags in a string. * * @param string $text The original text. * @param string $tag The matched tag. * @param string $match The match. * @param ColorStyle $style The color style to apply. * * @return mixed * * @since 4.0.0 */ private function replaceColors($text, $tag, $match, ColorStyle $style) { $replace = $this->noColors ? $match : "\033[" . $style . 'm' . $match . "\033[0m"; return str_replace('<' . $tag . '>' . $match . '</' . $tag . '>', $replace, $text); } /** * Adds predefined color styles to the ColorProcessor object * * @return $this * * @since 4.0.0 */ private function addPredefinedStyles() { $this->addStyle( 'info', new ColorStyle('green', '', ['bold']) ); $this->addStyle( 'comment', new ColorStyle('yellow', '', ['bold']) ); $this->addStyle( 'question', new ColorStyle('black', 'cyan') ); $this->addStyle( 'error', new ColorStyle('white', 'red') ); return $this; } } Output/Xml.php 0000644 00000002151 15172723751 0007326 0 ustar 00 <?php /** * Joomla! Content Management System * * @copyright (C) 2014 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Application\CLI\Output; use Joomla\CMS\Application\CLI\CliOutput; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Output handler for writing command line output to the stdout interface * * @since 4.0.0 * * @deprecated 4.3 will be removed in 6.0 * Use the `joomla/console` package instead */ class Xml extends CliOutput { /** * Write a string to standard output. * * @param string $text The text to display. * @param boolean $nl True (default) to append a new line at the end of the output string. * * @return $this * * @since 4.0.0 * @throws \RuntimeException * @codeCoverageIgnore */ public function out($text = '', $nl = true) { fwrite(STDOUT, $text . ($nl ? "\n" : null)); return $this; } } CliInput.php 0000644 00000001444 15172723751 0007021 0 ustar 00 <?php /** * Joomla! Content Management System * * @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Application\CLI; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Class CliInput * * @since 4.0.0 * * @deprecated 4.3 will be removed in 6.0 * Use the `joomla/console` package instead */ class CliInput { /** * Get a value from standard input. * * @return string The input string from standard input. * * @codeCoverageIgnore * @since 4.0.0 */ public function in() { return rtrim(fread(STDIN, 8192), "\n\r"); } } ColorStyle.php 0000644 00000013250 15172723751 0007367 0 ustar 00 <?php /** * Joomla! Content Management System * * @copyright (C) 2014 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Application\CLI; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Class defining ANSI-color styles for command line output * * @since 4.0.0 * * @deprecated 4.3 will be removed in 6.0 * Use the `joomla/console` package instead */ final class ColorStyle { /** * Known colors * * @var array * @since 4.0.0 */ private static $knownColors = [ 'black' => 0, 'red' => 1, 'green' => 2, 'yellow' => 3, 'blue' => 4, 'magenta' => 5, 'cyan' => 6, 'white' => 7, ]; /** * Known styles * * @var array * @since 4.0.0 */ private static $knownOptions = [ 'bold' => 1, 'underscore' => 4, 'blink' => 5, 'reverse' => 7, ]; /** * Foreground base value * * @var integer * @since 4.0.0 */ private static $fgBase = 30; /** * Background base value * * @var integer * @since 4.0.0 */ private static $bgBase = 40; /** * Foreground color * * @var integer * @since 4.0.0 */ private $fgColor = 0; /** * Background color * * @var integer * @since 4.0.0 */ private $bgColor = 0; /** * Array of style options * * @var array * @since 4.0.0 */ private $options = []; /** * Constructor * * @param string $fg Foreground color. * @param string $bg Background color. * @param array $options Style options. * * @since 4.0.0 * @throws \InvalidArgumentException */ public function __construct(string $fg = '', string $bg = '', array $options = []) { if ($fg) { if (\array_key_exists($fg, static::$knownColors) == false) { throw new \InvalidArgumentException( sprintf( 'Invalid foreground color "%1$s" [%2$s]', $fg, implode(', ', $this->getKnownColors()) ) ); } $this->fgColor = static::$fgBase + static::$knownColors[$fg]; } if ($bg) { if (\array_key_exists($bg, static::$knownColors) == false) { throw new \InvalidArgumentException( sprintf( 'Invalid background color "%1$s" [%2$s]', $bg, implode(', ', $this->getKnownColors()) ) ); } $this->bgColor = static::$bgBase + static::$knownColors[$bg]; } foreach ($options as $option) { if (\array_key_exists($option, static::$knownOptions) == false) { throw new \InvalidArgumentException( sprintf( 'Invalid option "%1$s" [%2$s]', $option, implode(', ', $this->getKnownOptions()) ) ); } $this->options[] = $option; } } /** * Convert to a string. * * @return string * * @since 4.0.0 */ public function __toString() { return $this->getStyle(); } /** * Create a color style from a parameter string. * * Example: fg=red;bg=blue;options=bold,blink * * @param string $string The parameter string. * * @return $this * * @since 4.0.0 * @throws \RuntimeException */ public static function fromString(string $string): self { $fg = ''; $bg = ''; $options = []; $parts = explode(';', $string); foreach ($parts as $part) { $subParts = explode('=', $part); if (\count($subParts) < 2) { continue; } switch ($subParts[0]) { case 'fg': $fg = $subParts[1]; break; case 'bg': $bg = $subParts[1]; break; case 'options': $options = explode(',', $subParts[1]); break; default: throw new \RuntimeException('Invalid option: ' . $subParts[0]); } } return new self($fg, $bg, $options); } /** * Get the translated color code. * * @return string * * @since 4.0.0 */ public function getStyle(): string { $values = []; if ($this->fgColor) { $values[] = $this->fgColor; } if ($this->bgColor) { $values[] = $this->bgColor; } foreach ($this->options as $option) { $values[] = static::$knownOptions[$option]; } return implode(';', $values); } /** * Get the known colors. * * @return string[] * * @since 4.0.0 */ public function getKnownColors(): array { return array_keys(static::$knownColors); } /** * Get the known options. * * @return string[] * * @since 4.0.0 */ public function getKnownOptions(): array { return array_keys(static::$knownOptions); } } CliOutput.php 0000644 00000004120 15172723751 0007214 0 ustar 00 <?php /** * Joomla! Content Management System * * @copyright (C) 2014 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Application\CLI; use Joomla\CMS\Application\CLI\Output\Processor\ProcessorInterface; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Base class defining a command line output handler * * @since 4.0.0 * * @deprecated 4.3 will be removed in 6.0 * Use the `joomla/console` package instead */ abstract class CliOutput { /** * Output processing object * * @var ProcessorInterface * @since 4.0.0 */ protected $processor; /** * Constructor * * @param ProcessorInterface $processor The output processor. * * @since 4.0.0 */ public function __construct(ProcessorInterface $processor = null) { $this->setProcessor($processor ?: new Output\Processor\ColorProcessor()); } /** * Set a processor * * @param ProcessorInterface $processor The output processor. * * @return $this * * @since 4.0.0 */ public function setProcessor(ProcessorInterface $processor) { $this->processor = $processor; return $this; } /** * Get a processor * * @return ProcessorInterface * * @since 4.0.0 * @throws \RuntimeException */ public function getProcessor() { if ($this->processor) { return $this->processor; } throw new \RuntimeException('A ProcessorInterface object has not been set.'); } /** * Write a string to an output handler. * * @param string $text The text to display. * @param boolean $nl True (default) to append a new line at the end of the output string. * * @return $this * * @since 4.0.0 * @codeCoverageIgnore */ abstract public function out($text = '', $nl = true); }
| ver. 1.4 |
Github
|
.
| PHP 8.3.23 | Generation time: 0 |
proxy
|
phpinfo
|
Settings