Updated Rector to commit 34844eb659

34844eb659 Fix code sample (#1299)
This commit is contained in:
Tomas Votruba 2021-11-24 19:57:13 +00:00
parent 00645c017c
commit b1b89512db
35 changed files with 217 additions and 106 deletions

View File

@ -36,7 +36,7 @@ final class UseClassKeywordForClassNameResolutionRector extends \Rector\Core\Rec
$value = 'App\SomeClass::someMethod()';
CODE_SAMPLE
, <<<'CODE_SAMPLE'
$value = \App\SomeClass . '::someMethod()';
$value = \App\SomeClass::class . '::someMethod()';
CODE_SAMPLE
)]);
}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '0e96615c363cc0c29834f10461e16d25e74122e4';
public const PACKAGE_VERSION = '34844eb6595649ef99a1e0932d39579ab69eba88';
/**
* @var string
*/
public const RELEASE_DATE = '2021-11-24 11:44:29';
public const RELEASE_DATE = '2021-11-24 20:43:20';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20211124\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitf542c9f5af46b9260baea83ea16f5ea3::getLoader();
return ComposerAutoloaderInit003ef056afe1f26afc02b5a74a9bc826::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitf542c9f5af46b9260baea83ea16f5ea3
class ComposerAutoloaderInit003ef056afe1f26afc02b5a74a9bc826
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInitf542c9f5af46b9260baea83ea16f5ea3
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitf542c9f5af46b9260baea83ea16f5ea3', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit003ef056afe1f26afc02b5a74a9bc826', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInitf542c9f5af46b9260baea83ea16f5ea3', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit003ef056afe1f26afc02b5a74a9bc826', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitf542c9f5af46b9260baea83ea16f5ea3::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit003ef056afe1f26afc02b5a74a9bc826::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInitf542c9f5af46b9260baea83ea16f5ea3
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInitf542c9f5af46b9260baea83ea16f5ea3::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit003ef056afe1f26afc02b5a74a9bc826::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequiref542c9f5af46b9260baea83ea16f5ea3($fileIdentifier, $file);
composerRequire003ef056afe1f26afc02b5a74a9bc826($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequiref542c9f5af46b9260baea83ea16f5ea3($fileIdentifier, $file)
function composerRequire003ef056afe1f26afc02b5a74a9bc826($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInitf542c9f5af46b9260baea83ea16f5ea3
class ComposerStaticInit003ef056afe1f26afc02b5a74a9bc826
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -3766,9 +3766,9 @@ class ComposerStaticInitf542c9f5af46b9260baea83ea16f5ea3
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitf542c9f5af46b9260baea83ea16f5ea3::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitf542c9f5af46b9260baea83ea16f5ea3::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitf542c9f5af46b9260baea83ea16f5ea3::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit003ef056afe1f26afc02b5a74a9bc826::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit003ef056afe1f26afc02b5a74a9bc826::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit003ef056afe1f26afc02b5a74a9bc826::$classMap;
}, null, ClassLoader::class);
}

View File

@ -797,17 +797,17 @@
},
{
"name": "nette\/utils",
"version": "v3.2.5",
"version_normalized": "3.2.5.0",
"version": "v3.2.6",
"version_normalized": "3.2.6.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/nette\/utils.git",
"reference": "9cd80396ca58d7969ab44fc7afcf03624dfa526e"
"reference": "2f261e55bd6a12057442045bf2c249806abc1d02"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/nette\/utils\/zipball\/9cd80396ca58d7969ab44fc7afcf03624dfa526e",
"reference": "9cd80396ca58d7969ab44fc7afcf03624dfa526e",
"url": "https:\/\/api.github.com\/repos\/nette\/utils\/zipball\/2f261e55bd6a12057442045bf2c249806abc1d02",
"reference": "2f261e55bd6a12057442045bf2c249806abc1d02",
"shasum": ""
},
"require": {
@ -818,7 +818,7 @@
},
"require-dev": {
"nette\/tester": "~2.0",
"phpstan\/phpstan": "^0.12",
"phpstan\/phpstan": "^1.0",
"tracy\/tracy": "^2.3"
},
"suggest": {
@ -830,7 +830,7 @@
"ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()",
"ext-xml": "to use Strings::length() etc. when mbstring is not available"
},
"time": "2021-09-20T10:50:11+00:00",
"time": "2021-11-24T15:47:23+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -879,7 +879,7 @@
],
"support": {
"issues": "https:\/\/github.com\/nette\/utils\/issues",
"source": "https:\/\/github.com\/nette\/utils\/tree\/v3.2.5"
"source": "https:\/\/github.com\/nette\/utils\/tree\/v3.2.6"
},
"install-path": "..\/nette\/utils"
},
@ -5334,17 +5334,17 @@
},
{
"name": "tracy\/tracy",
"version": "v2.8.8",
"version_normalized": "2.8.8.0",
"version": "v2.8.9",
"version_normalized": "2.8.9.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/nette\/tracy.git",
"reference": "1a18df64f6b745962e9a0bdf87eccfc62309e593"
"reference": "81c769040cd0396eabed3c6d5cebe68399531c7b"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/nette\/tracy\/zipball\/1a18df64f6b745962e9a0bdf87eccfc62309e593",
"reference": "1a18df64f6b745962e9a0bdf87eccfc62309e593",
"url": "https:\/\/api.github.com\/repos\/nette\/tracy\/zipball\/81c769040cd0396eabed3c6d5cebe68399531c7b",
"reference": "81c769040cd0396eabed3c6d5cebe68399531c7b",
"shasum": ""
},
"require": {
@ -5361,10 +5361,10 @@
"nette\/mail": "^3.0",
"nette\/tester": "^2.2",
"nette\/utils": "^3.0",
"phpstan\/phpstan": "^0.12",
"phpstan\/phpstan": "^1.0",
"psr\/log": "^1.0 || ^2.0 || ^3.0"
},
"time": "2021-11-08T23:40:20+00:00",
"time": "2021-11-24T16:04:35+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -5405,7 +5405,7 @@
],
"support": {
"issues": "https:\/\/github.com\/nette\/tracy\/issues",
"source": "https:\/\/github.com\/nette\/tracy\/tree\/v2.8.8"
"source": "https:\/\/github.com\/nette\/tracy\/tree\/v2.8.9"
},
"install-path": "..\/tracy\/tracy"
},

