mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
Updated Rector to commit 9b7ef717dded89018fd87febd7ffc7358ecaddcd
9b7ef717dd
[scoped] Keep tracy logger as needed in dump()
This commit is contained in:
parent
6d0c79899d
commit
abedf4d309
@ -16,11 +16,11 @@ final class VersionResolver
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '49b5ef525f9baef048d9a289ff389d49d97e081c';
|
||||
public const PACKAGE_VERSION = '9b7ef717dded89018fd87febd7ffc7358ecaddcd';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-05-31 14:38:29';
|
||||
public const RELEASE_DATE = '2022-05-31 15:03:09';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitd0e617c025a4e84ea7b03323d7053dd1::getLoader();
|
||||
return ComposerAutoloaderInit8301977485a4848b0885a70a7d8ad775::getLoader();
|
||||
|
3
vendor/composer/autoload_classmap.php
vendored
3
vendor/composer/autoload_classmap.php
vendored
@ -1269,7 +1269,10 @@ return array(
|
||||
'RectorPrefix20220531\\Tracy\\Dumper\\Exposer' => $vendorDir . '/tracy/tracy/src/Tracy/Dumper/Exposer.php',
|
||||
'RectorPrefix20220531\\Tracy\\Dumper\\Renderer' => $vendorDir . '/tracy/tracy/src/Tracy/Dumper/Renderer.php',
|
||||
'RectorPrefix20220531\\Tracy\\Dumper\\Value' => $vendorDir . '/tracy/tracy/src/Tracy/Dumper/Value.php',
|
||||
'RectorPrefix20220531\\Tracy\\FireLogger' => $vendorDir . '/tracy/tracy/src/Tracy/Logger/FireLogger.php',
|
||||
'RectorPrefix20220531\\Tracy\\Helpers' => $vendorDir . '/tracy/tracy/src/Tracy/Helpers.php',
|
||||
'RectorPrefix20220531\\Tracy\\ILogger' => $vendorDir . '/tracy/tracy/src/Tracy/Logger/ILogger.php',
|
||||
'RectorPrefix20220531\\Tracy\\Logger' => $vendorDir . '/tracy/tracy/src/Tracy/Logger/Logger.php',
|
||||
'RectorPrefix20220531\\Tracy\\OutputDebugger' => $vendorDir . '/tracy/tracy/src/Tracy/OutputDebugger/OutputDebugger.php',
|
||||
'RectorPrefix20220531\\Tracy\\ProductionStrategy' => $vendorDir . '/tracy/tracy/src/Tracy/Debugger/ProductionStrategy.php',
|
||||
'RectorPrefix20220531\\Webmozart\\Assert\\Assert' => $vendorDir . '/webmozart/assert/src/Assert.php',
|
||||
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitd0e617c025a4e84ea7b03323d7053dd1
|
||||
class ComposerAutoloaderInit8301977485a4848b0885a70a7d8ad775
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,19 +22,19 @@ class ComposerAutoloaderInitd0e617c025a4e84ea7b03323d7053dd1
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitd0e617c025a4e84ea7b03323d7053dd1', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit8301977485a4848b0885a70a7d8ad775', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitd0e617c025a4e84ea7b03323d7053dd1', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit8301977485a4848b0885a70a7d8ad775', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitd0e617c025a4e84ea7b03323d7053dd1::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit8301977485a4848b0885a70a7d8ad775::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInitd0e617c025a4e84ea7b03323d7053dd1::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit8301977485a4848b0885a70a7d8ad775::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequired0e617c025a4e84ea7b03323d7053dd1($fileIdentifier, $file);
|
||||
composerRequire8301977485a4848b0885a70a7d8ad775($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
@ -46,7 +46,7 @@ class ComposerAutoloaderInitd0e617c025a4e84ea7b03323d7053dd1
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequired0e617c025a4e84ea7b03323d7053dd1($fileIdentifier, $file)
|
||||
function composerRequire8301977485a4848b0885a70a7d8ad775($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
11
vendor/composer/autoload_static.php
vendored
11
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitd0e617c025a4e84ea7b03323d7053dd1
|
||||
class ComposerStaticInit8301977485a4848b0885a70a7d8ad775
|
||||
{
|
||||
public static $files = array (
|
||||
'23c18046f52bef3eea034657bafda50f' => __DIR__ . '/..' . '/symfony/polyfill-php81/bootstrap.php',
|
||||
@ -1584,7 +1584,10 @@ class ComposerStaticInitd0e617c025a4e84ea7b03323d7053dd1
|
||||
'RectorPrefix20220531\\Tracy\\Dumper\\Exposer' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Dumper/Exposer.php',
|
||||
'RectorPrefix20220531\\Tracy\\Dumper\\Renderer' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Dumper/Renderer.php',
|
||||
'RectorPrefix20220531\\Tracy\\Dumper\\Value' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Dumper/Value.php',
|
||||
'RectorPrefix20220531\\Tracy\\FireLogger' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Logger/FireLogger.php',
|
||||
'RectorPrefix20220531\\Tracy\\Helpers' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Helpers.php',
|
||||
'RectorPrefix20220531\\Tracy\\ILogger' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Logger/ILogger.php',
|
||||
'RectorPrefix20220531\\Tracy\\Logger' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Logger/Logger.php',
|
||||
'RectorPrefix20220531\\Tracy\\OutputDebugger' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/OutputDebugger/OutputDebugger.php',
|
||||
'RectorPrefix20220531\\Tracy\\ProductionStrategy' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Debugger/ProductionStrategy.php',
|
||||
'RectorPrefix20220531\\Webmozart\\Assert\\Assert' => __DIR__ . '/..' . '/webmozart/assert/src/Assert.php',
|
||||
@ -3762,9 +3765,9 @@ class ComposerStaticInitd0e617c025a4e84ea7b03323d7053dd1
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitd0e617c025a4e84ea7b03323d7053dd1::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitd0e617c025a4e84ea7b03323d7053dd1::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitd0e617c025a4e84ea7b03323d7053dd1::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit8301977485a4848b0885a70a7d8ad775::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit8301977485a4848b0885a70a7d8ad775::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit8301977485a4848b0885a70a7d8ad775::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -2344,12 +2344,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
|
||||
"reference": "97e4d85cb946ff8adf5385045116e9e2eff0aac6"
|
||||
"reference": "31de14018d6642879721e11e71855a6ef0be74df"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/97e4d85cb946ff8adf5385045116e9e2eff0aac6",
|
||||
"reference": "97e4d85cb946ff8adf5385045116e9e2eff0aac6",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/31de14018d6642879721e11e71855a6ef0be74df",
|
||||
"reference": "31de14018d6642879721e11e71855a6ef0be74df",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2374,7 +2374,7 @@
|
||||
"symplify\/rule-doc-generator": "^10.0",
|
||||
"symplify\/vendor-patches": "^10.0"
|
||||
},
|
||||
"time": "2022-05-30T20:09:46+00:00",
|
||||
"time": "2022-05-31T12:41:50+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
|
||||
*/
|
||||
final class GeneratedConfig
|
||||
{
|
||||
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 7e0a6f9'), 'rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main c745427'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 784271e'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e1d324e'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main b4026b1'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e00fa91'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 97e4d85'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 6ad431c'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 43e5f8e'));
|
||||
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 7e0a6f9'), 'rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main c745427'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 784271e'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e1d324e'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main b4026b1'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e00fa91'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 31de140'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 6ad431c'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 43e5f8e'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -84,6 +84,7 @@ CODE_SAMPLE
|
||||
return null;
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
$hasChanged = \false;
|
||||
foreach (self::ANNOTATION_TO_METHOD as $annotationName => $methodName) {
|
||||
if (!$phpDocInfo->hasByName($annotationName)) {
|
||||
continue;
|
||||
@ -91,6 +92,10 @@ CODE_SAMPLE
|
||||
$methodCallExpressions = $this->expectExceptionMethodCallFactory->createFromTagValueNodes($phpDocInfo->getTagsByName($annotationName), $methodName);
|
||||
$node->stmts = \array_merge($methodCallExpressions, (array) $node->stmts);
|
||||
$this->phpDocTagRemover->removeByName($phpDocInfo, $annotationName);
|
||||
$hasChanged = \true;
|
||||
}
|
||||
if (!$hasChanged) {
|
||||
return null;
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
|
||||
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
|
||||
spl_autoload_call('RectorPrefix20220531\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInitd0e617c025a4e84ea7b03323d7053dd1', false) && !interface_exists('ComposerAutoloaderInitd0e617c025a4e84ea7b03323d7053dd1', false) && !trait_exists('ComposerAutoloaderInitd0e617c025a4e84ea7b03323d7053dd1', false)) {
|
||||
spl_autoload_call('RectorPrefix20220531\ComposerAutoloaderInitd0e617c025a4e84ea7b03323d7053dd1');
|
||||
if (!class_exists('ComposerAutoloaderInit8301977485a4848b0885a70a7d8ad775', false) && !interface_exists('ComposerAutoloaderInit8301977485a4848b0885a70a7d8ad775', false) && !trait_exists('ComposerAutoloaderInit8301977485a4848b0885a70a7d8ad775', false)) {
|
||||
spl_autoload_call('RectorPrefix20220531\ComposerAutoloaderInit8301977485a4848b0885a70a7d8ad775');
|
||||
}
|
||||
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
|
||||
spl_autoload_call('RectorPrefix20220531\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
@ -56,9 +56,9 @@ if (!function_exists('print_node')) {
|
||||
return \RectorPrefix20220531\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequired0e617c025a4e84ea7b03323d7053dd1')) {
|
||||
function composerRequired0e617c025a4e84ea7b03323d7053dd1() {
|
||||
return \RectorPrefix20220531\composerRequired0e617c025a4e84ea7b03323d7053dd1(...func_get_args());
|
||||
if (!function_exists('composerRequire8301977485a4848b0885a70a7d8ad775')) {
|
||||
function composerRequire8301977485a4848b0885a70a7d8ad775() {
|
||||
return \RectorPrefix20220531\composerRequire8301977485a4848b0885a70a7d8ad775(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
135
vendor/tracy/tracy/src/Tracy/Logger/FireLogger.php
vendored
Normal file
135
vendor/tracy/tracy/src/Tracy/Logger/FireLogger.php
vendored
Normal file
@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Tracy (https://tracy.nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20220531\Tracy;
|
||||
|
||||
/**
|
||||
* FireLogger console logger.
|
||||
*
|
||||
* @see http://firelogger.binaryage.com
|
||||
* @see https://chrome.google.com/webstore/detail/firelogger-for-chrome/hmagilfopmdjkeomnjpchokglfdfjfeh
|
||||
*/
|
||||
class FireLogger implements \RectorPrefix20220531\Tracy\ILogger
|
||||
{
|
||||
/** @var int */
|
||||
public $maxDepth = 3;
|
||||
/** @var int */
|
||||
public $maxLength = 150;
|
||||
/** @var array */
|
||||
private $payload = ['logs' => []];
|
||||
/**
|
||||
* Sends message to FireLogger console.
|
||||
* @param mixed $message
|
||||
*/
|
||||
public function log($message, $level = self::DEBUG) : bool
|
||||
{
|
||||
if (!isset($_SERVER['HTTP_X_FIRELOGGER']) || \headers_sent()) {
|
||||
return \false;
|
||||
}
|
||||
$item = ['name' => 'PHP', 'level' => $level, 'order' => \count($this->payload['logs']), 'time' => \str_pad(\number_format((\microtime(\true) - \RectorPrefix20220531\Tracy\Debugger::$time) * 1000, 1, '.', ' '), 8, '0', \STR_PAD_LEFT) . ' ms', 'template' => '', 'message' => '', 'style' => 'background:#767ab6'];
|
||||
$args = \func_get_args();
|
||||
if (isset($args[0]) && \is_string($args[0])) {
|
||||
$item['template'] = \array_shift($args);
|
||||
}
|
||||
if (isset($args[0]) && $args[0] instanceof \Throwable) {
|
||||
$e = \array_shift($args);
|
||||
$trace = $e->getTrace();
|
||||
if (isset($trace[0]['class']) && $trace[0]['class'] === \RectorPrefix20220531\Tracy\Debugger::class && ($trace[0]['function'] === 'shutdownHandler' || $trace[0]['function'] === 'errorHandler')) {
|
||||
unset($trace[0]);
|
||||
}
|
||||
$file = \str_replace(\dirname($e->getFile(), 3), "…", $e->getFile());
|
||||
$item['template'] = ($e instanceof \ErrorException ? '' : \RectorPrefix20220531\Tracy\Helpers::getClass($e) . ': ') . $e->getMessage() . ($e->getCode() ? ' #' . $e->getCode() : '') . ' in ' . $file . ':' . $e->getLine();
|
||||
$item['pathname'] = $e->getFile();
|
||||
$item['lineno'] = $e->getLine();
|
||||
} else {
|
||||
$trace = \debug_backtrace();
|
||||
if (isset($trace[1]['class']) && $trace[1]['class'] === \RectorPrefix20220531\Tracy\Debugger::class && $trace[1]['function'] === 'fireLog') {
|
||||
unset($trace[0]);
|
||||
}
|
||||
foreach ($trace as $frame) {
|
||||
if (isset($frame['file']) && \is_file($frame['file'])) {
|
||||
$item['pathname'] = $frame['file'];
|
||||
$item['lineno'] = $frame['line'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$item['exc_info'] = ['', '', []];
|
||||
$item['exc_frames'] = [];
|
||||
foreach ($trace as $frame) {
|
||||
$frame += ['file' => null, 'line' => null, 'class' => null, 'type' => null, 'function' => null, 'object' => null, 'args' => null];
|
||||
$item['exc_info'][2][] = [$frame['file'], $frame['line'], "{$frame['class']}{$frame['type']}{$frame['function']}", $frame['object']];
|
||||
$item['exc_frames'][] = $frame['args'];
|
||||
}
|
||||
if (isset($args[0]) && \in_array($args[0], [self::DEBUG, self::INFO, self::WARNING, self::ERROR, self::CRITICAL], \true)) {
|
||||
$item['level'] = \array_shift($args);
|
||||
}
|
||||
$item['args'] = $args;
|
||||
$this->payload['logs'][] = $this->jsonDump($item, -1);
|
||||
foreach (\str_split(\base64_encode(\json_encode($this->payload, \JSON_INVALID_UTF8_SUBSTITUTE)), 4990) as $k => $v) {
|
||||
\header("FireLogger-de11e-{$k}: {$v}");
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
/**
|
||||
* Dump implementation for JSON.
|
||||
* @param mixed $var
|
||||
* @return array|int|float|bool|string|null
|
||||
*/
|
||||
private function jsonDump(&$var, int $level = 0)
|
||||
{
|
||||
if (\is_bool($var) || $var === null || \is_int($var) || \is_float($var)) {
|
||||
return $var;
|
||||
} elseif (\is_string($var)) {
|
||||
$var = \RectorPrefix20220531\Tracy\Helpers::encodeString($var, $this->maxLength);
|
||||
return \htmlspecialchars_decode(\strip_tags($var));
|
||||
} elseif (\is_array($var)) {
|
||||
static $marker;
|
||||
if ($marker === null) {
|
||||
$marker = \uniqid("\0", \true);
|
||||
}
|
||||
if (isset($var[$marker])) {
|
||||
return "…RECURSION…";
|
||||
} elseif ($level < $this->maxDepth || !$this->maxDepth) {
|
||||
$var[$marker] = \true;
|
||||
$res = [];
|
||||
foreach ($var as $k => &$v) {
|
||||
if ($k !== $marker) {
|
||||
$res[$this->jsonDump($k)] = $this->jsonDump($v, $level + 1);
|
||||
}
|
||||
}
|
||||
unset($var[$marker]);
|
||||
return $res;
|
||||
} else {
|
||||
return " … ";
|
||||
}
|
||||
} elseif (\is_object($var)) {
|
||||
$arr = (array) $var;
|
||||
static $list = [];
|
||||
if (\in_array($var, $list, \true)) {
|
||||
return "…RECURSION…";
|
||||
} elseif ($level < $this->maxDepth || !$this->maxDepth) {
|
||||
$list[] = $var;
|
||||
$res = ["\0" => '(object) ' . \RectorPrefix20220531\Tracy\Helpers::getClass($var)];
|
||||
foreach ($arr as $k => &$v) {
|
||||
if (isset($k[0]) && $k[0] === "\0") {
|
||||
$k = \substr($k, \strrpos($k, "\0") + 1);
|
||||
}
|
||||
$res[$this->jsonDump($k)] = $this->jsonDump($v, $level + 1);
|
||||
}
|
||||
\array_pop($list);
|
||||
return $res;
|
||||
} else {
|
||||
return " … ";
|
||||
}
|
||||
} elseif (\is_resource($var)) {
|
||||
return 'resource ' . \get_resource_type($var);
|
||||
} else {
|
||||
return 'unknown type';
|
||||
}
|
||||
}
|
||||
}
|
17
vendor/tracy/tracy/src/Tracy/Logger/ILogger.php
vendored
Normal file
17
vendor/tracy/tracy/src/Tracy/Logger/ILogger.php
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Tracy (https://tracy.nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20220531\Tracy;
|
||||
|
||||
/**
|
||||
* Logger.
|
||||
*/
|
||||
interface ILogger
|
||||
{
|
||||
public const DEBUG = 'debug', INFO = 'info', WARNING = 'warning', ERROR = 'error', EXCEPTION = 'exception', CRITICAL = 'critical';
|
||||
function log($value, $level = self::INFO);
|
||||
}
|
136
vendor/tracy/tracy/src/Tracy/Logger/Logger.php
vendored
Normal file
136
vendor/tracy/tracy/src/Tracy/Logger/Logger.php
vendored
Normal file
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Tracy (https://tracy.nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20220531\Tracy;
|
||||
|
||||
/**
|
||||
* Logger.
|
||||
*/
|
||||
class Logger implements \RectorPrefix20220531\Tracy\ILogger
|
||||
{
|
||||
/** @var string|null name of the directory where errors should be logged */
|
||||
public $directory;
|
||||
/** @var string|array|null email or emails to which send error notifications */
|
||||
public $email;
|
||||
/** @var string|null sender of email notifications */
|
||||
public $fromEmail;
|
||||
/** @var mixed interval for sending email is 2 days */
|
||||
public $emailSnooze = '2 days';
|
||||
/** @var callable handler for sending emails */
|
||||
public $mailer;
|
||||
/** @var BlueScreen|null */
|
||||
private $blueScreen;
|
||||
/**
|
||||
* @param string|array|null $email
|
||||
*/
|
||||
public function __construct(?string $directory, $email = null, ?\RectorPrefix20220531\Tracy\BlueScreen $blueScreen = null)
|
||||
{
|
||||
$this->directory = $directory;
|
||||
$this->email = $email;
|
||||
$this->blueScreen = $blueScreen;
|
||||
$this->mailer = [$this, 'defaultMailer'];
|
||||
}
|
||||
/**
|
||||
* Logs message or exception to file and sends email notification.
|
||||
* @param mixed $message
|
||||
* @param string $level one of constant ILogger::INFO, WARNING, ERROR (sends email), EXCEPTION (sends email), CRITICAL (sends email)
|
||||
* @return string|null logged error filename
|
||||
*/
|
||||
public function log($message, $level = self::INFO)
|
||||
{
|
||||
if (!$this->directory) {
|
||||
throw new \LogicException('Logging directory is not specified.');
|
||||
} elseif (!\is_dir($this->directory)) {
|
||||
throw new \RuntimeException("Logging directory '{$this->directory}' is not found or is not directory.");
|
||||
}
|
||||
$exceptionFile = $message instanceof \Throwable ? $this->getExceptionFile($message, $level) : null;
|
||||
$line = static::formatLogLine($message, $exceptionFile);
|
||||
$file = $this->directory . '/' . \strtolower($level ?: self::INFO) . '.log';
|
||||
if (!@\file_put_contents($file, $line . \PHP_EOL, \FILE_APPEND | \LOCK_EX)) {
|
||||
// @ is escalated to exception
|
||||
throw new \RuntimeException("Unable to write to log file '{$file}'. Is directory writable?");
|
||||
}
|
||||
if ($exceptionFile) {
|
||||
$this->logException($message, $exceptionFile);
|
||||
}
|
||||
if (\in_array($level, [self::ERROR, self::EXCEPTION, self::CRITICAL], \true)) {
|
||||
$this->sendEmail($message);
|
||||
}
|
||||
return $exceptionFile;
|
||||
}
|
||||
/**
|
||||
* @param mixed $message
|
||||
*/
|
||||
public static function formatMessage($message) : string
|
||||
{
|
||||
if ($message instanceof \Throwable) {
|
||||
foreach (\RectorPrefix20220531\Tracy\Helpers::getExceptionChain($message) as $exception) {
|
||||
$tmp[] = ($exception instanceof \ErrorException ? \RectorPrefix20220531\Tracy\Helpers::errorTypeToString($exception->getSeverity()) . ': ' . $exception->getMessage() : \RectorPrefix20220531\Tracy\Helpers::getClass($exception) . ': ' . $exception->getMessage() . ($exception->getCode() ? ' #' . $exception->getCode() : '')) . ' in ' . $exception->getFile() . ':' . $exception->getLine();
|
||||
}
|
||||
$message = \implode("\ncaused by ", $tmp);
|
||||
} elseif (!\is_string($message)) {
|
||||
$message = \RectorPrefix20220531\Tracy\Dumper::toText($message);
|
||||
}
|
||||
return \trim($message);
|
||||
}
|
||||
/**
|
||||
* @param mixed $message
|
||||
*/
|
||||
public static function formatLogLine($message, ?string $exceptionFile = null) : string
|
||||
{
|
||||
return \implode(' ', [\date('[Y-m-d H-i-s]'), \preg_replace('#\\s*\\r?\\n\\s*#', ' ', static::formatMessage($message)), ' @ ' . \RectorPrefix20220531\Tracy\Helpers::getSource(), $exceptionFile ? ' @@ ' . \basename($exceptionFile) : null]);
|
||||
}
|
||||
public function getExceptionFile(\Throwable $exception, string $level = self::EXCEPTION) : string
|
||||
{
|
||||
foreach (\RectorPrefix20220531\Tracy\Helpers::getExceptionChain($exception) as $exception) {
|
||||
$data[] = [\get_class($exception), $exception->getMessage(), $exception->getCode(), $exception->getFile(), $exception->getLine(), \array_map(function (array $item) : array {
|
||||
unset($item['args']);
|
||||
return $item;
|
||||
}, $exception->getTrace())];
|
||||
}
|
||||
$hash = \substr(\md5(\serialize($data)), 0, 10);
|
||||
$dir = \strtr($this->directory . '/', '\\/', \DIRECTORY_SEPARATOR . \DIRECTORY_SEPARATOR);
|
||||
foreach (new \DirectoryIterator($this->directory) as $file) {
|
||||
if (\strpos($file->getBasename(), $hash)) {
|
||||
return $dir . $file;
|
||||
}
|
||||
}
|
||||
return $dir . $level . '--' . \date('Y-m-d--H-i') . "--{$hash}.html";
|
||||
}
|
||||
/**
|
||||
* Logs exception to the file if file doesn't exist.
|
||||
* @return string logged error filename
|
||||
*/
|
||||
protected function logException(\Throwable $exception, ?string $file = null) : string
|
||||
{
|
||||
$file = $file ?: $this->getExceptionFile($exception);
|
||||
$bs = $this->blueScreen ?: new \RectorPrefix20220531\Tracy\BlueScreen();
|
||||
$bs->renderToFile($exception, $file);
|
||||
return $file;
|
||||
}
|
||||
/**
|
||||
* @param mixed $message
|
||||
*/
|
||||
protected function sendEmail($message) : void
|
||||
{
|
||||
$snooze = \is_numeric($this->emailSnooze) ? $this->emailSnooze : \strtotime($this->emailSnooze) - \time();
|
||||
if ($this->email && $this->mailer && @\filemtime($this->directory . '/email-sent') + $snooze < \time() && @\file_put_contents($this->directory . '/email-sent', 'sent')) {
|
||||
($this->mailer)($message, \implode(', ', (array) $this->email));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Default mailer.
|
||||
* @param mixed $message
|
||||
* @internal
|
||||
*/
|
||||
public function defaultMailer($message, string $email) : void
|
||||
{
|
||||
$host = \preg_replace('#[^\\w.-]+#', '', $_SERVER['SERVER_NAME'] ?? \php_uname('n'));
|
||||
$parts = \str_replace(["\r\n", "\n"], ["\n", \PHP_EOL], ['headers' => \implode("\n", ['From: ' . ($this->fromEmail ?: "noreply@{$host}"), 'X-Mailer: Tracy', 'Content-Type: text/plain; charset=UTF-8', 'Content-Transfer-Encoding: 8bit']) . "\n", 'subject' => "PHP: An error occurred on the server {$host}", 'body' => static::formatMessage($message) . "\n\nsource: " . \RectorPrefix20220531\Tracy\Helpers::getSource()]);
|
||||
\mail($email, $parts['subject'], $parts['body'], $parts['headers']);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user