Added dependency php-parallel-lint\php-console-color
This commit is contained in:
parent
3055547452
commit
59277226b9
8 changed files with 453 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -11,6 +11,7 @@ build
|
|||
src/ncc/ThirdParty/defuse/php-encryption/autoload_spl.php
|
||||
src/ncc/ThirdParty/jelix/version/autoload_spl.php
|
||||
src/ncc/ThirdParty/nikic/PhpParser/autoload_spl.php
|
||||
src/ncc/ThirdParty/php_parallel_lint/php_console_color/autoload_spl.php
|
||||
src/ncc/ThirdParty/Symfony/polyfill-ctype/autoload_spl.php
|
||||
src/ncc/ThirdParty/Symfony/polyfill-mbstring/autoload_spl.php
|
||||
src/ncc/ThirdParty/Symfony/polyfill-uuid/autoload_spl.php
|
||||
|
|
6
Makefile
6
Makefile
|
@ -8,6 +8,7 @@ autoload:
|
|||
make $(SRC_PATH)/ncc/ThirdParty/defuse/php-encryption/autoload_spl.php
|
||||
make $(SRC_PATH)/ncc/ThirdParty/jelix/version/autoload_spl.php
|
||||
make $(SRC_PATH)/ncc/ThirdParty/nikic/php-parser/autoload_spl.php
|
||||
make $(SRC_PATH)/ncc/ThirdParty/php_parallel_lint/php_console_color/autoload_spl.php
|
||||
make $(SRC_PATH)/ncc/ThirdParty/Symfony/polyfill-ctype/autoload_spl.php
|
||||
make $(SRC_PATH)/ncc/ThirdParty/Symfony/polyfill-mbstring/autoload_spl.php
|
||||
make $(SRC_PATH)/ncc/ThirdParty/Symfony/polyfill-uuid/autoload_spl.php
|
||||
|
@ -32,6 +33,10 @@ $(SRC_PATH)/ncc/ThirdParty/nikic/php-parser/autoload_spl.php:
|
|||
$(PHPCC) $(PHPAB) --output $(SRC_PATH)/ncc/ThirdParty/nikic/PhpParser/autoload_spl.php \
|
||||
$(SRC_PATH)/ncc/ThirdParty/nikic/PhpParser
|
||||
|
||||
$(SRC_PATH)/ncc/ThirdParty/php_parallel_lint/php_console_color/autoload_spl.php:
|
||||
$(PHPCC) $(PHPAB) --output $(SRC_PATH)/ncc/ThirdParty/php_parallel_lint/php_console_color/autoload_spl.php \
|
||||
$(SRC_PATH)/ncc/ThirdParty/php_parallel_lint/php_console_color
|
||||
|
||||
$(SRC_PATH)/ncc/ThirdParty/Symfony/polyfill-ctype/autoload_spl.php:
|
||||
$(PHPCC) $(PHPAB) --output $(SRC_PATH)/ncc/ThirdParty/Symfony/polyfill-ctype/autoload_spl.php \
|
||||
$(SRC_PATH)/ncc/ThirdParty/Symfony/polyfill-ctype
|
||||
|
@ -109,6 +114,7 @@ clean:
|
|||
rm -f $(SRC_PATH)/ncc/ThirdParty/defuse/php-encryption/autoload_spl.php
|
||||
rm -f $(SRC_PATH)/ncc/ThirdParty/jelix/version/autoload_spl.php
|
||||
rm -f $(SRC_PATH)/ncc/ThirdParty/nikic/PhpParser/autoload_spl.php
|
||||
rm -f $(SRC_PATH)/ncc/ThirdParty/php_parallel_lint/php_console_color
|
||||
rm -f $(SRC_PATH)/ncc/ThirdParty/Symfony/polyfill-ctype/autoload_spl.php
|
||||
rm -f $(SRC_PATH)/ncc/ThirdParty/Symfony/polyfill-mbstring/autoload_spl.php
|
||||
rm -f $(SRC_PATH)/ncc/ThirdParty/Symfony/polyfill-uuid/autoload_spl.php
|
||||
|
|
93
src/ncc/ThirdParty/php_parallel_lint/php_console_color/CHANGELOG.md
vendored
Normal file
93
src/ncc/ThirdParty/php_parallel_lint/php_console_color/CHANGELOG.md
vendored
Normal file
|
@ -0,0 +1,93 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
_Nothing yet._
|
||||
|
||||
|
||||
## [1.0.1] - 2021-12-25
|
||||
|
||||
### Changed
|
||||
|
||||
- Support for PHP 5.3 has been restored, [#22] from [@jrfnl].
|
||||
|
||||
### Internal
|
||||
- Welcome [@jrfnl] as new co-maintainer.
|
||||
- Improvements to the test suite, [#14], [#16], [#19], [#23], [#24] from [@jrfnl].
|
||||
- Improvements to the code consistency, [#13], [#23], [#25] from [@jrfnl].
|
||||
- Improvements to the CI/QA setup, [#12], [#17], [#18], [#20], [#27], [#28] from [@jrfnl].
|
||||
- Improvements to the changelog, [#21] from [@jrfnl].
|
||||
|
||||
[#12]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/12
|
||||
[#13]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/13
|
||||
[#14]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/14
|
||||
[#16]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/16
|
||||
[#17]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/17
|
||||
[#18]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/18
|
||||
[#19]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/19
|
||||
[#20]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/20
|
||||
[#21]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/21
|
||||
[#22]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/22
|
||||
[#23]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/23
|
||||
[#24]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/24
|
||||
[#25]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/25
|
||||
[#27]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/27
|
||||
[#28]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/28
|
||||
|
||||
|
||||
## [1.0] - 2020-10-31
|
||||
|
||||
### Changed
|
||||
|
||||
- BC-Break: The top-level namespace for all classes has changed from `JakubOnderka` to `PHP_Parallel_Lint`. [#10] from [@grogy].
|
||||
|
||||
### Added
|
||||
|
||||
- Added downloading per month badge from [@grogy].
|
||||
- Added license badge from [@grogy].
|
||||
- Added instruction for installation from [@grogy].
|
||||
- Composer: add description [#11] from [@jrfnl].
|
||||
|
||||
### Internal
|
||||
|
||||
- Updated PHP Parallel Lint dependency version restraint [#8] from [@jrfnl].
|
||||
- Travis: changed from "trusty" to "xenial" [#7] from [@jrfnl].
|
||||
- Update the unit tests setup [#9] from [@jrfnl].
|
||||
|
||||
[#7]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/7
|
||||
[#8]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/8
|
||||
[#9]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/9
|
||||
[#10]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/10
|
||||
[#11]: https://github.com/php-parallel-lint/PHP-Console-Color/pull/11
|
||||
|
||||
|
||||
## [0.3] - 2020-05-14
|
||||
|
||||
### Added
|
||||
|
||||
- Added changelog from [@reedy].
|
||||
|
||||
### Internal
|
||||
|
||||
- Travis: test against PHP 7.3 from [@samnela].
|
||||
- Cleaned readme - new organization from previous package from [@grogy].
|
||||
- Composer: updated dependancies to use new php-parallel-lint organisation from [@grogy].
|
||||
- Composer: marked package as replacing jakub-onderka/php-console-color from [@jrfnl].
|
||||
- Added a .gitattributes file from [@reedy].
|
||||
- Travis: test against PHP 7.4 and nightly from [@jrfnl].
|
||||
- Travis: only run PHPCS on PHP 7.4 from [@jrfnl].
|
||||
|
||||
|
||||
[Unreleased]: https://github.com/php-parallel-lint/PHP-Console-Color/compare/v1.0.1...HEAD
|
||||
[1.0.1]: https://github.com/php-parallel-lint/PHP-Console-Color/compare/v1.0...v1.0.1
|
||||
[1.0]: https://github.com/php-parallel-lint/PHP-Console-Color/compare/v0.3...v1.0
|
||||
[0.3]: https://github.com/php-parallel-lint/PHP-Console-Color/compare/v0.2...v0.3
|
||||
|
||||
[@grogy]: https://github.com/grogy
|
||||
[@jrfnl]: https://github.com/jrfnl
|
||||
[@reedy]: https://github.com/reedy
|
||||
[@samnela]: https://github.com/samnela
|
295
src/ncc/ThirdParty/php_parallel_lint/php_console_color/ConsoleColor.php
vendored
Normal file
295
src/ncc/ThirdParty/php_parallel_lint/php_console_color/ConsoleColor.php
vendored
Normal file
|
@ -0,0 +1,295 @@
|
|||
<?php
|
||||
|
||||
namespace ncc\ThirdParty\php_parallel_lint\php_console_color;
|
||||
|
||||
class ConsoleColor
|
||||
{
|
||||
const FOREGROUND = 38,
|
||||
BACKGROUND = 48;
|
||||
|
||||
const COLOR256_REGEXP = '~^(bg_)?color_([0-9]{1,3})$~';
|
||||
|
||||
const RESET_STYLE = 0;
|
||||
|
||||
/** @var bool */
|
||||
private $isSupported;
|
||||
|
||||
/** @var bool */
|
||||
private $forceStyle = false;
|
||||
|
||||
/** @var array */
|
||||
private $styles = array(
|
||||
'none' => null,
|
||||
'bold' => '1',
|
||||
'dark' => '2',
|
||||
'italic' => '3',
|
||||
'underline' => '4',
|
||||
'blink' => '5',
|
||||
'reverse' => '7',
|
||||
'concealed' => '8',
|
||||
|
||||
'default' => '39',
|
||||
'black' => '30',
|
||||
'red' => '31',
|
||||
'green' => '32',
|
||||
'yellow' => '33',
|
||||
'blue' => '34',
|
||||
'magenta' => '35',
|
||||
'cyan' => '36',
|
||||
'light_gray' => '37',
|
||||
|
||||
'dark_gray' => '90',
|
||||
'light_red' => '91',
|
||||
'light_green' => '92',
|
||||
'light_yellow' => '93',
|
||||
'light_blue' => '94',
|
||||
'light_magenta' => '95',
|
||||
'light_cyan' => '96',
|
||||
'white' => '97',
|
||||
|
||||
'bg_default' => '49',
|
||||
'bg_black' => '40',
|
||||
'bg_red' => '41',
|
||||
'bg_green' => '42',
|
||||
'bg_yellow' => '43',
|
||||
'bg_blue' => '44',
|
||||
'bg_magenta' => '45',
|
||||
'bg_cyan' => '46',
|
||||
'bg_light_gray' => '47',
|
||||
|
||||
'bg_dark_gray' => '100',
|
||||
'bg_light_red' => '101',
|
||||
'bg_light_green' => '102',
|
||||
'bg_light_yellow' => '103',
|
||||
'bg_light_blue' => '104',
|
||||
'bg_light_magenta' => '105',
|
||||
'bg_light_cyan' => '106',
|
||||
'bg_white' => '107',
|
||||
);
|
||||
|
||||
/** @var array */
|
||||
private $themes = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->isSupported = $this->isSupported();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $style
|
||||
* @param string $text
|
||||
* @return string
|
||||
* @throws InvalidStyleException
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function apply($style, $text)
|
||||
{
|
||||
if (!$this->isStyleForced() && !$this->isSupported()) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
if (is_string($style)) {
|
||||
$style = array($style);
|
||||
}
|
||||
if (!is_array($style)) {
|
||||
throw new \InvalidArgumentException("Style must be string or array.");
|
||||
}
|
||||
|
||||
$sequences = array();
|
||||
|
||||
foreach ($style as $s) {
|
||||
if (isset($this->themes[$s])) {
|
||||
$sequences = array_merge($sequences, $this->themeSequence($s));
|
||||
} elseif ($this->isValidStyle($s)) {
|
||||
$sequences[] = $this->styleSequence($s);
|
||||
} else {
|
||||
throw new InvalidStyleException($s);
|
||||
}
|
||||
}
|
||||
|
||||
$sequences = array_filter($sequences, function ($val) {
|
||||
return $val !== null;
|
||||
});
|
||||
|
||||
if (empty($sequences)) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
return $this->escSequence(implode(';', $sequences)) . $text . $this->escSequence(self::RESET_STYLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $forceStyle
|
||||
*/
|
||||
public function setForceStyle($forceStyle)
|
||||
{
|
||||
$this->forceStyle = (bool) $forceStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isStyleForced()
|
||||
{
|
||||
return $this->forceStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $themes
|
||||
* @throws InvalidStyleException
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setThemes(array $themes)
|
||||
{
|
||||
$this->themes = array();
|
||||
foreach ($themes as $name => $styles) {
|
||||
$this->addTheme($name, $styles);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array|string $styles
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws InvalidStyleException
|
||||
*/
|
||||
public function addTheme($name, $styles)
|
||||
{
|
||||
if (is_string($styles)) {
|
||||
$styles = array($styles);
|
||||
}
|
||||
if (!is_array($styles)) {
|
||||
throw new \InvalidArgumentException("Style must be string or array.");
|
||||
}
|
||||
|
||||
foreach ($styles as $style) {
|
||||
if (!$this->isValidStyle($style)) {
|
||||
throw new InvalidStyleException($style);
|
||||
}
|
||||
}
|
||||
|
||||
$this->themes[$name] = $styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getThemes()
|
||||
{
|
||||
return $this->themes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function hasTheme($name)
|
||||
{
|
||||
return isset($this->themes[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function removeTheme($name)
|
||||
{
|
||||
unset($this->themes[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSupported()
|
||||
{
|
||||
if (DIRECTORY_SEPARATOR === '\\') {
|
||||
// phpcs:ignore Generic.PHP.NoSilencedErrors,PHPCompatibility.FunctionUse.NewFunctions.sapi_windows_vt100_supportFound
|
||||
if (function_exists('sapi_windows_vt100_support') && @sapi_windows_vt100_support(STDOUT)) {
|
||||
return true;
|
||||
} elseif (getenv('ANSICON') !== false || getenv('ConEmuANSI') === 'ON') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
// phpcs:ignore Generic.PHP.NoSilencedErrors
|
||||
return function_exists('posix_isatty') && @posix_isatty(STDOUT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function are256ColorsSupported()
|
||||
{
|
||||
if (DIRECTORY_SEPARATOR === '\\') {
|
||||
// phpcs:ignore Generic.PHP.NoSilencedErrors,PHPCompatibility.FunctionUse.NewFunctions.sapi_windows_vt100_supportFound
|
||||
return function_exists('sapi_windows_vt100_support') && @sapi_windows_vt100_support(STDOUT);
|
||||
} else {
|
||||
return strpos(getenv('TERM'), '256color') !== false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getPossibleStyles()
|
||||
{
|
||||
return array_keys($this->styles);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return string[]
|
||||
*/
|
||||
private function themeSequence($name)
|
||||
{
|
||||
$sequences = array();
|
||||
foreach ($this->themes[$name] as $style) {
|
||||
$sequences[] = $this->styleSequence($style);
|
||||
}
|
||||
return $sequences;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $style
|
||||
* @return string
|
||||
*/
|
||||
private function styleSequence($style)
|
||||
{
|
||||
if (array_key_exists($style, $this->styles)) {
|
||||
return $this->styles[$style];
|
||||
}
|
||||
|
||||
if (!$this->are256ColorsSupported()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
preg_match(self::COLOR256_REGEXP, $style, $matches);
|
||||
|
||||
$type = $matches[1] === 'bg_' ? self::BACKGROUND : self::FOREGROUND;
|
||||
$value = $matches[2];
|
||||
|
||||
return "$type;5;$value";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $style
|
||||
* @return bool
|
||||
*/
|
||||
private function isValidStyle($style)
|
||||
{
|
||||
return array_key_exists($style, $this->styles) || preg_match(self::COLOR256_REGEXP, $style);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|int $value
|
||||
* @return string
|
||||
*/
|
||||
private function escSequence($value)
|
||||
{
|
||||
return "\033[{$value}m";
|
||||
}
|
||||
}
|
11
src/ncc/ThirdParty/php_parallel_lint/php_console_color/InvalidStyleException.php
vendored
Normal file
11
src/ncc/ThirdParty/php_parallel_lint/php_console_color/InvalidStyleException.php
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace ncc\ThirdParty\php_parallel_lint\php_console_color;
|
||||
|
||||
class InvalidStyleException extends \Exception
|
||||
{
|
||||
public function __construct($styleName)
|
||||
{
|
||||
parent::__construct("Invalid style $styleName.");
|
||||
}
|
||||
}
|
27
src/ncc/ThirdParty/php_parallel_lint/php_console_color/LICENSE
vendored
Normal file
27
src/ncc/ThirdParty/php_parallel_lint/php_console_color/LICENSE
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
Copyright (c) 2014-2018, Jakub Onderka
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
19
src/ncc/ThirdParty/php_parallel_lint/php_console_color/README.md
vendored
Normal file
19
src/ncc/ThirdParty/php_parallel_lint/php_console_color/README.md
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
PHP Console Color
|
||||
=================
|
||||
|
||||
[](https://packagist.org/packages/php-parallel-lint/php-console-color)
|
||||
[](https://github.com/php-parallel-lint/PHP-Console-Color/actions/workflows/cs.yml)
|
||||
[](https://github.com/php-parallel-lint/PHP-Console-Color/actions/workflows/test.yml)
|
||||
[](https://packagist.org/packages/php-parallel-lint/php-console-color)
|
||||
|
||||
Simple library for creating colored console ouput.
|
||||
|
||||
See `example.php` how to use this library.
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
Just run the following command to install it:
|
||||
|
||||
composer require php-parallel-lint/php-console-color
|
1
src/ncc/ThirdParty/php_parallel_lint/php_console_color/VERSION
vendored
Normal file
1
src/ncc/ThirdParty/php_parallel_lint/php_console_color/VERSION
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
0.0.5
|
Loading…
Add table
Reference in a new issue