Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
15
vendor/consolidation/log/.editorconfig
vendored
Normal file
15
vendor/consolidation/log/.editorconfig
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
# This file is for unifying the coding style for different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[**.php]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
4
vendor/consolidation/log/.gitignore
vendored
Normal file
4
vendor/consolidation/log/.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
.DS_Store
|
||||
vendor
|
||||
build
|
||||
dependencies/*/vendor
|
36
vendor/consolidation/log/.travis.yml
vendored
Normal file
36
vendor/consolidation/log/.travis.yml
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
language: php
|
||||
|
||||
branches:
|
||||
# Only test the master branch and SemVer tags.
|
||||
only:
|
||||
- master
|
||||
- /^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+.*$/
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: 7.2
|
||||
env: 'SCENARIO=symfony4 HIGHEST_LOWEST="update"'
|
||||
- php: 7.1
|
||||
env: 'SCENARIO=symfony4'
|
||||
- php: 7.0.11
|
||||
env: 'HIGHEST_LOWEST="update"'
|
||||
- php: 7.0.11
|
||||
- php: 5.6
|
||||
- php: 5.5
|
||||
env: 'SCENARIO=symfony2 HIGHEST_LOWEST="update --prefer-lowest'
|
||||
|
||||
sudo: false
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- vendor
|
||||
- $HOME/.composer/cache
|
||||
|
||||
install:
|
||||
- 'composer scenario "${SCENARIO}" "${HIGHEST_LOWEST-install}"'
|
||||
|
||||
script:
|
||||
- composer test
|
||||
|
||||
after_success:
|
||||
- travis_retry php vendor/bin/coveralls -v
|
25
vendor/consolidation/log/CONTRIBUTING.md
vendored
Normal file
25
vendor/consolidation/log/CONTRIBUTING.md
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Contributing to Consolidation
|
||||
|
||||
Thank you for your interest in contributing to the Consolidation effort! Consolidation aims to provide reusable, loosely-coupled components useful for building command-line tools. Consolidation is built on top of Symfony Console, but aims to separate the tool from the implementation details of Symfony.
|
||||
|
||||
Here are some of the guidelines you should follow to make the most of your efforts:
|
||||
|
||||
## Code Style Guidelines
|
||||
|
||||
Consolidation adheres to the [PSR-2 Coding Style Guide](http://www.php-fig.org/psr/psr-2/) for PHP code.
|
||||
|
||||
## Pull Request Guidelines
|
||||
|
||||
Every pull request is run through:
|
||||
|
||||
- phpcs -n --standard=PSR2 src
|
||||
- phpunit
|
||||
- [Scrutinizer](https://scrutinizer-ci.com/g/consolidation-org/log/)
|
||||
|
||||
It is easy to run the unit tests and code sniffer locally; simply ensure that `./vendor/bin` is in your `$PATH`, cd to the root of the project directory, and run `phpcs` and `phpunit` as shown above. To automatically fix coding standard errors, run:
|
||||
|
||||
- phpcbf --standard=PSR2 src
|
||||
|
||||
After submitting a pull request, please examine the Scrutinizer report. It is not required to fix all Scrutinizer issues; you may ignore recommendations that you disagree with. The spacing patches produced by Scrutinizer do not conform to PSR2 standards, and therefore should never be applied. DocBlock patches may be applied at your discression. Things that Scrutinizer identifies as a bug nearly always needs to be addressed.
|
||||
|
||||
Pull requests must pass phpcs and phpunit in order to be merged; ideally, new functionality will also include new unit tests.
|
8
vendor/consolidation/log/LICENSE
vendored
Normal file
8
vendor/consolidation/log/LICENSE
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
Copyright (c) 2016 Consolidation Org Developers
|
||||
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
35
vendor/consolidation/log/README.md
vendored
Normal file
35
vendor/consolidation/log/README.md
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
# Consolidation\Log
|
||||
|
||||
Improved [PSR-3](http://www.php-fig.org/psr/psr-3/) [Psr\Log](https://github.com/php-fig/log) logger based on Symfony Console components.
|
||||
|
||||
[](https://travis-ci.org/consolidation-org/log) [](https://scrutinizer-ci.com/g/consolidation-org/log/?branch=master) [](https://coveralls.io/github/consolidation-org/log?branch=master) [](https://packagist.org/packages/consolidation/log)
|
||||
|
||||
## Component Status
|
||||
|
||||
In use in [Robo](https://github.com/Codegyre/Robo).
|
||||
|
||||
## Motivation
|
||||
|
||||
Consolidation\Log provides a Psr-3 compatible logger that provides styled log output to the standard error (stderr) stream. By default, styling is provided by the SymfonyStyle class from the Symfony Console component; however, alternative stylers may be provided if desired.
|
||||
|
||||
## Usage
|
||||
```
|
||||
$logger = new \Consolidation\Log\Logger($output);
|
||||
$logger->setLogOutputStyler(new LogOutputStyler()); // optional
|
||||
$logger->warning('The file {name} does not exist.', ['name' => $filename]);
|
||||
```
|
||||
String interpolation -- that is, the substitution of replacements, such as `{name}` in the example above, is not required by Psr-3, and is not implemented by default in the Psr\Log project. However, it is recommended by PRS-3, and is often done, e.g. in the Symfony Console logger.
|
||||
|
||||
Consolidation\Log supports string interpolation.
|
||||
|
||||
## Comparison to Existing Solutions
|
||||
|
||||
Many Symfony Console compoenents use SymfonyStyle to format their output messages. This helper class has methods named things like `success` and `warning`, making it seem like a natural choice for reporting status.
|
||||
|
||||
However, in practice it is much more convenient to use an actual Psr-3 logger for logging. Doing this allows a Symfony Console component to call an external library that may not need to depend on Symfony Style. Having the Psr\Log\LoggerInterface serve as the only shared IO-related interface in common between the console tool and the libraries it depends on promots loose coupling, allowing said libraries to be re-used in other contexts which may wish to log in different ways.
|
||||
|
||||
Symfony Console provides the ConsoleLogger to fill this need; however, ConsoleLogger does not provide any facility for styling output, leaving SymfonyStyle as the preferred logging mechanism for style-conscienscious console coders.
|
||||
|
||||
Consolidation\Log provides the benefits of both classes, allowing for code that both behaved technically correctly (redirecting to stderr) without sacrificing on style.
|
||||
|
||||
Monlog also provides a full-featured Console logger that might be applicable for some use cases.
|
62
vendor/consolidation/log/composer.json
vendored
Normal file
62
vendor/consolidation/log/composer.json
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
{
|
||||
"name": "consolidation/log",
|
||||
"description": "Improved Psr-3 / Psr\\Log logger based on Symfony Console components.",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Greg Anderson",
|
||||
"email": "greg.1.anderson@greenknowe.org"
|
||||
}
|
||||
],
|
||||
"autoload":{
|
||||
"psr-4":{
|
||||
"Consolidation\\Log\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Consolidation\\TestUtils\\": "tests/src"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.0",
|
||||
"psr/log": "~1.0",
|
||||
"symfony/console": "^2.8|^3|^4"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.*",
|
||||
"g1a/composer-test-scenarios": "^1",
|
||||
"satooshi/php-coveralls": "^2",
|
||||
"squizlabs/php_codesniffer": "2.*"
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"scripts": {
|
||||
"cs": "phpcs -n --standard=PSR2 src",
|
||||
"cbf": "phpcbf -n --standard=PSR2 src",
|
||||
"unit": "phpunit",
|
||||
"lint": [
|
||||
"find src -name '*.php' -print0 | xargs -0 -n1 php -l",
|
||||
"find tests/src -name '*.php' -print0 | xargs -0 -n1 php -l"
|
||||
],
|
||||
"test": [
|
||||
"@lint",
|
||||
"@unit",
|
||||
"@cs"
|
||||
],
|
||||
"scenario": "scenarios/install",
|
||||
"post-update-cmd": [
|
||||
"create-scenario symfony4 'symfony/console:^4.0'",
|
||||
"create-scenario symfony2 'symfony/console:^2.8' --platform-php '5.5' --no-lockfile"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "5.6"
|
||||
}
|
||||
}
|
||||
}
|
2019
vendor/consolidation/log/composer.lock
generated
vendored
Normal file
2019
vendor/consolidation/log/composer.lock
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
15
vendor/consolidation/log/phpunit.xml.dist
vendored
Normal file
15
vendor/consolidation/log/phpunit.xml.dist
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
<phpunit bootstrap="vendor/autoload.php" colors="true">
|
||||
<testsuites>
|
||||
<testsuite name="log">
|
||||
<directory prefix="test" suffix=".php">tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<logging>
|
||||
<log type="coverage-clover" target="build/logs/clover.xml"/>
|
||||
</logging>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
28
vendor/consolidation/log/scenarios/install
vendored
Executable file
28
vendor/consolidation/log/scenarios/install
vendored
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
SCENARIO=$1
|
||||
ACTION=${2-install}
|
||||
|
||||
dir=scenarios/${SCENARIO}
|
||||
if [ -z "$SCENARIO" ] ; then
|
||||
SCENARIO=default
|
||||
dir=.
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -d "$dir" ] ; then
|
||||
echo "Requested scenario '${SCENARIO}' does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "::"
|
||||
echo ":: Switch to ${SCENARIO} scenario"
|
||||
echo "::"
|
||||
echo
|
||||
|
||||
set -ex
|
||||
|
||||
composer -n validate --working-dir=$dir --no-check-all --ansi
|
||||
composer -n --working-dir=$dir ${ACTION} --prefer-dist --no-scripts
|
||||
composer -n --working-dir=$dir info
|
2
vendor/consolidation/log/scenarios/symfony2/.gitignore
vendored
Normal file
2
vendor/consolidation/log/scenarios/symfony2/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
vendor
|
||||
composer.lock
|
63
vendor/consolidation/log/scenarios/symfony2/composer.json
vendored
Normal file
63
vendor/consolidation/log/scenarios/symfony2/composer.json
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"name": "consolidation/log",
|
||||
"description": "Improved Psr-3 / Psr\\Log logger based on Symfony Console components.",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Greg Anderson",
|
||||
"email": "greg.1.anderson@greenknowe.org"
|
||||
}
|
||||
],
|
||||
"autoload":{
|
||||
"psr-4":{
|
||||
"Consolidation\\Log\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Consolidation\\TestUtils\\": "tests/src"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.0",
|
||||
"psr/log": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.*",
|
||||
"g1a/composer-test-scenarios": "^1",
|
||||
"satooshi/php-coveralls": "^2",
|
||||
"squizlabs/php_codesniffer": "2.*",
|
||||
"symfony/console": "^2.8"
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"scripts": {
|
||||
"cs": "phpcs -n --standard=PSR2 src",
|
||||
"cbf": "phpcbf -n --standard=PSR2 src",
|
||||
"unit": "phpunit",
|
||||
"lint": [
|
||||
"find src -name '*.php' -print0 | xargs -0 -n1 php -l",
|
||||
"find tests/src -name '*.php' -print0 | xargs -0 -n1 php -l"
|
||||
],
|
||||
"test": [
|
||||
"@lint",
|
||||
"@unit",
|
||||
"@cs"
|
||||
],
|
||||
"scenario": "scenarios/install",
|
||||
"post-update-cmd": [
|
||||
"create-scenario symfony4 'symfony/console:^4.0'",
|
||||
"create-scenario symfony2 'symfony/console:^2.8' --platform-php '5.5' --no-lockfile"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "5.5"
|
||||
},
|
||||
"vendor-dir": "../../vendor"
|
||||
}
|
||||
}
|
1
vendor/consolidation/log/scenarios/symfony2/src
vendored
Symbolic link
1
vendor/consolidation/log/scenarios/symfony2/src
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../src
|
1
vendor/consolidation/log/scenarios/symfony2/tests
vendored
Symbolic link
1
vendor/consolidation/log/scenarios/symfony2/tests
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../tests
|
1
vendor/consolidation/log/scenarios/symfony4/.gitignore
vendored
Normal file
1
vendor/consolidation/log/scenarios/symfony4/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
vendor
|
63
vendor/consolidation/log/scenarios/symfony4/composer.json
vendored
Normal file
63
vendor/consolidation/log/scenarios/symfony4/composer.json
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"name": "consolidation/log",
|
||||
"description": "Improved Psr-3 / Psr\\Log logger based on Symfony Console components.",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Greg Anderson",
|
||||
"email": "greg.1.anderson@greenknowe.org"
|
||||
}
|
||||
],
|
||||
"autoload":{
|
||||
"psr-4":{
|
||||
"Consolidation\\Log\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Consolidation\\TestUtils\\": "tests/src"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.0",
|
||||
"psr/log": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.*",
|
||||
"g1a/composer-test-scenarios": "^1",
|
||||
"satooshi/php-coveralls": "^2",
|
||||
"squizlabs/php_codesniffer": "2.*",
|
||||
"symfony/console": "^4.0"
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"scripts": {
|
||||
"cs": "phpcs -n --standard=PSR2 src",
|
||||
"cbf": "phpcbf -n --standard=PSR2 src",
|
||||
"unit": "phpunit",
|
||||
"lint": [
|
||||
"find src -name '*.php' -print0 | xargs -0 -n1 php -l",
|
||||
"find tests/src -name '*.php' -print0 | xargs -0 -n1 php -l"
|
||||
],
|
||||
"test": [
|
||||
"@lint",
|
||||
"@unit",
|
||||
"@cs"
|
||||
],
|
||||
"scenario": "scenarios/install",
|
||||
"post-update-cmd": [
|
||||
"create-scenario symfony4 'symfony/console:^4.0'",
|
||||
"create-scenario symfony2 'symfony/console:^2.8' --platform-php '5.5' --no-lockfile"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
|
||||
},
|
||||
"vendor-dir": "../../vendor"
|
||||
}
|
||||
}
|
1964
vendor/consolidation/log/scenarios/symfony4/composer.lock
generated
vendored
Normal file
1964
vendor/consolidation/log/scenarios/symfony4/composer.lock
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
vendor/consolidation/log/scenarios/symfony4/src
vendored
Symbolic link
1
vendor/consolidation/log/scenarios/symfony4/src
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../src
|
1
vendor/consolidation/log/scenarios/symfony4/tests
vendored
Symbolic link
1
vendor/consolidation/log/scenarios/symfony4/tests
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../tests
|
25
vendor/consolidation/log/src/ConsoleLogLevel.php
vendored
Normal file
25
vendor/consolidation/log/src/ConsoleLogLevel.php
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
/**
|
||||
* Additional log levels for use in Console applications.
|
||||
*
|
||||
* ConsoleLogLevels may be used by methods of Symfony Command
|
||||
* in applications where it is known that the Consolidation logger
|
||||
* is in use. These log levels provide access to the 'success'
|
||||
* styled output method. Code in reusable libraries that may
|
||||
* be used with a standard Psr-3 logger should aviod using these
|
||||
* log levels.
|
||||
*
|
||||
* All ConsoleLogLevels should be interpreted as LogLevel\NOTICE.
|
||||
*
|
||||
* @author Greg Anderson <greg.1.anderson@greenknowe.org>
|
||||
*/
|
||||
class ConsoleLogLevel extends \Psr\Log\LogLevel
|
||||
{
|
||||
/**
|
||||
* Command successfully completed some operation.
|
||||
* Displayed at VERBOSITY_NORMAL.
|
||||
*/
|
||||
const SUCCESS = 'success';
|
||||
}
|
115
vendor/consolidation/log/src/LogOutputStyler.php
vendored
Normal file
115
vendor/consolidation/log/src/LogOutputStyler.php
vendored
Normal file
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Psr\Log\LogLevel;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\OutputStyle;
|
||||
|
||||
/**
|
||||
* Styles log output based on format mappings provided in the constructor.
|
||||
*
|
||||
* Override for greater control.
|
||||
*/
|
||||
class LogOutputStyler extends UnstyledLogOutputStyler
|
||||
{
|
||||
const TASK_STYLE_INFO = 'fg=white;bg=cyan;options=bold';
|
||||
const TASK_STYLE_SUCCESS = 'fg=white;bg=green;options=bold';
|
||||
const TASK_STYLE_WARNING = 'fg=black;bg=yellow;options=bold;';
|
||||
const TASK_STYLE_ERROR = 'fg=white;bg=red;options=bold';
|
||||
|
||||
protected $defaultStyles = [
|
||||
'*' => LogLevel::INFO,
|
||||
];
|
||||
protected $labelStyles = [
|
||||
LogLevel::EMERGENCY => self::TASK_STYLE_ERROR,
|
||||
LogLevel::ALERT => self::TASK_STYLE_ERROR,
|
||||
LogLevel::CRITICAL => self::TASK_STYLE_ERROR,
|
||||
LogLevel::ERROR => self::TASK_STYLE_ERROR,
|
||||
LogLevel::WARNING => self::TASK_STYLE_WARNING,
|
||||
LogLevel::NOTICE => self::TASK_STYLE_INFO,
|
||||
LogLevel::INFO => self::TASK_STYLE_INFO,
|
||||
LogLevel::DEBUG => self::TASK_STYLE_INFO,
|
||||
ConsoleLogLevel::SUCCESS => self::TASK_STYLE_SUCCESS,
|
||||
];
|
||||
protected $messageStyles = [
|
||||
LogLevel::EMERGENCY => self::TASK_STYLE_ERROR,
|
||||
LogLevel::ALERT => self::TASK_STYLE_ERROR,
|
||||
LogLevel::CRITICAL => self::TASK_STYLE_ERROR,
|
||||
LogLevel::ERROR => self::TASK_STYLE_ERROR,
|
||||
LogLevel::WARNING => '',
|
||||
LogLevel::NOTICE => '',
|
||||
LogLevel::INFO => '',
|
||||
LogLevel::DEBUG => '',
|
||||
ConsoleLogLevel::SUCCESS => '',
|
||||
];
|
||||
|
||||
public function __construct($labelStyles = [], $messageStyles = [])
|
||||
{
|
||||
$this->labelStyles = $labelStyles + $this->labelStyles;
|
||||
$this->messageStyles = $messageStyles + $this->messageStyles;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultStyles()
|
||||
{
|
||||
return $this->defaultStyles;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function style($context)
|
||||
{
|
||||
$context += ['_style' => []];
|
||||
$context['_style'] += $this->defaultStyles();
|
||||
foreach ($context as $key => $value) {
|
||||
$styleKey = $key;
|
||||
if (!isset($context['_style'][$styleKey])) {
|
||||
$styleKey = '*';
|
||||
}
|
||||
if (is_string($value) && isset($context['_style'][$styleKey])) {
|
||||
$style = $context['_style'][$styleKey];
|
||||
$context[$key] = $this->wrapFormatString($context[$key], $style);
|
||||
}
|
||||
}
|
||||
return $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a string in a format element.
|
||||
*/
|
||||
protected function wrapFormatString($string, $style)
|
||||
{
|
||||
if ($style) {
|
||||
return "<{$style}>$string</>";
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up the label and message styles for the specified log level,
|
||||
* and use the log level as the label for the log message.
|
||||
*/
|
||||
protected function formatMessageByLevel($level, $message, $context)
|
||||
{
|
||||
$label = $level;
|
||||
return $this->formatMessage($label, $message, $context, $this->labelStyles[$level], $this->messageStyles[$level]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply styling with the provided label and message styles.
|
||||
*/
|
||||
protected function formatMessage($label, $message, $context, $labelStyle, $messageStyle = '')
|
||||
{
|
||||
if (!empty($messageStyle)) {
|
||||
$message = $this->wrapFormatString(" $message ", $messageStyle);
|
||||
}
|
||||
if (!empty($label)) {
|
||||
$message = ' ' . $this->wrapFormatString("[$label]", $labelStyle) . ' ' . $message;
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
105
vendor/consolidation/log/src/LogOutputStylerInterface.php
vendored
Normal file
105
vendor/consolidation/log/src/LogOutputStylerInterface.php
vendored
Normal file
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Allow a log message to by styled.
|
||||
*
|
||||
* Styling happens in two phases:
|
||||
*
|
||||
* 1. Prior to message interpolation, context variables are styled
|
||||
* via the 'style()' method, using styles provided in the context
|
||||
* under the '_style' key, and also using styles provided by the
|
||||
* 'defaultStyles()' method.
|
||||
*
|
||||
* @see Symfony\Component\Console\Logger\ConsoleLogger::interpolate()
|
||||
*
|
||||
* 2. After message interpolation, an appropriate method based on the
|
||||
* log level will be called. StyledConsoleLogger::$formatFunctionMap
|
||||
* is used to map the LogLevel to a LogOutputStylerInterface method to call.
|
||||
*
|
||||
* It is possible to select the exact class to use as the log styler
|
||||
* in the constructor of StyledConsoleLogger, and the mapping from
|
||||
* LogLevel to format function can also be extended. It is possible to
|
||||
* add new format methods not defined here, if desired, so long as
|
||||
* any method named in the format function map is implemented by the
|
||||
* selected log styler class.
|
||||
*/
|
||||
interface LogOutputStylerInterface
|
||||
{
|
||||
const STYLE_CONTEXT_KEY = '_style';
|
||||
|
||||
/**
|
||||
* Return an array of default styles to use in an application.
|
||||
* The key of the style is the variable name that the style
|
||||
* should be applied to (or '*' to match all variables that have
|
||||
* no specific style set), and the value is the contents of the
|
||||
* Symfony style tag to wrap around the variable value.
|
||||
*
|
||||
* Example:
|
||||
* message: 'Running {command}'
|
||||
* context: ['command' => 'pwd']
|
||||
* default styles: ['*' => 'info']
|
||||
* result: 'Running <info>pwd</>'
|
||||
*/
|
||||
public function defaultStyles();
|
||||
|
||||
/**
|
||||
* Apply styles specified in the STYLE_CONTEXT_KEY context variable to
|
||||
* the other named variables stored in the context. The styles from
|
||||
* the context are unioned with the default styles.
|
||||
*/
|
||||
public function style($context);
|
||||
|
||||
/**
|
||||
* Create a wrapper object for the output stream. If this styler
|
||||
* does not require an output wrapper, it should just return
|
||||
* its $output parameter.
|
||||
*/
|
||||
public function createOutputWrapper(OutputInterface $output);
|
||||
|
||||
/**
|
||||
* Print an ordinary log message, usually unstyled.
|
||||
*/
|
||||
public function log($output, $level, $message, $context);
|
||||
|
||||
/**
|
||||
* Print a success message.
|
||||
*/
|
||||
public function success($output, $level, $message, $context);
|
||||
|
||||
/**
|
||||
* Print an error message. Used when log level is:
|
||||
* - LogLevel::EMERGENCY
|
||||
* - LogLevel::ALERT
|
||||
* - LogLevel::CRITICAL
|
||||
* - LogLevel::ERROR
|
||||
*/
|
||||
public function error($output, $level, $message, $context);
|
||||
|
||||
/**
|
||||
* Print a warning message. Used when log level is:
|
||||
* - LogLevel::WARNING
|
||||
*/
|
||||
public function warning($output, $level, $message, $context);
|
||||
|
||||
/**
|
||||
* Print a note. Similar to 'text', but may contain additional
|
||||
* styling (e.g. the task name). Used when log level is:
|
||||
* - LogLevel::NOTICE
|
||||
* - LogLevel::INFO
|
||||
* - LogLevel::DEBUG
|
||||
*
|
||||
* IMPORTANT: Symfony loggers only display LogLevel::NOTICE when the
|
||||
* the verbosity level is VERBOSITY_VERBOSE, unless overridden in the
|
||||
* constructor. Robo\Common\Logger emits LogLevel::NOTICE at
|
||||
* VERBOSITY_NORMAL so that these messages will always be displayed.
|
||||
*/
|
||||
public function note($output, $level, $message, $context);
|
||||
|
||||
/**
|
||||
* Print an error message. Not used by default by StyledConsoleLogger.
|
||||
*/
|
||||
public function caution($output, $level, $message, $context);
|
||||
}
|
268
vendor/consolidation/log/src/Logger.php
vendored
Normal file
268
vendor/consolidation/log/src/Logger.php
vendored
Normal file
|
@ -0,0 +1,268 @@
|
|||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Psr\Log\AbstractLogger;
|
||||
use Psr\Log\InvalidArgumentException;
|
||||
use Psr\Log\LogLevel;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Console\Input\StringInput;
|
||||
|
||||
/**
|
||||
* Replacement for Symfony\Component\Console\Logger\ConsoleLogger.
|
||||
* Each of the different log level messages are routed through the
|
||||
* corresponding SymfonyStyle formatting method. Log messages are
|
||||
* always sent to stderr if the provided output object implements
|
||||
* ConsoleOutputInterface.
|
||||
*
|
||||
* Note that this class could extend ConsoleLogger if some methods
|
||||
* of that class were declared 'protected' instead of 'private'.
|
||||
*
|
||||
* @author Greg Anderson <greg.1.anderson@greenknowe.org>
|
||||
*/
|
||||
class Logger extends AbstractLogger // extends ConsoleLogger
|
||||
{
|
||||
/**
|
||||
* @var OutputInterface
|
||||
*/
|
||||
protected $output;
|
||||
/**
|
||||
* @var OutputInterface
|
||||
*/
|
||||
protected $error;
|
||||
/**
|
||||
* @var LogOutputStylerInterface
|
||||
*/
|
||||
protected $outputStyler;
|
||||
/**
|
||||
* @var OutputInterface|SymfonyStyle|other
|
||||
*/
|
||||
protected $outputStreamWrapper;
|
||||
protected $errorStreamWrapper;
|
||||
|
||||
protected $formatFunctionMap = [
|
||||
LogLevel::EMERGENCY => 'error',
|
||||
LogLevel::ALERT => 'error',
|
||||
LogLevel::CRITICAL => 'error',
|
||||
LogLevel::ERROR => 'error',
|
||||
LogLevel::WARNING => 'warning',
|
||||
LogLevel::NOTICE => 'note',
|
||||
LogLevel::INFO => 'note',
|
||||
LogLevel::DEBUG => 'note',
|
||||
ConsoleLogLevel::SUCCESS => 'success',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param OutputInterface $output
|
||||
* @param array $verbosityLevelMap
|
||||
* @param array $formatLevelMap
|
||||
* @param array $formatFunctionMap
|
||||
*/
|
||||
public function __construct(OutputInterface $output, array $verbosityLevelMap = array(), array $formatLevelMap = array(), array $formatFunctionMap = array())
|
||||
{
|
||||
$this->output = $output;
|
||||
|
||||
$this->verbosityLevelMap = $verbosityLevelMap + $this->verbosityLevelMap;
|
||||
$this->formatLevelMap = $formatLevelMap + $this->formatLevelMap;
|
||||
$this->formatFunctionMap = $formatFunctionMap + $this->formatFunctionMap;
|
||||
}
|
||||
|
||||
public function setLogOutputStyler(LogOutputStylerInterface $outputStyler, array $formatFunctionMap = array())
|
||||
{
|
||||
$this->outputStyler = $outputStyler;
|
||||
$this->formatFunctionMap = $formatFunctionMap + $this->formatFunctionMap;
|
||||
$this->outputStreamWrapper = null;
|
||||
$this->errorStreamWrapper = null;
|
||||
}
|
||||
|
||||
public function getLogOutputStyler()
|
||||
{
|
||||
if (!isset($this->outputStyler)) {
|
||||
$this->outputStyler = new SymfonyLogOutputStyler();
|
||||
}
|
||||
return $this->outputStyler;
|
||||
}
|
||||
|
||||
protected function getOutputStream()
|
||||
{
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
protected function getErrorStream()
|
||||
{
|
||||
if (!isset($this->error)) {
|
||||
$output = $this->getOutputStream();
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$output = $output->getErrorOutput();
|
||||
}
|
||||
$this->error = $output;
|
||||
}
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
public function setOutputStream($output)
|
||||
{
|
||||
$this->output = $output;
|
||||
$this->outputStreamWrapper = null;
|
||||
}
|
||||
|
||||
public function setErrorStream($error)
|
||||
{
|
||||
$this->error = $error;
|
||||
$this->errorStreamWrapper = null;
|
||||
}
|
||||
|
||||
protected function getOutputStreamWrapper()
|
||||
{
|
||||
if (!isset($this->outputStreamWrapper)) {
|
||||
$this->outputStreamWrapper = $this->getLogOutputStyler()->createOutputWrapper($this->getOutputStream());
|
||||
}
|
||||
return $this->outputStreamWrapper;
|
||||
}
|
||||
|
||||
protected function getErrorStreamWrapper()
|
||||
{
|
||||
if (!isset($this->errorStreamWrapper)) {
|
||||
$this->errorStreamWrapper = $this->getLogOutputStyler()->createOutputWrapper($this->getErrorStream());
|
||||
}
|
||||
return $this->errorStreamWrapper;
|
||||
}
|
||||
|
||||
protected function getOutputStreamForLogLevel($level)
|
||||
{
|
||||
// Write to the error output if necessary and available.
|
||||
// Usually, loggers that log to a terminal should send
|
||||
// all log messages to stderr.
|
||||
if (array_key_exists($level, $this->formatLevelMap) && ($this->formatLevelMap[$level] !== self::ERROR)) {
|
||||
return $this->getOutputStreamWrapper();
|
||||
}
|
||||
return $this->getErrorStreamWrapper();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function log($level, $message, array $context = array())
|
||||
{
|
||||
// We use the '_level' context variable to allow log messages
|
||||
// to be logged at one level (e.g. NOTICE) and formatted at another
|
||||
// level (e.g. SUCCESS). This helps in instances where we want
|
||||
// to style log messages at a custom log level that might not
|
||||
// be available in all loggers. If the logger does not recognize
|
||||
// the log level, then it is treated like the original log level.
|
||||
if (array_key_exists('_level', $context) && array_key_exists($context['_level'], $this->verbosityLevelMap)) {
|
||||
$level = $context['_level'];
|
||||
}
|
||||
// It is a runtime error if someone logs at a log level that
|
||||
// we do not recognize.
|
||||
if (!isset($this->verbosityLevelMap[$level])) {
|
||||
throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
|
||||
}
|
||||
|
||||
// Write to the error output if necessary and available.
|
||||
// Usually, loggers that log to a terminal should send
|
||||
// all log messages to stderr.
|
||||
$outputStreamWrapper = $this->getOutputStreamForLogLevel($level);
|
||||
|
||||
// Ignore messages that are not at the right verbosity level
|
||||
if ($this->getOutputStream()->getVerbosity() >= $this->verbosityLevelMap[$level]) {
|
||||
$this->doLog($outputStreamWrapper, $level, $message, $context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interpolate and style the message, and then send it to the log.
|
||||
*/
|
||||
protected function doLog($outputStreamWrapper, $level, $message, $context)
|
||||
{
|
||||
$formatFunction = 'log';
|
||||
if (array_key_exists($level, $this->formatFunctionMap)) {
|
||||
$formatFunction = $this->formatFunctionMap[$level];
|
||||
}
|
||||
$interpolated = $this->interpolate(
|
||||
$message,
|
||||
$this->getLogOutputStyler()->style($context)
|
||||
);
|
||||
$this->getLogOutputStyler()->$formatFunction(
|
||||
$outputStreamWrapper,
|
||||
$level,
|
||||
$interpolated,
|
||||
$context
|
||||
);
|
||||
}
|
||||
|
||||
public function success($message, array $context = array())
|
||||
{
|
||||
$this->log(ConsoleLogLevel::SUCCESS, $message, $context);
|
||||
}
|
||||
|
||||
// The functions below could be eliminated if made `protected` intead
|
||||
// of `private` in ConsoleLogger
|
||||
|
||||
const INFO = 'info';
|
||||
const ERROR = 'error';
|
||||
|
||||
/**
|
||||
* @var OutputInterface
|
||||
*/
|
||||
//private $output;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $verbosityLevelMap = [
|
||||
LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL,
|
||||
LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL,
|
||||
LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL,
|
||||
LogLevel::ERROR => OutputInterface::VERBOSITY_NORMAL,
|
||||
LogLevel::WARNING => OutputInterface::VERBOSITY_NORMAL,
|
||||
LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE,
|
||||
LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE,
|
||||
LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG,
|
||||
ConsoleLogLevel::SUCCESS => OutputInterface::VERBOSITY_NORMAL,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*
|
||||
* Send all log messages to stderr. Symfony should have the same default.
|
||||
* See: https://en.wikipedia.org/wiki/Standard_streams
|
||||
* "Standard error was added to Unix after several wasted phototypesetting runs ended with error messages being typeset instead of displayed on the user's terminal."
|
||||
*/
|
||||
private $formatLevelMap = [
|
||||
LogLevel::EMERGENCY => self::ERROR,
|
||||
LogLevel::ALERT => self::ERROR,
|
||||
LogLevel::CRITICAL => self::ERROR,
|
||||
LogLevel::ERROR => self::ERROR,
|
||||
LogLevel::WARNING => self::ERROR,
|
||||
LogLevel::NOTICE => self::ERROR,
|
||||
LogLevel::INFO => self::ERROR,
|
||||
LogLevel::DEBUG => self::ERROR,
|
||||
ConsoleLogLevel::SUCCESS => self::ERROR,
|
||||
];
|
||||
|
||||
/**
|
||||
* Interpolates context values into the message placeholders.
|
||||
*
|
||||
* @author PHP Framework Interoperability Group
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function interpolate($message, array $context)
|
||||
{
|
||||
// build a replacement array with braces around the context keys
|
||||
$replace = array();
|
||||
foreach ($context as $key => $val) {
|
||||
if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) {
|
||||
$replace[sprintf('{%s}', $key)] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
// interpolate replacement values into the message and return
|
||||
return strtr($message, $replace);
|
||||
}
|
||||
}
|
65
vendor/consolidation/log/src/SymfonyLogOutputStyler.php
vendored
Normal file
65
vendor/consolidation/log/src/SymfonyLogOutputStyler.php
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Console\Input\StringInput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Style log messages with Symfony\Component\Console\Style\SymfonyStyle.
|
||||
* No context variable styling is done.
|
||||
*
|
||||
* This is the appropriate styler to use if your desire is to replace
|
||||
* the use of SymfonyStyle with a Psr-3 logger without changing the
|
||||
* appearance of your application's output.
|
||||
*/
|
||||
class SymfonyLogOutputStyler implements LogOutputStylerInterface
|
||||
{
|
||||
public function defaultStyles()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function style($context)
|
||||
{
|
||||
return $context;
|
||||
}
|
||||
|
||||
public function createOutputWrapper(OutputInterface $output)
|
||||
{
|
||||
// SymfonyStyle & c. contain both input and output functions,
|
||||
// but we only need the output methods here. Create a stand-in
|
||||
// input object to satisfy the SymfonyStyle constructor.
|
||||
return new SymfonyStyle(new StringInput(''), $output);
|
||||
}
|
||||
|
||||
public function log($symfonyStyle, $level, $message, $context)
|
||||
{
|
||||
$symfonyStyle->text($message);
|
||||
}
|
||||
|
||||
public function success($symfonyStyle, $level, $message, $context)
|
||||
{
|
||||
$symfonyStyle->success($message);
|
||||
}
|
||||
|
||||
public function error($symfonyStyle, $level, $message, $context)
|
||||
{
|
||||
$symfonyStyle->error($message);
|
||||
}
|
||||
|
||||
public function warning($symfonyStyle, $level, $message, $context)
|
||||
{
|
||||
$symfonyStyle->warning($message);
|
||||
}
|
||||
|
||||
public function note($symfonyStyle, $level, $message, $context)
|
||||
{
|
||||
$symfonyStyle->note($message);
|
||||
}
|
||||
|
||||
public function caution($symfonyStyle, $level, $message, $context)
|
||||
{
|
||||
$symfonyStyle->caution($message);
|
||||
}
|
||||
}
|
97
vendor/consolidation/log/src/UnstyledLogOutputStyler.php
vendored
Normal file
97
vendor/consolidation/log/src/UnstyledLogOutputStyler.php
vendored
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\OutputStyle;
|
||||
|
||||
/**
|
||||
* Base class that provides basic unstyled output.
|
||||
*/
|
||||
class UnstyledLogOutputStyler implements LogOutputStylerInterface
|
||||
{
|
||||
public function createOutputWrapper(OutputInterface $output)
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultStyles()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function style($context)
|
||||
{
|
||||
return $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function write($output, $message, $context)
|
||||
{
|
||||
$output->writeln($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function log($output, $level, $message, $context)
|
||||
{
|
||||
return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function success($output, $level, $message, $context)
|
||||
{
|
||||
return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function error($output, $level, $message, $context)
|
||||
{
|
||||
return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function warning($output, $level, $message, $context)
|
||||
{
|
||||
return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function note($output, $level, $message, $context)
|
||||
{
|
||||
return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function caution($output, $level, $message, $context)
|
||||
{
|
||||
return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up the label and message styles for the specified log level,
|
||||
* and use the log level as the label for the log message.
|
||||
*/
|
||||
protected function formatMessageByLevel($level, $message, $context)
|
||||
{
|
||||
return " [$level] $message";
|
||||
}
|
||||
}
|
81
vendor/consolidation/log/tests/src/TestDataPermuter.php
vendored
Normal file
81
vendor/consolidation/log/tests/src/TestDataPermuter.php
vendored
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
namespace Consolidation\TestUtils;
|
||||
|
||||
class TestDataPermuter
|
||||
{
|
||||
/**
|
||||
* Given an array of test data, where each element is
|
||||
* data to pass to a unit test AND each unit test requires
|
||||
* only scalar or object test value, find each array
|
||||
* in each test, and build all of the permutations for all
|
||||
* of the data provided in arrays.
|
||||
*/
|
||||
public static function expandProviderDataArrays($tests)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach($tests as $test) {
|
||||
$subsitutionIndex = 1;
|
||||
$permutationData = [];
|
||||
$replacements = [];
|
||||
|
||||
foreach($test as $testValue) {
|
||||
if (is_array($testValue)) {
|
||||
$key = "{SUB$subsitutionIndex}";
|
||||
$replacements[$key] = $testValue;
|
||||
$permutationData[] = $key;
|
||||
}
|
||||
else {
|
||||
$permutationData[] = $testValue;
|
||||
}
|
||||
}
|
||||
|
||||
$permuted = static::expandDataMatrix([$permutationData], $replacements);
|
||||
$result = array_merge($result, $permuted);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an array of test data, where each element is
|
||||
* data to pass to a unit test, expand all of the
|
||||
* permutations of $replacements, where each key
|
||||
* holds the placeholder value, and the value holds
|
||||
* an array of replacement values.
|
||||
*/
|
||||
public static function expandDataMatrix($tests, $replacements)
|
||||
{
|
||||
foreach($replacements as $substitute => $values) {
|
||||
$tests = static::expandOneValue($tests, $substitute, $values);
|
||||
}
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an array of test data, where each element is
|
||||
* data to pass to a unit test, find any element in any
|
||||
* one test item whose value is exactly $substitute.
|
||||
* Make a new test item for every item in $values, using
|
||||
* each as the substitution for $substitute.
|
||||
*/
|
||||
public static function expandOneValue($tests, $substitute, $values)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach($tests as $test) {
|
||||
$position = array_search($substitute, $test);
|
||||
if ($position === FALSE) {
|
||||
$result[] = $test;
|
||||
}
|
||||
else {
|
||||
foreach($values as $replacement) {
|
||||
$test[$position] = $replacement;
|
||||
$result[] = $test;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
54
vendor/consolidation/log/tests/testLogMethods.php
vendored
Normal file
54
vendor/consolidation/log/tests/testLogMethods.php
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class LogMethodTests extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $output;
|
||||
protected $logger;
|
||||
|
||||
function setup() {
|
||||
$this->output = new BufferedOutput();
|
||||
$this->output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
|
||||
$this->logger = new Logger($this->output);
|
||||
$this->logger->setLogOutputStyler(new UnstyledLogOutputStyler());
|
||||
}
|
||||
|
||||
function testError() {
|
||||
$this->logger->error('Do not enter - wrong way.');
|
||||
$outputText = rtrim($this->output->fetch());
|
||||
$this->assertEquals(' [error] Do not enter - wrong way.', $outputText);
|
||||
}
|
||||
|
||||
function testWarning() {
|
||||
$this->logger->warning('Steep grade.');
|
||||
$outputText = rtrim($this->output->fetch());
|
||||
$this->assertEquals(' [warning] Steep grade.', $outputText);
|
||||
}
|
||||
|
||||
function testNotice() {
|
||||
$this->logger->notice('No loitering.');
|
||||
$outputText = rtrim($this->output->fetch());
|
||||
$this->assertEquals(' [notice] No loitering.', $outputText);
|
||||
}
|
||||
|
||||
function testInfo() {
|
||||
$this->logger->info('Scenic route.');
|
||||
$outputText = rtrim($this->output->fetch());
|
||||
$this->assertEquals(' [info] Scenic route.', $outputText);
|
||||
}
|
||||
|
||||
function testDebug() {
|
||||
$this->logger->debug('Counter incremented.');
|
||||
$outputText = rtrim($this->output->fetch());
|
||||
$this->assertEquals(' [debug] Counter incremented.', $outputText);
|
||||
}
|
||||
|
||||
function testSuccess() {
|
||||
$this->logger->success('It worked!');
|
||||
$outputText = rtrim($this->output->fetch());
|
||||
$this->assertEquals(' [success] It worked!', $outputText);
|
||||
}
|
||||
}
|
164
vendor/consolidation/log/tests/testLoggerVerbosityAndStyles.php
vendored
Normal file
164
vendor/consolidation/log/tests/testLoggerVerbosityAndStyles.php
vendored
Normal file
|
@ -0,0 +1,164 @@
|
|||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Psr\Log\LogLevel;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use Consolidation\TestUtils\TestDataPermuter;
|
||||
|
||||
class LoggerVerbosityAndStyleTests extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $output;
|
||||
protected $logger;
|
||||
|
||||
function setup() {
|
||||
$this->output = new BufferedOutput();
|
||||
//$this->output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
|
||||
$this->logger = new Logger($this->output);
|
||||
}
|
||||
|
||||
public static function logTestValues()
|
||||
{
|
||||
/**
|
||||
* Use TEST_ALL_LOG_LEVELS to ensure that output is the same
|
||||
* in instances where the output does not vary by log level.
|
||||
*/
|
||||
$TEST_ALL_LOG_LEVELS = [
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
OutputInterface::VERBOSITY_VERY_VERBOSE,
|
||||
OutputInterface::VERBOSITY_VERBOSE,
|
||||
OutputInterface::VERBOSITY_NORMAL
|
||||
];
|
||||
|
||||
// Tests that return the same value for multiple inputs
|
||||
// may use the expandProviderDataArrays method, and list
|
||||
// repeated scalars as array values. All permutations of
|
||||
// all array items will be calculated, and one test will
|
||||
// be generated for each one.
|
||||
return TestDataPermuter::expandProviderDataArrays([
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
$TEST_ALL_LOG_LEVELS,
|
||||
LogLevel::ERROR,
|
||||
'Do not enter - wrong way.',
|
||||
' [error] Do not enter - wrong way.',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
$TEST_ALL_LOG_LEVELS,
|
||||
LogLevel::WARNING,
|
||||
'Steep grade.',
|
||||
' [warning] Steep grade.',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
[
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
OutputInterface::VERBOSITY_VERY_VERBOSE,
|
||||
OutputInterface::VERBOSITY_VERBOSE,
|
||||
],
|
||||
LogLevel::NOTICE,
|
||||
'No loitering.',
|
||||
' [notice] No loitering.',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_NORMAL,
|
||||
LogLevel::NOTICE,
|
||||
'No loitering.',
|
||||
'',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
LogLevel::INFO,
|
||||
'Scenic route.',
|
||||
' [info] Scenic route.',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
LogLevel::DEBUG,
|
||||
'Counter incremented.',
|
||||
' [debug] Counter incremented.',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
[
|
||||
OutputInterface::VERBOSITY_VERY_VERBOSE,
|
||||
OutputInterface::VERBOSITY_VERBOSE,
|
||||
OutputInterface::VERBOSITY_NORMAL
|
||||
],
|
||||
LogLevel::DEBUG,
|
||||
'Counter incremented.',
|
||||
'',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
$TEST_ALL_LOG_LEVELS,
|
||||
ConsoleLogLevel::SUCCESS,
|
||||
'It worked!',
|
||||
' [success] It worked!',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\LogOutputStyler',
|
||||
OutputInterface::VERBOSITY_NORMAL,
|
||||
ConsoleLogLevel::SUCCESS,
|
||||
'It worked!',
|
||||
' [success] It worked!',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\SymfonyLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
LogLevel::WARNING,
|
||||
'Steep grade.',
|
||||
"\n [WARNING] Steep grade.",
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\SymfonyLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
LogLevel::NOTICE,
|
||||
'No loitering.',
|
||||
"\n ! [NOTE] No loitering.",
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\SymfonyLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
LogLevel::INFO,
|
||||
'Scenic route.',
|
||||
"\n ! [NOTE] Scenic route.",
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\SymfonyLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
LogLevel::DEBUG,
|
||||
'Counter incremented.',
|
||||
"\n ! [NOTE] Counter incremented.",
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\SymfonyLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_NORMAL,
|
||||
ConsoleLogLevel::SUCCESS,
|
||||
'It worked!',
|
||||
"\n [OK] It worked!",
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is our only test method. It accepts all of the
|
||||
* permuted data from the data provider, and runs one
|
||||
* test on each one.
|
||||
*
|
||||
* @dataProvider logTestValues
|
||||
*/
|
||||
function testLogging($styleClass, $verbocity, $level, $message, $expected) {
|
||||
$logStyler = new $styleClass;
|
||||
$this->logger->setLogOutputStyler($logStyler);
|
||||
$this->output->setVerbosity($verbocity);
|
||||
$this->logger->log($level, $message);
|
||||
$outputText = rtrim($this->output->fetch(), "\n\r\t ");
|
||||
$this->assertEquals($expected, $outputText);
|
||||
}
|
||||
}
|
Reference in a new issue