File diff suppressed because one or more lines are too long

View File

@ -39,7 +39,7 @@
"require-dev": {
"nette\/tester": "~2.0",
"tracy\/tracy": "^2.3",
"phpstan\/phpstan": "^0.12"
"phpstan\/phpstan": "^1.0"
},
"conflict": {
"nette\/di": "<3.0.6"

View File

@ -12,7 +12,10 @@ namespace RectorPrefix20211124\Nette;
*/
trait StaticClass
{
/** @throws \Error */
/**
* @return never
* @throws \Error
*/
public final function __construct()
{
throw new \Error('Class ' . static::class . ' is static and cannot be instantiated.');

View File

@ -139,9 +139,10 @@ final class Callback
}
/**
* Unwraps closure created by Closure::fromCallable().
* @return callable|array
* @param \Closure $closure
*/
public static function unwrap($closure) : callable
public static function unwrap($closure)
{
$r = new \ReflectionFunction($closure);
if (\substr($r->name, -1) === '}') {

View File

@ -24,7 +24,7 @@ final class FileSystem
{
if (!\is_dir($dir) && !@\mkdir($dir, $mode, \true) && !\is_dir($dir)) {
// @ - dir may already exist
throw new \RectorPrefix20211124\Nette\IOException("Unable to create directory '{$dir}' with mode " . \decoct($mode) . '. ' . \RectorPrefix20211124\Nette\Utils\Helpers::getLastError());
throw new \RectorPrefix20211124\Nette\IOException(\sprintf("Unable to create directory '%s' with mode %s. %s", self::normalizePath($dir), \decoct($mode), \RectorPrefix20211124\Nette\Utils\Helpers::getLastError()));
}
}
/**
@ -38,9 +38,9 @@ final class FileSystem
public static function copy($origin, $target, $overwrite = \true) : void
{
if (\stream_is_local($origin) && !\file_exists($origin)) {
throw new \RectorPrefix20211124\Nette\IOException("File or directory '{$origin}' not found.");
throw new \RectorPrefix20211124\Nette\IOException(\sprintf("File or directory '%s' not found.", self::normalizePath($origin)));
} elseif (!$overwrite && \file_exists($target)) {
throw new \RectorPrefix20211124\Nette\InvalidStateException("File or directory '{$target}' already exists.");
throw new \RectorPrefix20211124\Nette\InvalidStateException(\sprintf("File or directory '%s' already exists.", self::normalizePath($target)));
} elseif (\is_dir($origin)) {
static::createDir($target);
foreach (new \FilesystemIterator($target) as $item) {
@ -57,7 +57,7 @@ final class FileSystem
static::createDir(\dirname($target));
if (($s = @\fopen($origin, 'rb')) && ($d = @\fopen($target, 'wb')) && @\stream_copy_to_stream($s, $d) === \false) {
// @ is escalated to exception
throw new \RectorPrefix20211124\Nette\IOException("Unable to copy file '{$origin}' to '{$target}'. " . \RectorPrefix20211124\Nette\Utils\Helpers::getLastError());
throw new \RectorPrefix20211124\Nette\IOException(\sprintf("Unable to copy file '%s' to '%s'. %s", self::normalizePath($origin), self::normalizePath($target), \RectorPrefix20211124\Nette\Utils\Helpers::getLastError()));
}
}
}
@ -72,7 +72,7 @@ final class FileSystem
$func = \DIRECTORY_SEPARATOR === '\\' && \is_dir($path) ? 'rmdir' : 'unlink';
if (!@$func($path)) {
// @ is escalated to exception
throw new \RectorPrefix20211124\Nette\IOException("Unable to delete '{$path}'. " . \RectorPrefix20211124\Nette\Utils\Helpers::getLastError());
throw new \RectorPrefix20211124\Nette\IOException(\sprintf("Unable to delete '%s'. %s", self::normalizePath($path), \RectorPrefix20211124\Nette\Utils\Helpers::getLastError()));
}
} elseif (\is_dir($path)) {
foreach (new \FilesystemIterator($path) as $item) {
@ -80,7 +80,7 @@ final class FileSystem
}
if (!@\rmdir($path)) {
// @ is escalated to exception
throw new \RectorPrefix20211124\Nette\IOException("Unable to delete directory '{$path}'. " . \RectorPrefix20211124\Nette\Utils\Helpers::getLastError());
throw new \RectorPrefix20211124\Nette\IOException(\sprintf("Unable to delete directory '%s'. %s", self::normalizePath($path), \RectorPrefix20211124\Nette\Utils\Helpers::getLastError()));
}
}
}
@ -95,9 +95,9 @@ final class FileSystem
public static function rename($origin, $target, $overwrite = \true) : void
{
if (!$overwrite && \file_exists($target)) {
throw new \RectorPrefix20211124\Nette\InvalidStateException("File or directory '{$target}' already exists.");
throw new \RectorPrefix20211124\Nette\InvalidStateException(\sprintf("File or directory '%s' already exists.", self::normalizePath($target)));
} elseif (!\file_exists($origin)) {
throw new \RectorPrefix20211124\Nette\IOException("File or directory '{$origin}' not found.");
throw new \RectorPrefix20211124\Nette\IOException(\sprintf("File or directory '%s' not found.", self::normalizePath($origin)));
} else {
static::createDir(\dirname($target));
if (\realpath($origin) !== \realpath($target)) {
@ -105,7 +105,7 @@ final class FileSystem
}
if (!@\rename($origin, $target)) {
// @ is escalated to exception
throw new \RectorPrefix20211124\Nette\IOException("Unable to rename file or directory '{$origin}' to '{$target}'. " . \RectorPrefix20211124\Nette\Utils\Helpers::getLastError());
throw new \RectorPrefix20211124\Nette\IOException(\sprintf("Unable to rename file or directory '%s' to '%s'. %s", self::normalizePath($origin), self::normalizePath($target), \RectorPrefix20211124\Nette\Utils\Helpers::getLastError()));
}
}
}
@ -119,7 +119,7 @@ final class FileSystem
$content = @\file_get_contents($file);
// @ is escalated to exception
if ($content === \false) {
throw new \RectorPrefix20211124\Nette\IOException("Unable to read file '{$file}'. " . \RectorPrefix20211124\Nette\Utils\Helpers::getLastError());
throw new \RectorPrefix20211124\Nette\IOException(\sprintf("Unable to read file '%s'. %s", self::normalizePath($file), \RectorPrefix20211124\Nette\Utils\Helpers::getLastError()));
}
return $content;
}
@ -135,11 +135,11 @@ final class FileSystem
static::createDir(\dirname($file));
if (@\file_put_contents($file, $content) === \false) {
// @ is escalated to exception
throw new \RectorPrefix20211124\Nette\IOException("Unable to write file '{$file}'. " . \RectorPrefix20211124\Nette\Utils\Helpers::getLastError());
throw new \RectorPrefix20211124\Nette\IOException(\sprintf("Unable to write file '%s'. %s", self::normalizePath($file), \RectorPrefix20211124\Nette\Utils\Helpers::getLastError()));
}
if ($mode !== null && !@\chmod($file, $mode)) {
// @ is escalated to exception
throw new \RectorPrefix20211124\Nette\IOException("Unable to chmod file '{$file}' to mode " . \decoct($mode) . '. ' . \RectorPrefix20211124\Nette\Utils\Helpers::getLastError());
throw new \RectorPrefix20211124\Nette\IOException(\sprintf("Unable to chmod file '%s' to mode %s. %s", self::normalizePath($file), \decoct($mode), \RectorPrefix20211124\Nette\Utils\Helpers::getLastError()));
}
}
/**
@ -154,7 +154,7 @@ final class FileSystem
if (\is_file($path)) {
if (!@\chmod($path, $fileMode)) {
// @ is escalated to exception
throw new \RectorPrefix20211124\Nette\IOException("Unable to chmod file '{$path}' to mode " . \decoct($fileMode) . '. ' . \RectorPrefix20211124\Nette\Utils\Helpers::getLastError());
throw new \RectorPrefix20211124\Nette\IOException(\sprintf("Unable to chmod file '%s' to mode %s. %s", self::normalizePath($path), \decoct($fileMode), \RectorPrefix20211124\Nette\Utils\Helpers::getLastError()));
}
} elseif (\is_dir($path)) {
foreach (new \FilesystemIterator($path) as $item) {
@ -162,10 +162,10 @@ final class FileSystem
}
if (!@\chmod($path, $dirMode)) {
// @ is escalated to exception
throw new \RectorPrefix20211124\Nette\IOException("Unable to chmod directory '{$path}' to mode " . \decoct($dirMode) . '. ' . \RectorPrefix20211124\Nette\Utils\Helpers::getLastError());
throw new \RectorPrefix20211124\Nette\IOException(\sprintf("Unable to chmod directory '%s' to mode %s. %s", self::normalizePath($path), \decoct($dirMode), \RectorPrefix20211124\Nette\Utils\Helpers::getLastError()));
}
} else {
throw new \RectorPrefix20211124\Nette\IOException("File or directory '{$path}' not found.");
throw new \RectorPrefix20211124\Nette\IOException(\sprintf("File or directory '%s' not found.", self::normalizePath($path)));
}
}
/**

View File

@ -45,6 +45,20 @@ class Helpers
{
return $value === \false ? null : $value;
}
/**
* Returns value clamped to the inclusive range of min and max.
* @param int|float $value
* @param int|float $min
* @param int|float $max
* @return int|float
*/
public static function clamp($value, $min, $max)
{
if ($min > $max) {
throw new \InvalidArgumentException("Minimum ({$min}) is not less than maximum ({$max}).");
}
return \min(\max($value, $min), $max);
}
/**
* Looks for a string from possibilities that is most similar to value, but not the same (for 8-bit encoding).
* @param string[] $possibilities

View File

@ -15,9 +15,12 @@ use RectorPrefix20211124\Nette\MemberAccessException;
final class ObjectHelpers
{
use Nette\StaticClass;
/** @throws MemberAccessException
/**
* @return never
* @throws MemberAccessException
* @param string $class
* @param string $name */
* @param string $name
*/
public static function strictGet($class, $name) : void
{
$rc = new \ReflectionClass($class);
@ -26,9 +29,12 @@ final class ObjectHelpers
}), self::parseFullDoc($rc, '~^[ \\t*]*@property(?:-read)?[ \\t]+(?:\\S+[ \\t]+)??\\$(\\w+)~m')), $name);
throw new \RectorPrefix20211124\Nette\MemberAccessException("Cannot read an undeclared property {$class}::\${$name}" . ($hint ? ", did you mean \${$hint}?" : '.'));
}
/** @throws MemberAccessException
/**
* @return never
* @throws MemberAccessException
* @param string $class
* @param string $name */
* @param string $name
*/
public static function strictSet($class, $name) : void
{
$rc = new \ReflectionClass($class);
@ -37,10 +43,13 @@ final class ObjectHelpers
}), self::parseFullDoc($rc, '~^[ \\t*]*@property(?:-write)?[ \\t]+(?:\\S+[ \\t]+)??\\$(\\w+)~m')), $name);
throw new \RectorPrefix20211124\Nette\MemberAccessException("Cannot write to an undeclared property {$class}::\${$name}" . ($hint ? ", did you mean \${$hint}?" : '.'));
}
/** @throws MemberAccessException
/**
* @return never
* @throws MemberAccessException
* @param string $class
* @param string $method
* @param mixed[] $additionalMethods */
* @param mixed[] $additionalMethods
*/
public static function strictCall($class, $method, $additionalMethods = []) : void
{
$trace = \debug_backtrace(0, 3);
@ -60,9 +69,12 @@ final class ObjectHelpers
throw new \RectorPrefix20211124\Nette\MemberAccessException("Call to undefined method {$class}::{$method}()" . ($hint ? ", did you mean {$hint}()?" : '.'));
}
}
/** @throws MemberAccessException
/**
* @return never
* @throws MemberAccessException
* @param string $class
* @param string $method */
* @param string $method
*/
public static function strictStaticCall($class, $method) : void
{
$trace = \debug_backtrace(0, 3);

View File

@ -15,6 +15,7 @@ final class Reflection
{
use Nette\StaticClass;
private const BUILTIN_TYPES = ['string' => 1, 'int' => 1, 'float' => 1, 'bool' => 1, 'array' => 1, 'object' => 1, 'callable' => 1, 'iterable' => 1, 'void' => 1, 'null' => 1, 'mixed' => 1, 'false' => 1, 'never' => 1];
private const CLASS_KEYWORDS = ['self' => 1, 'parent' => 1, 'static' => 1];
/**
* Determines if type is PHP built-in type. Otherwise, it is the class name.
* @param string $type
@ -23,6 +24,14 @@ final class Reflection
{
return isset(self::BUILTIN_TYPES[\strtolower($type)]);
}
/**
* Determines if type is special class name self/parent/static.
* @param string $name
*/
public static function isClassKeyword($name) : bool
{
return isset(self::CLASS_KEYWORDS[\strtolower($name)]);
}
/**
* Returns the type of return value of given function or method and normalizes `self`, `static`, and `parent` to actual class names.
* If the function does not have a return type, it returns null.
@ -206,6 +215,8 @@ final class Reflection
return $lower;
} elseif ($lower === 'self' || $lower === 'static') {
return $context->name;
} elseif ($lower === 'parent') {
return $context->getParentClass() ? $context->getParentClass()->name : 'parent';
} elseif ($name[0] === '\\') {
// fully qualified name
return \ltrim($name, '\\');

View File

@ -431,6 +431,8 @@ class Strings
$len = \strlen($haystack);
if ($needle === '') {
return $len;
} elseif ($len === 0) {
return null;
}
$pos = $len - 1;
while (($pos = \strrpos($haystack, $needle, $pos - $len)) !== \false && ++$nth) {
@ -440,8 +442,8 @@ class Strings
return \RectorPrefix20211124\Nette\Utils\Helpers::falseToNull($pos);
}
/**
* Splits a string into array by the regular expression.
* Argument $flag takes same arguments as preg_split(), but PREG_SPLIT_DELIM_CAPTURE is set by default.
* Splits a string into array by the regular expression. Parenthesized expression in the delimiter are captured.
* Parameter $flags can be any combination of PREG_SPLIT_NO_EMPTY and PREG_OFFSET_CAPTURE flags.
* @param string $subject
* @param string $pattern
* @param int $flags
@ -452,7 +454,7 @@ class Strings
}
/**
* Checks if given string matches a regular expression pattern and returns an array with first found match and each subpattern.
* Argument $flag takes same arguments as function preg_match().
* Parameter $flags can be any combination of PREG_OFFSET_CAPTURE and PREG_UNMATCHED_AS_NULL flags.
* @param string $subject
* @param string $pattern
* @param int $flags
@ -466,8 +468,8 @@ class Strings
return self::pcre('preg_match', [$pattern, $subject, &$m, $flags, $offset]) ? $m : null;
}
/**
* Finds all occurrences matching regular expression pattern and returns a two-dimensional array.
* Argument $flag takes same arguments as function preg_match_all(), but PREG_SET_ORDER is set by default.
* Finds all occurrences matching regular expression pattern and returns a two-dimensional array. Result is array of matches (ie uses by default PREG_SET_ORDER).
* Parameter $flags can be any combination of PREG_OFFSET_CAPTURE, PREG_UNMATCHED_AS_NULL and PREG_PATTERN_ORDER flags.
* @param string $subject
* @param string $pattern
* @param int $flags

View File

@ -159,6 +159,13 @@ final class Type
{
return $this->single && !\RectorPrefix20211124\Nette\Utils\Reflection::isBuiltinType($this->types[0]);
}
/**
* Determines if type is special class name self/parent/static.
*/
public function isClassKeyword() : bool
{
return $this->single && \RectorPrefix20211124\Nette\Utils\Reflection::isClassKeyword($this->types[0]);
}
/**
* Verifies type compatibility. For example, it checks if a value of a certain type could be passed as a parameter.
* @param string $type

View File

@ -318,6 +318,6 @@ XX
*/
public static function isPhpIdentifier($value) : bool
{
return \is_string($value) && \preg_match('#^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$#D', $value);
return \preg_match('#^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$#D', $value) === 1;
}
}

View File

@ -12,8 +12,8 @@ if (!class_exists('GenerateChangelogCommand', false) && !interface_exists('Gener
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20211124\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInitf542c9f5af46b9260baea83ea16f5ea3', false) && !interface_exists('ComposerAutoloaderInitf542c9f5af46b9260baea83ea16f5ea3', false) && !trait_exists('ComposerAutoloaderInitf542c9f5af46b9260baea83ea16f5ea3', false)) {
spl_autoload_call('RectorPrefix20211124\ComposerAutoloaderInitf542c9f5af46b9260baea83ea16f5ea3');
if (!class_exists('ComposerAutoloaderInit003ef056afe1f26afc02b5a74a9bc826', false) && !interface_exists('ComposerAutoloaderInit003ef056afe1f26afc02b5a74a9bc826', false) && !trait_exists('ComposerAutoloaderInit003ef056afe1f26afc02b5a74a9bc826', false)) {
spl_autoload_call('RectorPrefix20211124\ComposerAutoloaderInit003ef056afe1f26afc02b5a74a9bc826');
}
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('RectorPrefix20211124\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -81,9 +81,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20211124\print_node(...func_get_args());
}
}
if (!function_exists('composerRequiref542c9f5af46b9260baea83ea16f5ea3')) {
function composerRequiref542c9f5af46b9260baea83ea16f5ea3() {
return \RectorPrefix20211124\composerRequiref542c9f5af46b9260baea83ea16f5ea3(...func_get_args());
if (!function_exists('composerRequire003ef056afe1f26afc02b5a74a9bc826')) {
function composerRequire003ef056afe1f26afc02b5a74a9bc826() {
return \RectorPrefix20211124\composerRequire003ef056afe1f26afc02b5a74a9bc826(...func_get_args());
}
}
if (!function_exists('parseArgs')) {

View File

@ -34,7 +34,7 @@
"nette\/tester": "^2.2",
"latte\/latte": "^2.5",
"psr\/log": "^1.0 || ^2.0 || ^3.0",
"phpstan\/phpstan": "^0.12"
"phpstan\/phpstan": "^1.0"
},
"conflict": {
"nette\/di": "<3.0"

View File

@ -20,8 +20,10 @@ class Bridge
public static function initialize() : void
{
$blueScreen = \RectorPrefix20211124\Tracy\Debugger::getBlueScreen();
$blueScreen->addPanel([self::class, 'renderLatteError']);
$blueScreen->addAction([self::class, 'renderLatteUnknownMacro']);
if (!\class_exists(\RectorPrefix20211124\Latte\Bridges\Tracy\BlueScreenPanel::class)) {
$blueScreen->addPanel([self::class, 'renderLatteError']);
$blueScreen->addAction([self::class, 'renderLatteUnknownMacro']);
}
$blueScreen->addAction([self::class, 'renderMemberAccessException']);
$blueScreen->addPanel([self::class, 'renderNeonError']);
}
@ -75,10 +77,14 @@ class Bridge
*/
public static function renderNeonError($e) : ?array
{
if ($e instanceof \RectorPrefix20211124\Nette\Neon\Exception && \preg_match('#line (\\d+)#', $e->getMessage(), $m) && ($trace = \RectorPrefix20211124\Tracy\Helpers::findTrace($e->getTrace(), [\RectorPrefix20211124\Nette\Neon\Decoder::class, 'decode']))) {
return ['tab' => 'NEON', 'panel' => ($trace2 = \RectorPrefix20211124\Tracy\Helpers::findTrace($e->getTrace(), [\RectorPrefix20211124\Nette\DI\Config\Adapters\NeonAdapter::class, 'load'])) ? '<p><b>File:</b> ' . \RectorPrefix20211124\Tracy\Helpers::editorLink($trace2['args'][0], (int) $m[1]) . '</p>' . self::highlightNeon(\file_get_contents($trace2['args'][0]), (int) $m[1]) : self::highlightNeon($trace['args'][0], (int) $m[1])];
if (!$e instanceof \RectorPrefix20211124\Nette\Neon\Exception || !\preg_match('#line (\\d+)#', $e->getMessage(), $m)) {
return null;
} elseif ($trace = \RectorPrefix20211124\Tracy\Helpers::findTrace($e->getTrace(), [\RectorPrefix20211124\Nette\Neon\Decoder::class, 'decodeFile']) ?? \RectorPrefix20211124\Tracy\Helpers::findTrace($e->getTrace(), [\RectorPrefix20211124\Nette\DI\Config\Adapters\NeonAdapter::class, 'load'])) {
$panel = '<p><b>File:</b> ' . \RectorPrefix20211124\Tracy\Helpers::editorLink($trace['args'][0], (int) $m[1]) . '</p>' . self::highlightNeon(\file_get_contents($trace['args'][0]), (int) $m[1]);
} elseif ($trace = \RectorPrefix20211124\Tracy\Helpers::findTrace($e->getTrace(), [\RectorPrefix20211124\Nette\Neon\Decoder::class, 'decode'])) {
$panel = self::highlightNeon($trace['args'][0], (int) $m[1]);
}
return null;
return isset($panel) ? ['tab' => 'NEON', 'panel' => $panel] : null;
}
private static function highlightNeon(string $code, int $line) : string
{

View File

@ -5,15 +5,16 @@
*
* This file is part of the Tracy (http://tracy.nette.org)
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* @param string $type
* @param array $panels
*/
declare(strict_types=1);
namespace Tracy;
/**
* @var string $type
* @var \stdClass[] $panels
*/
?>
<ul class="tracy-row" data-tracy-group="<?= Helpers::escapeHtml($type) ?>">

View File

@ -13,6 +13,12 @@ declare(strict_types=1);
namespace Tracy;
/**
* @var ?string $nonce
* @var bool $async
* @var string $contentId
*/
$baseUrl = $_SERVER['REQUEST_URI'] ?? '';
$baseUrl .= strpos($baseUrl, '?') === false ? '?' : '&';
$nonceAttr = $nonce ? ' nonce="' . Helpers::escapeHtml($nonce) . '"' : '';

View File

@ -5,9 +5,6 @@
*
* This file is part of the Tracy (http://tracy.nette.org)
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* @param string $type
* @param array $panels
*/
declare(strict_types=1);
@ -16,6 +13,11 @@ namespace Tracy;
use Tracy\Helpers;
/**
* @var string $type
* @var \stdClass[] $panels
*/
$icons = '
<div class="tracy-icons">
<a href="#" data-tracy-action="window" title="open in window">&curren;</a>

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Tracy;
/** @var array[] $data */
?>
<style class="tracy-debug">
#tracy-debug .tracy-DumpPanel h2 {

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Tracy;
/** @var array[] $data */
if (empty($data)) {
return;
}

View File

@ -11,13 +11,14 @@ declare(strict_types=1);
namespace Tracy;
/** @var int[] $data */
?>
<h1>Errors</h1>
<div class="tracy-inner">
<table class="tracy-sortable">
<tr><th>Count</th><th>Error</th></tr>
<?php foreach ($data as $item => $count): list($file, $line, $message) = explode('|', $item, 3) ?>
<?php foreach ($data as $item => $count): [$file, $line, $message] = explode('|', $item, 3) ?>
<tr>
<td class="tracy-right"><?= $count ? "$count\xC3\x97" : '' ?></td>
<td><pre><?= Helpers::escapeHtml($message), ' in ', Helpers::editorLink($file, (int) $line) ?></pre></td>

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Tracy;
/** @var int[] $data */
if (empty($data)) {
return;
}

View File

@ -11,6 +11,8 @@ declare(strict_types=1);
namespace Tracy;
/** @var DefaultBarPanel $this */
if (isset($this->cpuUsage) && $this->time) {
foreach (getrusage() as $key => $val) {
$this->cpuUsage[$key] -= $val;

View File

@ -11,6 +11,8 @@ declare(strict_types=1);
namespace Tracy;
/** @var DefaultBarPanel $this */
$this->time = microtime(true) - Debugger::$time;
?>

View File

@ -99,6 +99,8 @@ class BlueScreen
}
private function renderTemplate(\Throwable $exception, string $template, $toScreen = \true) : void
{
$headersSent = \headers_sent($headersFile, $headersLine);
$obStatus = \RectorPrefix20211124\Tracy\Debugger::$obStatus;
$showEnvironment = $this->showEnvironment && \strpos($exception->getMessage(), 'Allowed memory size') === \false;
$info = \array_filter($this->info);
$source = \RectorPrefix20211124\Tracy\Helpers::getSource();
@ -269,7 +271,7 @@ class BlueScreen
* @param int $line
* @param int $lines
*/
public static function highlightPhpCli($file, $line, $lines = 15) : string
public static function highlightPhpCli($file, $line, $lines = 15) : ?string
{
$source = @\file_get_contents($file);
// @ file may not exist

View File

@ -5,22 +5,30 @@
*
* This file is part of the Tracy (https://tracy.nette.org)
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
*
* @param array $exception
* @param array[] $actions
* @param array $info
* @param string $title
* @param string $source
* @param array $lastError
* @param array $httpHeaders
* @param callable $dump
* @return void
*/
declare(strict_types=1);
namespace Tracy;
/**
* @var \Throwable $exception
* @var array[] $actions
* @var string[] $info
* @var string $title
* @var string $source
* @var ?array $lastError
* @var string[] $httpHeaders
* @var callable $dump
* @var array $snapshot
* @var bool $showEnvironment
* @var BlueScreen $this
* @var bool $headersSent
* @var ?string $headersFile
* @var ?int $headersLine
* @var ?array $obStatus
*/
$code = $exception->getCode() ? ' #' . $exception->getCode() : '';
$exceptions = $exceptions ?? Helpers::getExceptionChain($exception);
@ -82,7 +90,7 @@ $exceptions = $exceptions ?? Helpers::getExceptionChain($exception);
<div class="<?= $collapsed ? 'tracy-collapsed ' : '' ?>inner">
<p><b>File:</b> <?= Helpers::editorLink($ex->getFile(), $ex->getLine()) ?></p>
<?php if (is_file($ex->getFile())): ?><?= self::highlightFile($ex->getFile(), $ex->getLine()) ?><?php endif ?>
<?php if (is_file($ex->getFile())): ?><?= BlueScreen::highlightFile($ex->getFile(), $ex->getLine()) ?><?php endif ?>
</div></div>
@ -111,7 +119,7 @@ $exceptions = $exceptions ?? Helpers::getExceptionChain($exception);
</p>
<?php if (isset($row['file']) && is_file($row['file'])): ?>
<div class="<?php if ($expanded !== $key) echo 'tracy-collapsed ' ?>file"><?= self::highlightFile($row['file'], $row['line']) ?></div>
<div class="<?php if ($expanded !== $key) echo 'tracy-collapsed ' ?>file"><?= BlueScreen::highlightFile($row['file'], $row['line']) ?></div>
<?php endif ?>
@ -178,9 +186,10 @@ $exceptions = $exceptions ?? Helpers::getExceptionChain($exception);
<div class="tracy-collapsed inner">
<h3><?= Helpers::errorTypeToString($lastError['type']) ?>: <?= Helpers::escapeHtml($lastError['message']) ?></h3>
<p><i>Note: the last muted error may have nothing to do with the thrown exception.</i></p>
<?php if (isset($lastError['file']) && is_file($lastError['file'])): ?>
<p><?= Helpers::editorLink($lastError['file'], $lastError['line']) ?></p>
<div><?= self::highlightFile($lastError['file'], $lastError['line']) ?></div>
<div><?= BlueScreen::highlightFile($lastError['file'], $lastError['line']) ?></div>
<?php else: ?>
<p><i>inner-code</i><?php if (isset($lastError['line'])) echo ':', $lastError['line'] ?></p>
<?php endif ?>
@ -264,6 +273,14 @@ $exceptions = $exceptions ?? Helpers::getExceptionChain($exception);
<div class="outer tracy-collapsed">
<?php $this->renderPhpInfo() ?>
</div>
<?php if ($obStatus): ?>
<h3><a data-tracy-ref="^+" class="tracy-toggle tracy-collapsed">Output buffers status</a></h3>
<div class="outer tracy-collapsed">
<?php echo $dump($obStatus) ?>
</div>
<?php endif ?>
</div></div>
<?php endif ?>
@ -338,6 +355,16 @@ $exceptions = $exceptions ?? Helpers::getExceptionChain($exception);
<?php else: ?>
<p><i>no headers</i></p>
<?php endif ?>
<?php if ($headersSent && $headersFile && @is_file($headersFile)): ?>
<p>Headers have been sent, output started at <?= Helpers::editorLink($headersFile, $headersLine) ?> <a data-tracy-ref="^p + div" class="tracy-toggle tracy-collapsed">source</a></p>
<div class="tracy-collapsed"><?= BlueScreen::highlightFile($headersFile, $headersLine) ?></div>
<?php elseif ($headersSent): ?>
<p>Headers have been sent</p>
<?php else: ?>
<p>Headers were not sent at the time of the exception</p>
<?php endif ?>
</div></div>
<?php endif ?>

View File

@ -5,17 +5,19 @@
*
* This file is part of the Tracy (https://tracy.nette.org)
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
*
* @param array $exception
* @param string $title
* @param string $nonce
* @return void
*/
declare(strict_types=1);
namespace Tracy;
/**
* @var \Throwable $exception
* @var string $title
* @var ?string $nonce
* @var string $css
*/
$code = $exception->getCode() ? ' #' . $exception->getCode() : '';
$nonceAttr = $nonce ? ' nonce="' . Helpers::escapeHtml($nonce) . '"' : '';
$exceptions = Helpers::getExceptionChain($exception);

View File

@ -13,7 +13,7 @@ use ErrorException;
*/
class Debugger
{
public const VERSION = '2.8.8';
public const VERSION = '2.8.9';
/** server modes for Debugger::enable() */
public const DEVELOPMENT = \false, PRODUCTION = \true, DETECT = null;
public const COOKIE_SECRET = 'tracy-debug';
@ -31,6 +31,8 @@ class Debugger
private static $reserved;
/** @var int initial output buffer level */
private static $obLevel;
/** @var ?array output buffer status @internal */
public static $obStatus;
/********************* errors and exceptions reporting ****************d*g**/
/** @var bool|int determines whether any error will cause immediate death in development mode; if integer that it's matched against error severity */
public static $strictMode = \false;
@ -213,6 +215,7 @@ class Debugger
{
$firstTime = (bool) self::$reserved;
self::$reserved = null;
self::$obStatus = \ob_get_status(\true);
if (!\headers_sent()) {
\http_response_code(isset($_SERVER['HTTP_USER_AGENT']) && \strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE ') !== \false ? 503 : 500);
}

View File

@ -2,13 +2,15 @@
/**
* Default error page.
* @param bool $logged
*/
declare(strict_types=1);
namespace Tracy;
/**
* @var bool $logged
*/
?>
<!DOCTYPE html><!-- "' --></textarea></script></style></pre></xmp></a></audio></button></canvas></datalist></details></dialog></iframe></listing></meter></noembed></noframes></noscript></optgroup></option></progress></rp></select></table></template></title></video>
<meta charset="utf-8">

View File

@ -21,10 +21,12 @@ class Helpers
{
$file = \strtr($origFile = $file, \RectorPrefix20211124\Tracy\Debugger::$editorMapping);
if ($editor = self::editorUri($origFile, $line)) {
$file = \strtr($file, '\\', '/');
if (\preg_match('#(^[a-z]:)?/.{1,40}$#i', $file, $m) && \strlen($file) > \strlen($m[0])) {
$file = '...' . $m[0];
$parts = \explode('/', \strtr($file, '\\', '/'));
$file = \array_pop($parts);
while ($parts && \strlen($file) < 42) {
$file = \array_pop($parts) . '/' . $file;
}
$file = ($parts ? '.../' : '') . $file;
$file = \strtr($file, '/', \DIRECTORY_SEPARATOR);
return self::formatHtml('<a href="%" title="%" class="tracy-editor">%<b>%</b>%</a>', $editor, $origFile . ($line ? ":{$line}" : ''), \rtrim(\dirname($file), \DIRECTORY_SEPARATOR) . \DIRECTORY_SEPARATOR, \basename($file), $line ? ":{$line}" : '');
} else {