mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-31 08:20:53 +00:00
Updated Rector to commit d68bc4ccf6fca72f748cb3b9b80264901094b3d6
d68bc4ccf6
bump deps
This commit is contained in:
parent
966de41565
commit
c79a46ee2a
|
@ -17,12 +17,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '81f3299a0d1a50b0d4c7a0d8b56c5677491fb1f8';
|
||||
public const PACKAGE_VERSION = 'd68bc4ccf6fca72f748cb3b9b80264901094b3d6';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-08-07 10:35:16';
|
||||
public const RELEASE_DATE = '2022-08-07 14:22:47';
|
||||
/**
|
||||
* @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 ComposerAutoloaderInit1863c32f22038906f632ac4bf6fa8eea::getLoader();
|
||||
return ComposerAutoloaderInit0af6fe88a0b076bd8e57cbb331a2e0b2::getLoader();
|
||||
|
|
95
vendor/bin/neon-lint
vendored
95
vendor/bin/neon-lint
vendored
|
@ -1,95 +0,0 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
/**
|
||||
* Proxy PHP file generated by Composer
|
||||
*
|
||||
* This file includes the referenced bin path (../nette/neon/bin/neon-lint)
|
||||
* using a stream wrapper to prevent the shebang from being output on PHP<8
|
||||
*
|
||||
* @generated
|
||||
*/
|
||||
namespace RectorPrefix202208\Composer;
|
||||
|
||||
$GLOBALS['_composer_bin_dir'] = __DIR__;
|
||||
$GLOBALS['_composer_autoload_path'] = __DIR__ . '/..' . '/autoload.php';
|
||||
if (\PHP_VERSION_ID < 80000) {
|
||||
if (!\class_exists('RectorPrefix202208\\Composer\\BinProxyWrapper')) {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class BinProxyWrapper
|
||||
{
|
||||
private $handle;
|
||||
private $position;
|
||||
private $realpath;
|
||||
public function stream_open($path, $mode, $options, &$opened_path)
|
||||
{
|
||||
// get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
|
||||
$opened_path = \substr($path, 17);
|
||||
$this->realpath = \realpath($opened_path) ?: $opened_path;
|
||||
$opened_path = $this->realpath;
|
||||
$this->handle = \fopen($this->realpath, $mode);
|
||||
$this->position = 0;
|
||||
return (bool) $this->handle;
|
||||
}
|
||||
public function stream_read($count)
|
||||
{
|
||||
$data = \fread($this->handle, $count);
|
||||
if ($this->position === 0) {
|
||||
$data = \preg_replace('{^#!.*\\r?\\n}', '', $data);
|
||||
}
|
||||
$this->position += \strlen($data);
|
||||
return $data;
|
||||
}
|
||||
public function stream_cast($castAs)
|
||||
{
|
||||
return $this->handle;
|
||||
}
|
||||
public function stream_close()
|
||||
{
|
||||
\fclose($this->handle);
|
||||
}
|
||||
public function stream_lock($operation)
|
||||
{
|
||||
return $operation ? \flock($this->handle, $operation) : \true;
|
||||
}
|
||||
public function stream_seek($offset, $whence)
|
||||
{
|
||||
if (0 === \fseek($this->handle, $offset, $whence)) {
|
||||
$this->position = \ftell($this->handle);
|
||||
return \true;
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
public function stream_tell()
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
public function stream_eof()
|
||||
{
|
||||
return \feof($this->handle);
|
||||
}
|
||||
public function stream_stat()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
public function stream_set_option($option, $arg1, $arg2)
|
||||
{
|
||||
return \true;
|
||||
}
|
||||
public function url_stat($path, $flags)
|
||||
{
|
||||
$path = \substr($path, 17);
|
||||
if (\file_exists($path)) {
|
||||
return \stat($path);
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (\function_exists('stream_get_wrappers') && \in_array('phpvfscomposer', \stream_get_wrappers(), \true) || \function_exists('stream_wrapper_register') && \stream_wrapper_register('phpvfscomposer', 'RectorPrefix202208\\Composer\\BinProxyWrapper')) {
|
||||
include "phpvfscomposer://" . __DIR__ . '/..' . '/nette/neon/bin/neon-lint';
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
include __DIR__ . '/..' . '/nette/neon/bin/neon-lint';
|
64
vendor/composer/autoload_classmap.php
vendored
64
vendor/composer/autoload_classmap.php
vendored
|
@ -412,25 +412,6 @@ return array(
|
|||
'RectorPrefix202208\\Nette\\Localization\\ITranslator' => $vendorDir . '/nette/utils/src/compatibility.php',
|
||||
'RectorPrefix202208\\Nette\\Localization\\Translator' => $vendorDir . '/nette/utils/src/Translator.php',
|
||||
'RectorPrefix202208\\Nette\\MemberAccessException' => $vendorDir . '/nette/utils/src/exceptions.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Decoder' => $vendorDir . '/nette/neon/src/Neon/Decoder.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Encoder' => $vendorDir . '/nette/neon/src/Neon/Encoder.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Entity' => $vendorDir . '/nette/neon/src/Neon/Entity.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Exception' => $vendorDir . '/nette/neon/src/Neon/Exception.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Lexer' => $vendorDir . '/nette/neon/src/Neon/Lexer.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Neon' => $vendorDir . '/nette/neon/src/Neon/Neon.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Node' => $vendorDir . '/nette/neon/src/Neon/Node.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Node\\ArrayItemNode' => $vendorDir . '/nette/neon/src/Neon/Node/ArrayItemNode.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Node\\ArrayNode' => $vendorDir . '/nette/neon/src/Neon/Node/ArrayNode.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Node\\BlockArrayNode' => $vendorDir . '/nette/neon/src/Neon/Node/BlockArrayNode.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Node\\EntityChainNode' => $vendorDir . '/nette/neon/src/Neon/Node/EntityChainNode.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Node\\EntityNode' => $vendorDir . '/nette/neon/src/Neon/Node/EntityNode.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Node\\InlineArrayNode' => $vendorDir . '/nette/neon/src/Neon/Node/InlineArrayNode.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Node\\LiteralNode' => $vendorDir . '/nette/neon/src/Neon/Node/LiteralNode.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Node\\StringNode' => $vendorDir . '/nette/neon/src/Neon/Node/StringNode.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Parser' => $vendorDir . '/nette/neon/src/Neon/Parser.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Token' => $vendorDir . '/nette/neon/src/Neon/Token.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\TokenStream' => $vendorDir . '/nette/neon/src/Neon/TokenStream.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Traverser' => $vendorDir . '/nette/neon/src/Neon/Traverser.php',
|
||||
'RectorPrefix202208\\Nette\\NotImplementedException' => $vendorDir . '/nette/utils/src/exceptions.php',
|
||||
'RectorPrefix202208\\Nette\\NotSupportedException' => $vendorDir . '/nette/utils/src/exceptions.php',
|
||||
'RectorPrefix202208\\Nette\\OutOfRangeException' => $vendorDir . '/nette/utils/src/exceptions.php',
|
||||
|
@ -2075,39 +2056,9 @@ return array(
|
|||
'Rector\\Naming\\ValueObject\\VariableAndCallForeach' => $baseDir . '/rules/Naming/ValueObject/VariableAndCallForeach.php',
|
||||
'Rector\\Naming\\VariableRenamer' => $baseDir . '/rules/Naming/VariableRenamer.php',
|
||||
'Rector\\Nette\\Contract\\Rector\\LatteRectorInterface' => $vendorDir . '/rector/rector-nette/src/Contract/Rector/LatteRectorInterface.php',
|
||||
'Rector\\Nette\\Contract\\Rector\\NeonRectorInterface' => $vendorDir . '/rector/rector-nette/src/Contract/Rector/NeonRectorInterface.php',
|
||||
'Rector\\Nette\\FileProcessor\\LatteFileProcessor' => $vendorDir . '/rector/rector-nette/src/FileProcessor/LatteFileProcessor.php',
|
||||
'Rector\\Nette\\FileProcessor\\NeonFileProcessor' => $vendorDir . '/rector/rector-nette/src/FileProcessor/NeonFileProcessor.php',
|
||||
'Rector\\Nette\\Kdyby\\BlueprintFactory\\VariableWithTypesFactory' => $vendorDir . '/rector/rector-nette/src/Kdyby/BlueprintFactory/VariableWithTypesFactory.php',
|
||||
'Rector\\Nette\\Kdyby\\ContributeEventClassResolver' => $vendorDir . '/rector/rector-nette/src/Kdyby/ContributeEventClassResolver.php',
|
||||
'Rector\\Nette\\Kdyby\\Naming\\EventClassNaming' => $vendorDir . '/rector/rector-nette/src/Kdyby/Naming/EventClassNaming.php',
|
||||
'Rector\\Nette\\Kdyby\\NodeAnalyzer\\GetSubscribedEventsClassMethodAnalyzer' => $vendorDir . '/rector/rector-nette/src/Kdyby/NodeAnalyzer/GetSubscribedEventsClassMethodAnalyzer.php',
|
||||
'Rector\\Nette\\Kdyby\\NodeFactory\\EventValueObjectClassFactory' => $vendorDir . '/rector/rector-nette/src/Kdyby/NodeFactory/EventValueObjectClassFactory.php',
|
||||
'Rector\\Nette\\Kdyby\\NodeManipulator\\GetSubscribedEventsArrayManipulator' => $vendorDir . '/rector/rector-nette/src/Kdyby/NodeManipulator/GetSubscribedEventsArrayManipulator.php',
|
||||
'Rector\\Nette\\Kdyby\\NodeManipulator\\ListeningClassMethodArgumentManipulator' => $vendorDir . '/rector/rector-nette/src/Kdyby/NodeManipulator/ListeningClassMethodArgumentManipulator.php',
|
||||
'Rector\\Nette\\Kdyby\\NodeResolver\\ListeningMethodsCollector' => $vendorDir . '/rector/rector-nette/src/Kdyby/NodeResolver/ListeningMethodsCollector.php',
|
||||
'Rector\\Nette\\Kdyby\\Rector\\ClassMethod\\ChangeNetteEventNamesInGetSubscribedEventsRector' => $vendorDir . '/rector/rector-nette/src/Kdyby/Rector/ClassMethod/ChangeNetteEventNamesInGetSubscribedEventsRector.php',
|
||||
'Rector\\Nette\\Kdyby\\Rector\\MethodCall\\ReplaceEventManagerWithEventSubscriberRector' => $vendorDir . '/rector/rector-nette/src/Kdyby/Rector/MethodCall/ReplaceEventManagerWithEventSubscriberRector.php',
|
||||
'Rector\\Nette\\Kdyby\\Rector\\MethodCall\\WrapTransParameterNameRector' => $vendorDir . '/rector/rector-nette/src/Kdyby/Rector/MethodCall/WrapTransParameterNameRector.php',
|
||||
'Rector\\Nette\\Kdyby\\ValueObject\\EventClassAndClassMethod' => $vendorDir . '/rector/rector-nette/src/Kdyby/ValueObject/EventClassAndClassMethod.php',
|
||||
'Rector\\Nette\\Kdyby\\ValueObject\\NetteEventToContributeEventClass' => $vendorDir . '/rector/rector-nette/src/Kdyby/ValueObject/NetteEventToContributeEventClass.php',
|
||||
'Rector\\Nette\\Kdyby\\ValueObject\\VariableWithType' => $vendorDir . '/rector/rector-nette/src/Kdyby/ValueObject/VariableWithType.php',
|
||||
'Rector\\Nette\\Latte\\Parser\\TemplateTypeParser' => $vendorDir . '/rector/rector-nette/src/Latte/Parser/TemplateTypeParser.php',
|
||||
'Rector\\Nette\\Latte\\Parser\\VarTypeParser' => $vendorDir . '/rector/rector-nette/src/Latte/Parser/VarTypeParser.php',
|
||||
'Rector\\Nette\\NeonParser\\Contract\\NeonNodeVisitorInterface' => $vendorDir . '/rector/rector-nette/packages/NeonParser/Contract/NeonNodeVisitorInterface.php',
|
||||
'Rector\\Nette\\NeonParser\\Exception\\NotImplementedYetException' => $vendorDir . '/rector/rector-nette/packages/NeonParser/Exception/NotImplementedYetException.php',
|
||||
'Rector\\Nette\\NeonParser\\Exception\\UnusedVirtualMethodException' => $vendorDir . '/rector/rector-nette/packages/NeonParser/Exception/UnusedVirtualMethodException.php',
|
||||
'Rector\\Nette\\NeonParser\\NeonNodeTraverser' => $vendorDir . '/rector/rector-nette/packages/NeonParser/NeonNodeTraverser.php',
|
||||
'Rector\\Nette\\NeonParser\\NeonNodeTraverserFactory' => $vendorDir . '/rector/rector-nette/packages/NeonParser/NeonNodeTraverserFactory.php',
|
||||
'Rector\\Nette\\NeonParser\\NeonNodeVisitor\\AbstractServiceNeonNodeVisitor' => $vendorDir . '/rector/rector-nette/packages/NeonParser/NeonNodeVisitor/AbstractServiceNeonNodeVisitor.php',
|
||||
'Rector\\Nette\\NeonParser\\NeonParser' => $vendorDir . '/rector/rector-nette/packages/NeonParser/NeonParser.php',
|
||||
'Rector\\Nette\\NeonParser\\NodeFactory\\ServiceFactory' => $vendorDir . '/rector/rector-nette/packages/NeonParser/NodeFactory/ServiceFactory.php',
|
||||
'Rector\\Nette\\NeonParser\\Node\\AbstractVirtualNode' => $vendorDir . '/rector/rector-nette/packages/NeonParser/Node/AbstractVirtualNode.php',
|
||||
'Rector\\Nette\\NeonParser\\Node\\Service_' => $vendorDir . '/rector/rector-nette/packages/NeonParser/Node/Service_.php',
|
||||
'Rector\\Nette\\NeonParser\\Node\\Service_\\SetupMethodCall' => $vendorDir . '/rector/rector-nette/packages/NeonParser/Node/Service_/SetupMethodCall.php',
|
||||
'Rector\\Nette\\NeonParser\\Printer\\FormatPreservingNeonPrinter' => $vendorDir . '/rector/rector-nette/packages/NeonParser/Printer/FormatPreservingNeonPrinter.php',
|
||||
'Rector\\Nette\\NeonParser\\Services\\ServiceTypeResolver' => $vendorDir . '/rector/rector-nette/packages/NeonParser/Services/ServiceTypeResolver.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\BinaryOpAnalyzer' => $vendorDir . '/rector/rector-nette/src/NodeAnalyzer/BinaryOpAnalyzer.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\ConditionalTemplateAssignReplacer' => $vendorDir . '/rector/rector-nette/src/NodeAnalyzer/ConditionalTemplateAssignReplacer.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\MethodCallArgMerger' => $vendorDir . '/rector/rector-nette/src/NodeAnalyzer/MethodCallArgMerger.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\NetteClassAnalyzer' => $vendorDir . '/rector/rector-nette/src/NodeAnalyzer/NetteClassAnalyzer.php',
|
||||
|
@ -2117,13 +2068,10 @@ return array(
|
|||
'Rector\\Nette\\NodeAnalyzer\\RenderMethodAnalyzer' => $vendorDir . '/rector/rector-nette/src/NodeAnalyzer/RenderMethodAnalyzer.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\ReturnAnalyzer' => $vendorDir . '/rector/rector-nette/src/NodeAnalyzer/ReturnAnalyzer.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\StaticCallAnalyzer' => $vendorDir . '/rector/rector-nette/src/NodeAnalyzer/StaticCallAnalyzer.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\StrlenEndsWithResolver' => $vendorDir . '/rector/rector-nette/src/NodeAnalyzer/StrlenEndsWithResolver.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\TemplatePropertyAssignCollector' => $vendorDir . '/rector/rector-nette/src/NodeAnalyzer/TemplatePropertyAssignCollector.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\TemplatePropertyParametersReplacer' => $vendorDir . '/rector/rector-nette/src/NodeAnalyzer/TemplatePropertyParametersReplacer.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\ThisTemplatePropertyFetchAnalyzer' => $vendorDir . '/rector/rector-nette/src/NodeAnalyzer/ThisTemplatePropertyFetchAnalyzer.php',
|
||||
'Rector\\Nette\\NodeFactory\\CheckRequirementsClassMethodFactory' => $vendorDir . '/rector/rector-nette/src/NodeFactory/CheckRequirementsClassMethodFactory.php',
|
||||
'Rector\\Nette\\NodeFactory\\ClassWithPublicPropertiesFactory' => $vendorDir . '/rector/rector-nette/src/NodeFactory/ClassWithPublicPropertiesFactory.php',
|
||||
'Rector\\Nette\\NodeFactory\\ParentGetterStmtsToExternalStmtsFactory' => $vendorDir . '/rector/rector-nette/src/NodeFactory/ParentGetterStmtsToExternalStmtsFactory.php',
|
||||
'Rector\\Nette\\NodeFactory\\RenderParameterArrayFactory' => $vendorDir . '/rector/rector-nette/src/NodeFactory/RenderParameterArrayFactory.php',
|
||||
'Rector\\Nette\\NodeFinder\\FormFieldsFinder' => $vendorDir . '/rector/rector-nette/src/NodeFinder/FormFieldsFinder.php',
|
||||
'Rector\\Nette\\NodeFinder\\FormOnSuccessCallbackFinder' => $vendorDir . '/rector/rector-nette/src/NodeFinder/FormOnSuccessCallbackFinder.php',
|
||||
|
@ -2132,24 +2080,18 @@ return array(
|
|||
'Rector\\Nette\\NodeFinder\\ParamFinder' => $vendorDir . '/rector/rector-nette/src/NodeFinder/ParamFinder.php',
|
||||
'Rector\\Nette\\Rector\\ClassMethod\\MergeTemplateSetFileToTemplateRenderRector' => $vendorDir . '/rector/rector-nette/src/Rector/ClassMethod/MergeTemplateSetFileToTemplateRenderRector.php',
|
||||
'Rector\\Nette\\Rector\\ClassMethod\\RemoveParentAndNameFromComponentConstructorRector' => $vendorDir . '/rector/rector-nette/src/Rector/ClassMethod/RemoveParentAndNameFromComponentConstructorRector.php',
|
||||
'Rector\\Nette\\Rector\\ClassMethod\\RenderMethodParamToTypeDeclarationRector' => $vendorDir . '/rector/rector-nette/src/Rector/ClassMethod/RenderMethodParamToTypeDeclarationRector.php',
|
||||
'Rector\\Nette\\Rector\\ClassMethod\\TemplateMagicAssignToExplicitVariableArrayRector' => $vendorDir . '/rector/rector-nette/src/Rector/ClassMethod/TemplateMagicAssignToExplicitVariableArrayRector.php',
|
||||
'Rector\\Nette\\Rector\\ClassMethod\\TranslateClassMethodToVariadicsRector' => $vendorDir . '/rector/rector-nette/src/Rector/ClassMethod/TranslateClassMethodToVariadicsRector.php',
|
||||
'Rector\\Nette\\Rector\\Class_\\FormDataRector' => $vendorDir . '/rector/rector-nette/src/Rector/Class_/FormDataRector.php',
|
||||
'Rector\\Nette\\Rector\\Class_\\LatteVarTypesBasedOnPresenterTemplateParametersRector' => $vendorDir . '/rector/rector-nette/src/Rector/Class_/LatteVarTypesBasedOnPresenterTemplateParametersRector.php',
|
||||
'Rector\\Nette\\Rector\\Class_\\MoveFinalGetUserToCheckRequirementsClassMethodRector' => $vendorDir . '/rector/rector-nette/src/Rector/Class_/MoveFinalGetUserToCheckRequirementsClassMethodRector.php',
|
||||
'Rector\\Nette\\Rector\\Class_\\MoveInjectToExistingConstructorRector' => $vendorDir . '/rector/rector-nette/src/Rector/Class_/MoveInjectToExistingConstructorRector.php',
|
||||
'Rector\\Nette\\Rector\\Class_\\TemplateTypeBasedOnPresenterTemplateParametersRector' => $vendorDir . '/rector/rector-nette/src/Rector/Class_/TemplateTypeBasedOnPresenterTemplateParametersRector.php',
|
||||
'Rector\\Nette\\Rector\\FuncCall\\FilePutContentsToFileSystemWriteRector' => $vendorDir . '/rector/rector-nette/src/Rector/FuncCall/FilePutContentsToFileSystemWriteRector.php',
|
||||
'Rector\\Nette\\Rector\\FuncCall\\JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector' => $vendorDir . '/rector/rector-nette/src/Rector/FuncCall/JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector.php',
|
||||
'Rector\\Nette\\Rector\\FuncCall\\PregFunctionToNetteUtilsStringsRector' => $vendorDir . '/rector/rector-nette/src/Rector/FuncCall/PregFunctionToNetteUtilsStringsRector.php',
|
||||
'Rector\\Nette\\Rector\\FuncCall\\PregMatchFunctionToNetteUtilsStringsRector' => $vendorDir . '/rector/rector-nette/src/Rector/FuncCall/PregMatchFunctionToNetteUtilsStringsRector.php',
|
||||
'Rector\\Nette\\Rector\\FuncCall\\SubstrStrlenFunctionToNetteUtilsStringsRector' => $vendorDir . '/rector/rector-nette/src/Rector/FuncCall/SubstrStrlenFunctionToNetteUtilsStringsRector.php',
|
||||
'Rector\\Nette\\Rector\\Identical\\EndsWithFunctionToNetteUtilsStringsRector' => $vendorDir . '/rector/rector-nette/src/Rector/Identical/EndsWithFunctionToNetteUtilsStringsRector.php',
|
||||
'Rector\\Nette\\Rector\\Identical\\SubstrMinusToStringEndsWithRector' => $vendorDir . '/rector/rector-nette/src/Rector/Identical/SubstrMinusToStringEndsWithRector.php',
|
||||
'Rector\\Nette\\Rector\\LNumber\\ReplaceTimeNumberWithDateTimeConstantRector' => $vendorDir . '/rector/rector-nette/src/Rector/LNumber/ReplaceTimeNumberWithDateTimeConstantRector.php',
|
||||
'Rector\\Nette\\Rector\\Latte\\RenameMethodLatteRector' => $vendorDir . '/rector/rector-nette/src/Rector/Latte/RenameMethodLatteRector.php',
|
||||
'Rector\\Nette\\Rector\\MethodCall\\AddNextrasDatePickerToDateControlRector' => $vendorDir . '/rector/rector-nette/src/Rector/MethodCall/AddNextrasDatePickerToDateControlRector.php',
|
||||
'Rector\\Nette\\Rector\\MethodCall\\BuilderExpandToHelperExpandRector' => $vendorDir . '/rector/rector-nette/src/Rector/MethodCall/BuilderExpandToHelperExpandRector.php',
|
||||
'Rector\\Nette\\Rector\\MethodCall\\ContextGetByTypeToConstructorInjectionRector' => $vendorDir . '/rector/rector-nette/src/Rector/MethodCall/ContextGetByTypeToConstructorInjectionRector.php',
|
||||
'Rector\\Nette\\Rector\\MethodCall\\ConvertAddUploadWithThirdArgumentTrueToAddMultiUploadRector' => $vendorDir . '/rector/rector-nette/src/Rector/MethodCall/ConvertAddUploadWithThirdArgumentTrueToAddMultiUploadRector.php',
|
||||
|
@ -2157,16 +2099,10 @@ return array(
|
|||
'Rector\\Nette\\Rector\\MethodCall\\MergeDefaultsInGetConfigCompilerExtensionRector' => $vendorDir . '/rector/rector-nette/src/Rector/MethodCall/MergeDefaultsInGetConfigCompilerExtensionRector.php',
|
||||
'Rector\\Nette\\Rector\\MethodCall\\RequestGetCookieDefaultArgumentToCoalesceRector' => $vendorDir . '/rector/rector-nette/src/Rector/MethodCall/RequestGetCookieDefaultArgumentToCoalesceRector.php',
|
||||
'Rector\\Nette\\Rector\\MethodCall\\SetClassWithArgumentToSetFactoryRector' => $vendorDir . '/rector/rector-nette/src/Rector/MethodCall/SetClassWithArgumentToSetFactoryRector.php',
|
||||
'Rector\\Nette\\Rector\\Neon\\RenameMethodNeonRector' => $vendorDir . '/rector/rector-nette/src/Rector/Neon/RenameMethodNeonRector.php',
|
||||
'Rector\\Nette\\Rector\\NotIdentical\\StrposToStringsContainsRector' => $vendorDir . '/rector/rector-nette/src/Rector/NotIdentical/StrposToStringsContainsRector.php',
|
||||
'Rector\\Nette\\Rector\\Property\\NetteInjectToConstructorInjectionRector' => $vendorDir . '/rector/rector-nette/src/Rector/Property/NetteInjectToConstructorInjectionRector.php',
|
||||
'Rector\\Nette\\Set\\ContributteSetList' => $vendorDir . '/rector/rector-nette/src/Set/ContributteSetList.php',
|
||||
'Rector\\Nette\\Set\\KdybySetList' => $vendorDir . '/rector/rector-nette/src/Set/KdybySetList.php',
|
||||
'Rector\\Nette\\Set\\NetteSetList' => $vendorDir . '/rector/rector-nette/src/Set/NetteSetList.php',
|
||||
'Rector\\Nette\\ValueObject\\AlwaysTemplateParameterAssign' => $vendorDir . '/rector/rector-nette/src/ValueObject/AlwaysTemplateParameterAssign.php',
|
||||
'Rector\\Nette\\ValueObject\\ContentExprAndNeedleExpr' => $vendorDir . '/rector/rector-nette/src/ValueObject/ContentExprAndNeedleExpr.php',
|
||||
'Rector\\Nette\\ValueObject\\FormField' => $vendorDir . '/rector/rector-nette/src/ValueObject/FormField.php',
|
||||
'Rector\\Nette\\ValueObject\\FuncCallAndExpr' => $vendorDir . '/rector/rector-nette/src/ValueObject/FuncCallAndExpr.php',
|
||||
'Rector\\Nette\\ValueObject\\LatteVariableType' => $vendorDir . '/rector/rector-nette/src/ValueObject/LatteVariableType.php',
|
||||
'Rector\\Nette\\ValueObject\\ParameterAssign' => $vendorDir . '/rector/rector-nette/src/ValueObject/ParameterAssign.php',
|
||||
'Rector\\Nette\\ValueObject\\TemplateParametersAssigns' => $vendorDir . '/rector/rector-nette/src/ValueObject/TemplateParametersAssigns.php',
|
||||
|
|
2
vendor/composer/autoload_psr4.php
vendored
2
vendor/composer/autoload_psr4.php
vendored
|
@ -16,7 +16,7 @@ return array(
|
|||
'Rector\\RectorGenerator\\' => array($vendorDir . '/rector/rector-generator/src'),
|
||||
'Rector\\PHPUnit\\' => array($vendorDir . '/rector/rector-phpunit/src'),
|
||||
'Rector\\PHPOffice\\' => array($vendorDir . '/rector/rector-phpoffice/src'),
|
||||
'Rector\\Nette\\' => array($vendorDir . '/rector/rector-nette/src', $vendorDir . '/rector/rector-nette/packages'),
|
||||
'Rector\\Nette\\' => array($vendorDir . '/rector/rector-nette/src'),
|
||||
'Rector\\Laravel\\' => array($vendorDir . '/rector/rector-laravel/src'),
|
||||
'Rector\\Doctrine\\' => array($vendorDir . '/rector/rector-doctrine/src'),
|
||||
'Rector\\Core\\' => array($baseDir . '/src'),
|
||||
|
|
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 ComposerAutoloaderInit1863c32f22038906f632ac4bf6fa8eea
|
||||
class ComposerAutoloaderInit0af6fe88a0b076bd8e57cbb331a2e0b2
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,19 +22,19 @@ class ComposerAutoloaderInit1863c32f22038906f632ac4bf6fa8eea
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit1863c32f22038906f632ac4bf6fa8eea', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit0af6fe88a0b076bd8e57cbb331a2e0b2', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit1863c32f22038906f632ac4bf6fa8eea', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit0af6fe88a0b076bd8e57cbb331a2e0b2', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit1863c32f22038906f632ac4bf6fa8eea::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit0af6fe88a0b076bd8e57cbb331a2e0b2::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit1863c32f22038906f632ac4bf6fa8eea::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit0af6fe88a0b076bd8e57cbb331a2e0b2::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire1863c32f22038906f632ac4bf6fa8eea($fileIdentifier, $file);
|
||||
composerRequire0af6fe88a0b076bd8e57cbb331a2e0b2($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
@ -46,7 +46,7 @@ class ComposerAutoloaderInit1863c32f22038906f632ac4bf6fa8eea
|
|||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire1863c32f22038906f632ac4bf6fa8eea($fileIdentifier, $file)
|
||||
function composerRequire0af6fe88a0b076bd8e57cbb331a2e0b2($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
73
vendor/composer/autoload_static.php
vendored
73
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit1863c32f22038906f632ac4bf6fa8eea
|
||||
class ComposerStaticInit0af6fe88a0b076bd8e57cbb331a2e0b2
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
|
@ -130,7 +130,6 @@ class ComposerStaticInit1863c32f22038906f632ac4bf6fa8eea
|
|||
'Rector\\Nette\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/rector/rector-nette/src',
|
||||
1 => __DIR__ . '/..' . '/rector/rector-nette/packages',
|
||||
),
|
||||
'Rector\\Laravel\\' =>
|
||||
array (
|
||||
|
@ -719,25 +718,6 @@ class ComposerStaticInit1863c32f22038906f632ac4bf6fa8eea
|
|||
'RectorPrefix202208\\Nette\\Localization\\ITranslator' => __DIR__ . '/..' . '/nette/utils/src/compatibility.php',
|
||||
'RectorPrefix202208\\Nette\\Localization\\Translator' => __DIR__ . '/..' . '/nette/utils/src/Translator.php',
|
||||
'RectorPrefix202208\\Nette\\MemberAccessException' => __DIR__ . '/..' . '/nette/utils/src/exceptions.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Decoder' => __DIR__ . '/..' . '/nette/neon/src/Neon/Decoder.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Encoder' => __DIR__ . '/..' . '/nette/neon/src/Neon/Encoder.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Entity' => __DIR__ . '/..' . '/nette/neon/src/Neon/Entity.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Exception' => __DIR__ . '/..' . '/nette/neon/src/Neon/Exception.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Lexer' => __DIR__ . '/..' . '/nette/neon/src/Neon/Lexer.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Neon' => __DIR__ . '/..' . '/nette/neon/src/Neon/Neon.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Node' => __DIR__ . '/..' . '/nette/neon/src/Neon/Node.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Node\\ArrayItemNode' => __DIR__ . '/..' . '/nette/neon/src/Neon/Node/ArrayItemNode.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Node\\ArrayNode' => __DIR__ . '/..' . '/nette/neon/src/Neon/Node/ArrayNode.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Node\\BlockArrayNode' => __DIR__ . '/..' . '/nette/neon/src/Neon/Node/BlockArrayNode.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Node\\EntityChainNode' => __DIR__ . '/..' . '/nette/neon/src/Neon/Node/EntityChainNode.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Node\\EntityNode' => __DIR__ . '/..' . '/nette/neon/src/Neon/Node/EntityNode.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Node\\InlineArrayNode' => __DIR__ . '/..' . '/nette/neon/src/Neon/Node/InlineArrayNode.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Node\\LiteralNode' => __DIR__ . '/..' . '/nette/neon/src/Neon/Node/LiteralNode.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Node\\StringNode' => __DIR__ . '/..' . '/nette/neon/src/Neon/Node/StringNode.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Parser' => __DIR__ . '/..' . '/nette/neon/src/Neon/Parser.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Token' => __DIR__ . '/..' . '/nette/neon/src/Neon/Token.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\TokenStream' => __DIR__ . '/..' . '/nette/neon/src/Neon/TokenStream.php',
|
||||
'RectorPrefix202208\\Nette\\Neon\\Traverser' => __DIR__ . '/..' . '/nette/neon/src/Neon/Traverser.php',
|
||||
'RectorPrefix202208\\Nette\\NotImplementedException' => __DIR__ . '/..' . '/nette/utils/src/exceptions.php',
|
||||
'RectorPrefix202208\\Nette\\NotSupportedException' => __DIR__ . '/..' . '/nette/utils/src/exceptions.php',
|
||||
'RectorPrefix202208\\Nette\\OutOfRangeException' => __DIR__ . '/..' . '/nette/utils/src/exceptions.php',
|
||||
|
@ -2382,39 +2362,9 @@ class ComposerStaticInit1863c32f22038906f632ac4bf6fa8eea
|
|||
'Rector\\Naming\\ValueObject\\VariableAndCallForeach' => __DIR__ . '/../..' . '/rules/Naming/ValueObject/VariableAndCallForeach.php',
|
||||
'Rector\\Naming\\VariableRenamer' => __DIR__ . '/../..' . '/rules/Naming/VariableRenamer.php',
|
||||
'Rector\\Nette\\Contract\\Rector\\LatteRectorInterface' => __DIR__ . '/..' . '/rector/rector-nette/src/Contract/Rector/LatteRectorInterface.php',
|
||||
'Rector\\Nette\\Contract\\Rector\\NeonRectorInterface' => __DIR__ . '/..' . '/rector/rector-nette/src/Contract/Rector/NeonRectorInterface.php',
|
||||
'Rector\\Nette\\FileProcessor\\LatteFileProcessor' => __DIR__ . '/..' . '/rector/rector-nette/src/FileProcessor/LatteFileProcessor.php',
|
||||
'Rector\\Nette\\FileProcessor\\NeonFileProcessor' => __DIR__ . '/..' . '/rector/rector-nette/src/FileProcessor/NeonFileProcessor.php',
|
||||
'Rector\\Nette\\Kdyby\\BlueprintFactory\\VariableWithTypesFactory' => __DIR__ . '/..' . '/rector/rector-nette/src/Kdyby/BlueprintFactory/VariableWithTypesFactory.php',
|
||||
'Rector\\Nette\\Kdyby\\ContributeEventClassResolver' => __DIR__ . '/..' . '/rector/rector-nette/src/Kdyby/ContributeEventClassResolver.php',
|
||||
'Rector\\Nette\\Kdyby\\Naming\\EventClassNaming' => __DIR__ . '/..' . '/rector/rector-nette/src/Kdyby/Naming/EventClassNaming.php',
|
||||
'Rector\\Nette\\Kdyby\\NodeAnalyzer\\GetSubscribedEventsClassMethodAnalyzer' => __DIR__ . '/..' . '/rector/rector-nette/src/Kdyby/NodeAnalyzer/GetSubscribedEventsClassMethodAnalyzer.php',
|
||||
'Rector\\Nette\\Kdyby\\NodeFactory\\EventValueObjectClassFactory' => __DIR__ . '/..' . '/rector/rector-nette/src/Kdyby/NodeFactory/EventValueObjectClassFactory.php',
|
||||
'Rector\\Nette\\Kdyby\\NodeManipulator\\GetSubscribedEventsArrayManipulator' => __DIR__ . '/..' . '/rector/rector-nette/src/Kdyby/NodeManipulator/GetSubscribedEventsArrayManipulator.php',
|
||||
'Rector\\Nette\\Kdyby\\NodeManipulator\\ListeningClassMethodArgumentManipulator' => __DIR__ . '/..' . '/rector/rector-nette/src/Kdyby/NodeManipulator/ListeningClassMethodArgumentManipulator.php',
|
||||
'Rector\\Nette\\Kdyby\\NodeResolver\\ListeningMethodsCollector' => __DIR__ . '/..' . '/rector/rector-nette/src/Kdyby/NodeResolver/ListeningMethodsCollector.php',
|
||||
'Rector\\Nette\\Kdyby\\Rector\\ClassMethod\\ChangeNetteEventNamesInGetSubscribedEventsRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Kdyby/Rector/ClassMethod/ChangeNetteEventNamesInGetSubscribedEventsRector.php',
|
||||
'Rector\\Nette\\Kdyby\\Rector\\MethodCall\\ReplaceEventManagerWithEventSubscriberRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Kdyby/Rector/MethodCall/ReplaceEventManagerWithEventSubscriberRector.php',
|
||||
'Rector\\Nette\\Kdyby\\Rector\\MethodCall\\WrapTransParameterNameRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Kdyby/Rector/MethodCall/WrapTransParameterNameRector.php',
|
||||
'Rector\\Nette\\Kdyby\\ValueObject\\EventClassAndClassMethod' => __DIR__ . '/..' . '/rector/rector-nette/src/Kdyby/ValueObject/EventClassAndClassMethod.php',
|
||||
'Rector\\Nette\\Kdyby\\ValueObject\\NetteEventToContributeEventClass' => __DIR__ . '/..' . '/rector/rector-nette/src/Kdyby/ValueObject/NetteEventToContributeEventClass.php',
|
||||
'Rector\\Nette\\Kdyby\\ValueObject\\VariableWithType' => __DIR__ . '/..' . '/rector/rector-nette/src/Kdyby/ValueObject/VariableWithType.php',
|
||||
'Rector\\Nette\\Latte\\Parser\\TemplateTypeParser' => __DIR__ . '/..' . '/rector/rector-nette/src/Latte/Parser/TemplateTypeParser.php',
|
||||
'Rector\\Nette\\Latte\\Parser\\VarTypeParser' => __DIR__ . '/..' . '/rector/rector-nette/src/Latte/Parser/VarTypeParser.php',
|
||||
'Rector\\Nette\\NeonParser\\Contract\\NeonNodeVisitorInterface' => __DIR__ . '/..' . '/rector/rector-nette/packages/NeonParser/Contract/NeonNodeVisitorInterface.php',
|
||||
'Rector\\Nette\\NeonParser\\Exception\\NotImplementedYetException' => __DIR__ . '/..' . '/rector/rector-nette/packages/NeonParser/Exception/NotImplementedYetException.php',
|
||||
'Rector\\Nette\\NeonParser\\Exception\\UnusedVirtualMethodException' => __DIR__ . '/..' . '/rector/rector-nette/packages/NeonParser/Exception/UnusedVirtualMethodException.php',
|
||||
'Rector\\Nette\\NeonParser\\NeonNodeTraverser' => __DIR__ . '/..' . '/rector/rector-nette/packages/NeonParser/NeonNodeTraverser.php',
|
||||
'Rector\\Nette\\NeonParser\\NeonNodeTraverserFactory' => __DIR__ . '/..' . '/rector/rector-nette/packages/NeonParser/NeonNodeTraverserFactory.php',
|
||||
'Rector\\Nette\\NeonParser\\NeonNodeVisitor\\AbstractServiceNeonNodeVisitor' => __DIR__ . '/..' . '/rector/rector-nette/packages/NeonParser/NeonNodeVisitor/AbstractServiceNeonNodeVisitor.php',
|
||||
'Rector\\Nette\\NeonParser\\NeonParser' => __DIR__ . '/..' . '/rector/rector-nette/packages/NeonParser/NeonParser.php',
|
||||
'Rector\\Nette\\NeonParser\\NodeFactory\\ServiceFactory' => __DIR__ . '/..' . '/rector/rector-nette/packages/NeonParser/NodeFactory/ServiceFactory.php',
|
||||
'Rector\\Nette\\NeonParser\\Node\\AbstractVirtualNode' => __DIR__ . '/..' . '/rector/rector-nette/packages/NeonParser/Node/AbstractVirtualNode.php',
|
||||
'Rector\\Nette\\NeonParser\\Node\\Service_' => __DIR__ . '/..' . '/rector/rector-nette/packages/NeonParser/Node/Service_.php',
|
||||
'Rector\\Nette\\NeonParser\\Node\\Service_\\SetupMethodCall' => __DIR__ . '/..' . '/rector/rector-nette/packages/NeonParser/Node/Service_/SetupMethodCall.php',
|
||||
'Rector\\Nette\\NeonParser\\Printer\\FormatPreservingNeonPrinter' => __DIR__ . '/..' . '/rector/rector-nette/packages/NeonParser/Printer/FormatPreservingNeonPrinter.php',
|
||||
'Rector\\Nette\\NeonParser\\Services\\ServiceTypeResolver' => __DIR__ . '/..' . '/rector/rector-nette/packages/NeonParser/Services/ServiceTypeResolver.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\BinaryOpAnalyzer' => __DIR__ . '/..' . '/rector/rector-nette/src/NodeAnalyzer/BinaryOpAnalyzer.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\ConditionalTemplateAssignReplacer' => __DIR__ . '/..' . '/rector/rector-nette/src/NodeAnalyzer/ConditionalTemplateAssignReplacer.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\MethodCallArgMerger' => __DIR__ . '/..' . '/rector/rector-nette/src/NodeAnalyzer/MethodCallArgMerger.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\NetteClassAnalyzer' => __DIR__ . '/..' . '/rector/rector-nette/src/NodeAnalyzer/NetteClassAnalyzer.php',
|
||||
|
@ -2424,13 +2374,10 @@ class ComposerStaticInit1863c32f22038906f632ac4bf6fa8eea
|
|||
'Rector\\Nette\\NodeAnalyzer\\RenderMethodAnalyzer' => __DIR__ . '/..' . '/rector/rector-nette/src/NodeAnalyzer/RenderMethodAnalyzer.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\ReturnAnalyzer' => __DIR__ . '/..' . '/rector/rector-nette/src/NodeAnalyzer/ReturnAnalyzer.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\StaticCallAnalyzer' => __DIR__ . '/..' . '/rector/rector-nette/src/NodeAnalyzer/StaticCallAnalyzer.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\StrlenEndsWithResolver' => __DIR__ . '/..' . '/rector/rector-nette/src/NodeAnalyzer/StrlenEndsWithResolver.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\TemplatePropertyAssignCollector' => __DIR__ . '/..' . '/rector/rector-nette/src/NodeAnalyzer/TemplatePropertyAssignCollector.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\TemplatePropertyParametersReplacer' => __DIR__ . '/..' . '/rector/rector-nette/src/NodeAnalyzer/TemplatePropertyParametersReplacer.php',
|
||||
'Rector\\Nette\\NodeAnalyzer\\ThisTemplatePropertyFetchAnalyzer' => __DIR__ . '/..' . '/rector/rector-nette/src/NodeAnalyzer/ThisTemplatePropertyFetchAnalyzer.php',
|
||||
'Rector\\Nette\\NodeFactory\\CheckRequirementsClassMethodFactory' => __DIR__ . '/..' . '/rector/rector-nette/src/NodeFactory/CheckRequirementsClassMethodFactory.php',
|
||||
'Rector\\Nette\\NodeFactory\\ClassWithPublicPropertiesFactory' => __DIR__ . '/..' . '/rector/rector-nette/src/NodeFactory/ClassWithPublicPropertiesFactory.php',
|
||||
'Rector\\Nette\\NodeFactory\\ParentGetterStmtsToExternalStmtsFactory' => __DIR__ . '/..' . '/rector/rector-nette/src/NodeFactory/ParentGetterStmtsToExternalStmtsFactory.php',
|
||||
'Rector\\Nette\\NodeFactory\\RenderParameterArrayFactory' => __DIR__ . '/..' . '/rector/rector-nette/src/NodeFactory/RenderParameterArrayFactory.php',
|
||||
'Rector\\Nette\\NodeFinder\\FormFieldsFinder' => __DIR__ . '/..' . '/rector/rector-nette/src/NodeFinder/FormFieldsFinder.php',
|
||||
'Rector\\Nette\\NodeFinder\\FormOnSuccessCallbackFinder' => __DIR__ . '/..' . '/rector/rector-nette/src/NodeFinder/FormOnSuccessCallbackFinder.php',
|
||||
|
@ -2439,24 +2386,18 @@ class ComposerStaticInit1863c32f22038906f632ac4bf6fa8eea
|
|||
'Rector\\Nette\\NodeFinder\\ParamFinder' => __DIR__ . '/..' . '/rector/rector-nette/src/NodeFinder/ParamFinder.php',
|
||||
'Rector\\Nette\\Rector\\ClassMethod\\MergeTemplateSetFileToTemplateRenderRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/ClassMethod/MergeTemplateSetFileToTemplateRenderRector.php',
|
||||
'Rector\\Nette\\Rector\\ClassMethod\\RemoveParentAndNameFromComponentConstructorRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/ClassMethod/RemoveParentAndNameFromComponentConstructorRector.php',
|
||||
'Rector\\Nette\\Rector\\ClassMethod\\RenderMethodParamToTypeDeclarationRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/ClassMethod/RenderMethodParamToTypeDeclarationRector.php',
|
||||
'Rector\\Nette\\Rector\\ClassMethod\\TemplateMagicAssignToExplicitVariableArrayRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/ClassMethod/TemplateMagicAssignToExplicitVariableArrayRector.php',
|
||||
'Rector\\Nette\\Rector\\ClassMethod\\TranslateClassMethodToVariadicsRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/ClassMethod/TranslateClassMethodToVariadicsRector.php',
|
||||
'Rector\\Nette\\Rector\\Class_\\FormDataRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/Class_/FormDataRector.php',
|
||||
'Rector\\Nette\\Rector\\Class_\\LatteVarTypesBasedOnPresenterTemplateParametersRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/Class_/LatteVarTypesBasedOnPresenterTemplateParametersRector.php',
|
||||
'Rector\\Nette\\Rector\\Class_\\MoveFinalGetUserToCheckRequirementsClassMethodRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/Class_/MoveFinalGetUserToCheckRequirementsClassMethodRector.php',
|
||||
'Rector\\Nette\\Rector\\Class_\\MoveInjectToExistingConstructorRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/Class_/MoveInjectToExistingConstructorRector.php',
|
||||
'Rector\\Nette\\Rector\\Class_\\TemplateTypeBasedOnPresenterTemplateParametersRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/Class_/TemplateTypeBasedOnPresenterTemplateParametersRector.php',
|
||||
'Rector\\Nette\\Rector\\FuncCall\\FilePutContentsToFileSystemWriteRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/FuncCall/FilePutContentsToFileSystemWriteRector.php',
|
||||
'Rector\\Nette\\Rector\\FuncCall\\JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/FuncCall/JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector.php',
|
||||
'Rector\\Nette\\Rector\\FuncCall\\PregFunctionToNetteUtilsStringsRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/FuncCall/PregFunctionToNetteUtilsStringsRector.php',
|
||||
'Rector\\Nette\\Rector\\FuncCall\\PregMatchFunctionToNetteUtilsStringsRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/FuncCall/PregMatchFunctionToNetteUtilsStringsRector.php',
|
||||
'Rector\\Nette\\Rector\\FuncCall\\SubstrStrlenFunctionToNetteUtilsStringsRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/FuncCall/SubstrStrlenFunctionToNetteUtilsStringsRector.php',
|
||||
'Rector\\Nette\\Rector\\Identical\\EndsWithFunctionToNetteUtilsStringsRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/Identical/EndsWithFunctionToNetteUtilsStringsRector.php',
|
||||
'Rector\\Nette\\Rector\\Identical\\SubstrMinusToStringEndsWithRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/Identical/SubstrMinusToStringEndsWithRector.php',
|
||||
'Rector\\Nette\\Rector\\LNumber\\ReplaceTimeNumberWithDateTimeConstantRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/LNumber/ReplaceTimeNumberWithDateTimeConstantRector.php',
|
||||
'Rector\\Nette\\Rector\\Latte\\RenameMethodLatteRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/Latte/RenameMethodLatteRector.php',
|
||||
'Rector\\Nette\\Rector\\MethodCall\\AddNextrasDatePickerToDateControlRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/MethodCall/AddNextrasDatePickerToDateControlRector.php',
|
||||
'Rector\\Nette\\Rector\\MethodCall\\BuilderExpandToHelperExpandRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/MethodCall/BuilderExpandToHelperExpandRector.php',
|
||||
'Rector\\Nette\\Rector\\MethodCall\\ContextGetByTypeToConstructorInjectionRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/MethodCall/ContextGetByTypeToConstructorInjectionRector.php',
|
||||
'Rector\\Nette\\Rector\\MethodCall\\ConvertAddUploadWithThirdArgumentTrueToAddMultiUploadRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/MethodCall/ConvertAddUploadWithThirdArgumentTrueToAddMultiUploadRector.php',
|
||||
|
@ -2464,16 +2405,10 @@ class ComposerStaticInit1863c32f22038906f632ac4bf6fa8eea
|
|||
'Rector\\Nette\\Rector\\MethodCall\\MergeDefaultsInGetConfigCompilerExtensionRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/MethodCall/MergeDefaultsInGetConfigCompilerExtensionRector.php',
|
||||
'Rector\\Nette\\Rector\\MethodCall\\RequestGetCookieDefaultArgumentToCoalesceRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/MethodCall/RequestGetCookieDefaultArgumentToCoalesceRector.php',
|
||||
'Rector\\Nette\\Rector\\MethodCall\\SetClassWithArgumentToSetFactoryRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/MethodCall/SetClassWithArgumentToSetFactoryRector.php',
|
||||
'Rector\\Nette\\Rector\\Neon\\RenameMethodNeonRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/Neon/RenameMethodNeonRector.php',
|
||||
'Rector\\Nette\\Rector\\NotIdentical\\StrposToStringsContainsRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/NotIdentical/StrposToStringsContainsRector.php',
|
||||
'Rector\\Nette\\Rector\\Property\\NetteInjectToConstructorInjectionRector' => __DIR__ . '/..' . '/rector/rector-nette/src/Rector/Property/NetteInjectToConstructorInjectionRector.php',
|
||||
'Rector\\Nette\\Set\\ContributteSetList' => __DIR__ . '/..' . '/rector/rector-nette/src/Set/ContributteSetList.php',
|
||||
'Rector\\Nette\\Set\\KdybySetList' => __DIR__ . '/..' . '/rector/rector-nette/src/Set/KdybySetList.php',
|
||||
'Rector\\Nette\\Set\\NetteSetList' => __DIR__ . '/..' . '/rector/rector-nette/src/Set/NetteSetList.php',
|
||||
'Rector\\Nette\\ValueObject\\AlwaysTemplateParameterAssign' => __DIR__ . '/..' . '/rector/rector-nette/src/ValueObject/AlwaysTemplateParameterAssign.php',
|
||||
'Rector\\Nette\\ValueObject\\ContentExprAndNeedleExpr' => __DIR__ . '/..' . '/rector/rector-nette/src/ValueObject/ContentExprAndNeedleExpr.php',
|
||||
'Rector\\Nette\\ValueObject\\FormField' => __DIR__ . '/..' . '/rector/rector-nette/src/ValueObject/FormField.php',
|
||||
'Rector\\Nette\\ValueObject\\FuncCallAndExpr' => __DIR__ . '/..' . '/rector/rector-nette/src/ValueObject/FuncCallAndExpr.php',
|
||||
'Rector\\Nette\\ValueObject\\LatteVariableType' => __DIR__ . '/..' . '/rector/rector-nette/src/ValueObject/LatteVariableType.php',
|
||||
'Rector\\Nette\\ValueObject\\ParameterAssign' => __DIR__ . '/..' . '/rector/rector-nette/src/ValueObject/ParameterAssign.php',
|
||||
'Rector\\Nette\\ValueObject\\TemplateParametersAssigns' => __DIR__ . '/..' . '/rector/rector-nette/src/ValueObject/TemplateParametersAssigns.php',
|
||||
|
@ -3386,9 +3321,9 @@ class ComposerStaticInit1863c32f22038906f632ac4bf6fa8eea
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit1863c32f22038906f632ac4bf6fa8eea::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit1863c32f22038906f632ac4bf6fa8eea::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit1863c32f22038906f632ac4bf6fa8eea::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit0af6fe88a0b076bd8e57cbb331a2e0b2::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit0af6fe88a0b076bd8e57cbb331a2e0b2::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit0af6fe88a0b076bd8e57cbb331a2e0b2::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
99
vendor/composer/installed.json
vendored
99
vendor/composer/installed.json
vendored
|
@ -438,77 +438,6 @@
|
|||
},
|
||||
"install-path": "..\/evenement\/evenement"
|
||||
},
|
||||
{
|
||||
"name": "nette\/neon",
|
||||
"version": "v3.3.3",
|
||||
"version_normalized": "3.3.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/nette\/neon.git",
|
||||
"reference": "22e384da162fab42961d48eb06c06d3ad0c11b95"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/nette\/neon\/zipball\/22e384da162fab42961d48eb06c06d3ad0c11b95",
|
||||
"reference": "22e384da162fab42961d48eb06c06d3ad0c11b95",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"php": ">=7.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"nette\/tester": "^2.0",
|
||||
"phpstan\/phpstan": "^0.12",
|
||||
"tracy\/tracy": "^2.7"
|
||||
},
|
||||
"time": "2022-03-10T02:04:26+00:00",
|
||||
"bin": [
|
||||
"bin\/neon-lint"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.3-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src\/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
||||
"license": [
|
||||
"BSD-3-Clause",
|
||||
"GPL-2.0-only",
|
||||
"GPL-3.0-only"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "David Grudl",
|
||||
"homepage": "https:\/\/davidgrudl.com"
|
||||
},
|
||||
{
|
||||
"name": "Nette Community",
|
||||
"homepage": "https:\/\/nette.org\/contributors"
|
||||
}
|
||||
],
|
||||
"description": "\ud83c\udf78 Nette NEON: encodes and decodes NEON file format.",
|
||||
"homepage": "https:\/\/ne-on.org",
|
||||
"keywords": [
|
||||
"export",
|
||||
"import",
|
||||
"neon",
|
||||
"nette",
|
||||
"yaml"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https:\/\/github.com\/nette\/neon\/issues",
|
||||
"source": "https:\/\/github.com\/nette\/neon\/tree\/v3.3.3"
|
||||
},
|
||||
"install-path": "..\/nette\/neon"
|
||||
},
|
||||
{
|
||||
"name": "nette\/utils",
|
||||
"version": "v3.2.7",
|
||||
|
@ -1923,12 +1852,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
|
||||
"reference": "ea5a50c055449227910a9f8df5e7e8290ddd4f7c"
|
||||
"reference": "3e935b49a44986f7fa28c1c74d9c8ce1ef700931"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/ea5a50c055449227910a9f8df5e7e8290ddd4f7c",
|
||||
"reference": "ea5a50c055449227910a9f8df5e7e8290ddd4f7c",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/3e935b49a44986f7fa28c1c74d9c8ce1ef700931",
|
||||
"reference": "3e935b49a44986f7fa28c1c74d9c8ce1ef700931",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1953,7 +1882,7 @@
|
|||
"symplify\/rule-doc-generator": "^11.0",
|
||||
"symplify\/vendor-patches": "^11.0"
|
||||
},
|
||||
"time": "2022-08-06T20:05:23+00:00",
|
||||
"time": "2022-08-07T09:30:44+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
@ -2202,23 +2131,20 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-nette.git",
|
||||
"reference": "0509d318cbadbe8d70157358d60a6418ed40c7b2"
|
||||
"reference": "9c8bf10d44d96d6c828fb3d1d563cfa88f03b26a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-nette\/zipball\/0509d318cbadbe8d70157358d60a6418ed40c7b2",
|
||||
"reference": "0509d318cbadbe8d70157358d60a6418ed40c7b2",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-nette\/zipball\/9c8bf10d44d96d6c828fb3d1d563cfa88f03b26a",
|
||||
"reference": "9c8bf10d44d96d6c828fb3d1d563cfa88f03b26a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-xml": "*",
|
||||
"nette\/neon": "^3.3.3",
|
||||
"php": ">=8.1",
|
||||
"rector\/rector-phpunit": "^0.11",
|
||||
"symfony\/string": "^6.1"
|
||||
"rector\/rector-phpunit": "^0.11"
|
||||
},
|
||||
"conflict": {
|
||||
"rector\/rector": "<0.11"
|
||||
"rector\/rector": "<0.12"
|
||||
},
|
||||
"require-dev": {
|
||||
"nette\/application": "^3.1",
|
||||
|
@ -2240,7 +2166,7 @@
|
|||
"symplify\/rule-doc-generator": "^11.0",
|
||||
"symplify\/vendor-patches": "^11.0"
|
||||
},
|
||||
"time": "2022-08-06T23:12:06+00:00",
|
||||
"time": "2022-08-07T12:19:31+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
@ -2257,10 +2183,7 @@
|
|||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Rector\\Nette\\": [
|
||||
"src",
|
||||
"packages"
|
||||
]
|
||||
"Rector\\Nette\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
||||
|
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
72
vendor/nette/neon/bin/neon-lint
vendored
72
vendor/nette/neon/bin/neon-lint
vendored
|
@ -1,72 +0,0 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208;
|
||||
|
||||
if (!(\is_file($file = __DIR__ . '/../vendor/autoload.php') && (include $file)) && !(\is_file($file = __DIR__ . '/../../../autoload.php') && (include $file))) {
|
||||
\fwrite(\STDERR, "Install packages using Composer.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (\function_exists('pcntl_signal')) {
|
||||
\pcntl_signal(\SIGINT, function () : void {
|
||||
\pcntl_signal(\SIGINT, \SIG_DFL);
|
||||
echo "Terminated\n";
|
||||
exit(1);
|
||||
});
|
||||
} elseif (\function_exists('sapi_windows_set_ctrl_handler')) {
|
||||
\sapi_windows_set_ctrl_handler(function () {
|
||||
echo "Terminated\n";
|
||||
exit(1);
|
||||
});
|
||||
}
|
||||
\set_time_limit(0);
|
||||
echo '
|
||||
NEON linter
|
||||
-----------
|
||||
';
|
||||
if ($argc < 2) {
|
||||
echo "Usage: neon-lint <path>\n";
|
||||
exit(1);
|
||||
}
|
||||
$ok = scanPath($argv[1]);
|
||||
exit($ok ? 0 : 1);
|
||||
function scanPath(string $path) : bool
|
||||
{
|
||||
echo "Scanning {$path}\n";
|
||||
$it = new \RecursiveDirectoryIterator($path);
|
||||
$it = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::LEAVES_ONLY);
|
||||
$it = new \RegexIterator($it, '~\\.neon$~');
|
||||
$counter = 0;
|
||||
$success = \true;
|
||||
foreach ($it as $file) {
|
||||
echo \str_pad(\str_repeat('.', $counter++ % 40), 40), "\r";
|
||||
$success = lintFile((string) $file) && $success;
|
||||
}
|
||||
echo \str_pad('', 40), "\r";
|
||||
echo "Done.\n";
|
||||
return $success;
|
||||
}
|
||||
function lintFile(string $file) : bool
|
||||
{
|
||||
\set_error_handler(function (int $severity, string $message) use($file) {
|
||||
if ($severity === \E_USER_DEPRECATED) {
|
||||
\fwrite(\STDERR, "[DEPRECATED] {$file} {$message}\n");
|
||||
return null;
|
||||
}
|
||||
return \false;
|
||||
});
|
||||
$s = \file_get_contents($file);
|
||||
if (\substr($s, 0, 3) === "") {
|
||||
\fwrite(\STDERR, "[WARNING] {$file} contains BOM\n");
|
||||
$contents = \substr($s, 3);
|
||||
}
|
||||
try {
|
||||
Nette\Neon\Neon::decode($s);
|
||||
return \true;
|
||||
} catch (Nette\Neon\Exception $e) {
|
||||
\fwrite(\STDERR, "[ERROR] {$file} {$e->getMessage()}\n");
|
||||
} finally {
|
||||
\restore_error_handler();
|
||||
}
|
||||
return \false;
|
||||
}
|
54
vendor/nette/neon/composer.json
vendored
54
vendor/nette/neon/composer.json
vendored
|
@ -1,54 +0,0 @@
|
|||
{
|
||||
"name": "nette\/neon",
|
||||
"description": "\ud83c\udf78 Nette NEON: encodes and decodes NEON file format.",
|
||||
"keywords": [
|
||||
"nette",
|
||||
"neon",
|
||||
"import",
|
||||
"export",
|
||||
"yaml"
|
||||
],
|
||||
"homepage": "https:\/\/ne-on.org",
|
||||
"license": [
|
||||
"BSD-3-Clause",
|
||||
"GPL-2.0-only",
|
||||
"GPL-3.0-only"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "David Grudl",
|
||||
"homepage": "https:\/\/davidgrudl.com"
|
||||
},
|
||||
{
|
||||
"name": "Nette Community",
|
||||
"homepage": "https:\/\/nette.org\/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.1",
|
||||
"ext-json": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"nette\/tester": "^2.0",
|
||||
"tracy\/tracy": "^2.7",
|
||||
"phpstan\/phpstan": "^0.12"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src\/"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"bin": [
|
||||
"bin\/neon-lint"
|
||||
],
|
||||
"scripts": {
|
||||
"phpstan": "phpstan analyse",
|
||||
"tester": "tester tests -s"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.3-dev"
|
||||
}
|
||||
}
|
||||
}
|
33
vendor/nette/neon/contributing.md
vendored
33
vendor/nette/neon/contributing.md
vendored
|
@ -1,33 +0,0 @@
|
|||
How to contribute & use the issue tracker
|
||||
=========================================
|
||||
|
||||
Nette welcomes your contributions. There are several ways to help out:
|
||||
|
||||
* Create an issue on GitHub, if you have found a bug
|
||||
* Write test cases for open bug issues
|
||||
* Write fixes for open bug/feature issues, preferably with test cases included
|
||||
* Contribute to the [documentation](https://nette.org/en/writing)
|
||||
|
||||
Issues
|
||||
------
|
||||
|
||||
Please **do not use the issue tracker to ask questions**. We will be happy to help you
|
||||
on [Nette forum](https://forum.nette.org) or chat with us on [Gitter](https://gitter.im/nette/nette).
|
||||
|
||||
A good bug report shouldn't leave others needing to chase you up for more
|
||||
information. Please try to be as detailed as possible in your report.
|
||||
|
||||
**Feature requests** are welcome. But take a moment to find out whether your idea
|
||||
fits with the scope and aims of the project. It's up to *you* to make a strong
|
||||
case to convince the project's developers of the merits of this feature.
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
If you'd like to contribute, please take a moment to read [the contributing guide](https://nette.org/en/contributing).
|
||||
|
||||
The best way to propose a feature is to discuss your ideas on [Nette forum](https://forum.nette.org) before implementing them.
|
||||
|
||||
Please do not fix whitespace, format code, or make a purely cosmetic patch.
|
||||
|
||||
Thanks! :heart:
|
60
vendor/nette/neon/license.md
vendored
60
vendor/nette/neon/license.md
vendored
|
@ -1,60 +0,0 @@
|
|||
Licenses
|
||||
========
|
||||
|
||||
Good news! You may use Nette Framework under the terms of either
|
||||
the New BSD License or the GNU General Public License (GPL) version 2 or 3.
|
||||
|
||||
The BSD License is recommended for most projects. It is easy to understand and it
|
||||
places almost no restrictions on what you can do with the framework. If the GPL
|
||||
fits better to your project, you can use the framework under this license.
|
||||
|
||||
You don't have to notify anyone which license you are using. You can freely
|
||||
use Nette Framework in commercial projects as long as the copyright header
|
||||
remains intact.
|
||||
|
||||
Please be advised that the name "Nette Framework" is a protected trademark and its
|
||||
usage has some limitations. So please do not use word "Nette" in the name of your
|
||||
project or top-level domain, and choose a name that stands on its own merits.
|
||||
If your stuff is good, it will not take long to establish a reputation for yourselves.
|
||||
|
||||
|
||||
New BSD License
|
||||
---------------
|
||||
|
||||
Copyright (c) 2004, 2014 David Grudl (https://davidgrudl.com)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of "Nette Framework" nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
This software is provided by the copyright holders and contributors "as is" and
|
||||
any express or implied warranties, including, but not limited to, the implied
|
||||
warranties of merchantability and fitness for a particular purpose are
|
||||
disclaimed. In no event shall the copyright owner or contributors be liable for
|
||||
any direct, indirect, incidental, special, exemplary, or consequential damages
|
||||
(including, but not limited to, procurement of substitute goods or services;
|
||||
loss of use, data, or profits; or business interruption) however caused and on
|
||||
any theory of liability, whether in contract, strict liability, or tort
|
||||
(including negligence or otherwise) arising in any way out of the use of this
|
||||
software, even if advised of the possibility of such damage.
|
||||
|
||||
|
||||
GNU General Public License
|
||||
--------------------------
|
||||
|
||||
GPL licenses are very very long, so instead of including them here we offer
|
||||
you URLs with full text:
|
||||
|
||||
- [GPL version 2](https://www.gnu.org/licenses/gpl-2.0.html)
|
||||
- [GPL version 3](https://www.gnu.org/licenses/gpl-3.0.html)
|
490
vendor/nette/neon/readme.md
vendored
490
vendor/nette/neon/readme.md
vendored
|
@ -1,490 +0,0 @@
|
|||
[NEON](https://ne-on.org): Nette Object Notation
|
||||
================================================
|
||||
|
||||
[![Downloads this Month](https://img.shields.io/packagist/dm/nette/neon.svg)](https://packagist.org/packages/nette/neon)
|
||||
[![Tests](https://github.com/nette/neon/workflows/Tests/badge.svg?branch=master)](https://github.com/nette/neon/actions)
|
||||
[![Coverage Status](https://coveralls.io/repos/github/nette/neon/badge.svg?branch=master)](https://coveralls.io/github/nette/neon?branch=master)
|
||||
[![Latest Stable Version](https://poser.pugx.org/nette/neon/v/stable)](https://github.com/nette/neon/releases)
|
||||
[![License](https://img.shields.io/badge/license-New%20BSD-blue.svg)](https://github.com/nette/neon/blob/master/license.md)
|
||||
|
||||
|
||||
Introduction
|
||||
============
|
||||
|
||||
NEON is a human-readable structured data format. In Nette, it is used for configuration files. It is also used for structured data such as settings, language translations, etc. [Try it on the sandbox](https://ne-on.org).
|
||||
|
||||
NEON stands for *Nette Object Notation*. It is less complex and ungainly than XML or JSON, but provides similar capabilities. It is very similar to YAML. The main advantage is that NEON has so-called [entities](#entities), thanks to which the configuration of DI services is so sexy. And allows tabs for indentation.
|
||||
|
||||
NEON is built from the ground up to be simple to use.
|
||||
|
||||
|
||||
[Support Neon](https://github.com/sponsors/dg)
|
||||
----------------------------------------------
|
||||
|
||||
Do you like NEON? Are you looking forward to the new features?
|
||||
|
||||
[![Buy me a coffee](https://files.nette.org/icons/donation-3.svg)](https://github.com/sponsors/dg)
|
||||
|
||||
Thank you!
|
||||
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
Install via Composer:
|
||||
|
||||
```
|
||||
composer require nette/neon
|
||||
```
|
||||
|
||||
It requires PHP version 7.1 and supports PHP up to 8.1. Documentation can be found on the [website](https://doc.nette.org/neon).
|
||||
|
||||
`Neon::encode()` returns `$value` converted to NEON. As the second parameter `$blockMode` you can pass true, which will create multiline output. The third parameter `$indentation` specifies the characters used for indentation (default is tab).
|
||||
|
||||
```php
|
||||
use Nette\Neon\Neon;
|
||||
|
||||
$neon = Neon::encode($value); // Returns $value converted to NEON
|
||||
$neon = Neon::encode($value, true); // Returns $value converted to multiline NEON
|
||||
```
|
||||
|
||||
`Neon::decode()` converts given NEON to PHP value:
|
||||
|
||||
```php
|
||||
$value = Neon::decode('hello: world'); // Returns an array ['hello' => 'world']
|
||||
```
|
||||
|
||||
`Neon::decodeFile()` converts given NEON file to PHP value:
|
||||
|
||||
```php
|
||||
$value = Neon::decodeFile('config.neon');
|
||||
```
|
||||
|
||||
All methods throw `Nette\Neon\Exception` on error.
|
||||
|
||||
|
||||
Integration
|
||||
===========
|
||||
|
||||
- NetBeans (has built-in support)
|
||||
- PhpStorm ([plugin](https://plugins.jetbrains.com/plugin/7060?pr))
|
||||
- Visual Studio Code ([plugin](https://marketplace.visualstudio.com/items?itemName=Kasik96.latte))
|
||||
- Sublime Text 3 ([plugin](https://github.com/FilipStryk/Nette-Latte-Neon-for-Sublime-Text-3))
|
||||
- Sublime Text 2 ([plugin](https://github.com/Michal-Mikolas/Nette-package-for-Sublime-Text-2))
|
||||
|
||||
|
||||
- [NEON for PHP](https://doc.nette.org/neon)
|
||||
- [NEON for JavaScript](https://github.com/matej21/neon-js)
|
||||
- [NEON for Python](https://github.com/paveldedik/neon-py).
|
||||
|
||||
|
||||
You can check for syntax errors in Neon files using the `neon-lint` console command:
|
||||
|
||||
```shell
|
||||
vendor/bin/neon-lint <path>
|
||||
```
|
||||
|
||||
Syntax
|
||||
======
|
||||
|
||||
A file written in NEON usually consists of a sequence or mapping.
|
||||
|
||||
|
||||
Mappings
|
||||
--------
|
||||
Mapping is a set of key-value pairs, in PHP it would be called an associative array. Each pair is written as `key: value`, a space after `:` is required. The value can be anything: string, number, boolean, null, sequence, or other mapping.
|
||||
|
||||
```neon
|
||||
street: 742 Evergreen Terrace
|
||||
city: Springfield
|
||||
country: USA
|
||||
```
|
||||
|
||||
In PHP, the same structure would be written as:
|
||||
|
||||
```php
|
||||
[ // PHP
|
||||
'street' => '742 Evergreen Terrace',
|
||||
'city' => 'Springfield',
|
||||
'country' => 'USA',
|
||||
]
|
||||
```
|
||||
|
||||
This notation is called a block notation because all items are on a separate line and have the same indentation (none in this case). NEON also supports inline representation for mapping, which is enclosed in brackets, indentation plays no role, and the separator of each element is either a comma or a newline:
|
||||
|
||||
```neon
|
||||
{street: 742 Evergreen Terrace, city: Springfield, country: USA}
|
||||
```
|
||||
|
||||
This is the same written on multiple lines (indentation does not matter):
|
||||
|
||||
```neon
|
||||
{
|
||||
street: 742 Evergreen Terrace
|
||||
city: Springfield, country: USA
|
||||
}
|
||||
```
|
||||
|
||||
Alternatively, `=` can be used instead of <code>: </code>, both in block and inline notation:
|
||||
|
||||
```neon
|
||||
{street=742 Evergreen Terrace, city=Springfield, country=USA}
|
||||
```
|
||||
|
||||
|
||||
Sequences
|
||||
---------
|
||||
Sequences are indexed arrays in PHP. They are written as lines starting with the hyphen `-` followed by a space. Again, the value can be anything: string, number, boolean, null, sequence, or other mapping.
|
||||
|
||||
```neon
|
||||
- Cat
|
||||
- Dog
|
||||
- Goldfish
|
||||
```
|
||||
|
||||
In PHP, the same structure would be written as:
|
||||
|
||||
```php
|
||||
[ // PHP
|
||||
'Cat',
|
||||
'Dog',
|
||||
'Goldfish',
|
||||
]
|
||||
```
|
||||
|
||||
This notation is called a block notation because all items are on a separate line and have the same indentation (none in this case). NEON also supports inline representation for sequences, which is enclosed in brackets, indentation plays no role, and the separator of each element is either a comma or a newline:
|
||||
|
||||
```neon
|
||||
[Cat, Dog, Goldfish]
|
||||
```
|
||||
|
||||
This is the same written on multiple lines (indentation does not matter):
|
||||
|
||||
```neon
|
||||
[
|
||||
Cat, Dog
|
||||
Goldfish
|
||||
]
|
||||
```
|
||||
|
||||
Hyphens cannot be used in an inline representation.
|
||||
|
||||
|
||||
Combination
|
||||
-----------
|
||||
Values of mappings and sequences may be other mappings and sequences. The level of indentation plays a major role. In the following example, the hyphen used to indicate sequence items has a greater indent than the `pets` key, so the items become the value of the first line:
|
||||
|
||||
```neon
|
||||
pets:
|
||||
- Cat
|
||||
- Dog
|
||||
cars:
|
||||
- Volvo
|
||||
- Skoda
|
||||
```
|
||||
|
||||
In PHP, the same structure would be written as:
|
||||
|
||||
```php
|
||||
[ // PHP
|
||||
'pets' => [
|
||||
'Cat',
|
||||
'Dog',
|
||||
],
|
||||
'cars' => [
|
||||
'Volvo',
|
||||
'Skoda',
|
||||
],
|
||||
]
|
||||
```
|
||||
|
||||
It is possible to combine block and inline notation:
|
||||
|
||||
```neon
|
||||
pets: [Cat, Dog]
|
||||
cars: [
|
||||
Volvo,
|
||||
Skoda,
|
||||
]
|
||||
```
|
||||
|
||||
Block notation can no longer be used inside an inline notation, this does not work:
|
||||
|
||||
```neon
|
||||
item: [
|
||||
pets:
|
||||
- Cat # THIS IS NOT POSSIBLE!!!
|
||||
- Dog
|
||||
]
|
||||
```
|
||||
|
||||
Because PHP uses the same structure for mapping and sequences, that is, arrays, both can be merged. The indentation is the same this time:
|
||||
|
||||
```neon
|
||||
- Cat
|
||||
street: 742 Evergreen Terrace
|
||||
- Goldfish
|
||||
```
|
||||
|
||||
In PHP, the same structure would be written as:
|
||||
|
||||
```php
|
||||
[ // PHP
|
||||
'Cat',
|
||||
'street' => '742 Evergreen Terrace',
|
||||
'Goldfish',
|
||||
]
|
||||
```
|
||||
|
||||
Strings
|
||||
-------
|
||||
Strings in NEON can be enclosed in single or double quotes. But as you can see, they can also be without quotes.
|
||||
|
||||
```neon
|
||||
- A unquoted string in NEON
|
||||
- 'A singled-quoted string in NEON'
|
||||
- "A double-quoted string in NEON"
|
||||
```
|
||||
|
||||
If the string contains characters that can be confused with NEON syntax (hyphens, colons, etc.), it must be enclosed in quotation marks. We recommend using single quotes because they do not use escaping. If you need to enclose a quotation mark in such a string, double it:
|
||||
|
||||
```neon
|
||||
'A single quote '' inside a single-quoted string'
|
||||
```
|
||||
|
||||
Double quotes allow you to use escape sequences to write special characters using backslashes `\`. All escape sequences as in the JSON format are supported, plus `\_`, which is an non-breaking space, ie `\u00A0`.
|
||||
|
||||
```neon
|
||||
- "\t \n \r \f \b \" \\ \/ \_"
|
||||
- "\u00A9"
|
||||
```
|
||||
|
||||
There are other cases where you need to enclose strings in quotation marks:
|
||||
- they begin or end with spaces
|
||||
- look like numbers, booleans, or null
|
||||
- NEON would understand them as [dates](#dates)
|
||||
|
||||
|
||||
Multiline strings
|
||||
-----------------
|
||||
|
||||
A multiline string begins and ends with a triple quotation mark on separate lines. The indent of the first line is ignored for all lines:
|
||||
|
||||
```neon
|
||||
'''
|
||||
first line
|
||||
second line
|
||||
third line
|
||||
'''
|
||||
```
|
||||
|
||||
In PHP we would write the same as:
|
||||
|
||||
```php
|
||||
"first line\n\tsecond line\nthird line" // PHP
|
||||
```
|
||||
|
||||
Escaping sequences only work for strings enclosed in double quotes instead of apostrophes:
|
||||
|
||||
```neon
|
||||
"""
|
||||
Copyright \u00A9
|
||||
"""
|
||||
```
|
||||
|
||||
|
||||
Numbers
|
||||
-------
|
||||
NEON understands numbers written in so-called scientific notation and also numbers in binary, octal and hexadecimal:
|
||||
|
||||
```neon
|
||||
- 12 # an integer
|
||||
- 12.3 # a float
|
||||
- +1.2e-34 # an exponential number
|
||||
|
||||
- 0b11010 # binary number
|
||||
- 0o666 # octal number
|
||||
- 0x7A # hexa number
|
||||
```
|
||||
|
||||
Nulls
|
||||
-----
|
||||
Null can be expressed in NEON by using `null` or by not specifying a value. Variants with a capital first or all uppercase letters are also allowed.
|
||||
|
||||
```neon
|
||||
a: null
|
||||
b:
|
||||
```
|
||||
|
||||
Booleans
|
||||
--------
|
||||
Boolean values are expressed in NEON using `true` / `false` or `yes` / `no`. Variants with a capital first or all uppercase letters are also allowed.
|
||||
|
||||
```neon
|
||||
[true, TRUE, True, false, yes, no]
|
||||
```
|
||||
|
||||
Dates
|
||||
-----
|
||||
NEON uses the following formats to express data and automatically converts them to `DateTimeImmutable` objects:
|
||||
|
||||
```neon
|
||||
- 2016-06-03 # date
|
||||
- 2016-06-03 19:00:00 # date & time
|
||||
- 2016-06-03 19:00:00.1234 # date & microtime
|
||||
- 2016-06-03 19:00:00 +0200 # date & time & timezone
|
||||
- 2016-06-03 19:00:00 +02:00 # date & time & timezone
|
||||
```
|
||||
|
||||
|
||||
Entities
|
||||
--------
|
||||
An entity is a structure that resembles a function call:
|
||||
|
||||
```neon
|
||||
Column(type: int, nulls: yes)
|
||||
```
|
||||
|
||||
In PHP, it is parsed as an object [Nette\Neon\Entity](https://api.nette.org/3.0/Nette/Neon/Entity.html):
|
||||
|
||||
```php
|
||||
// PHP
|
||||
new Nette\Neon\Entity('Column', ['type' => 'int', 'nulls' => true])
|
||||
```
|
||||
|
||||
Entities can also be chained:
|
||||
|
||||
```neon
|
||||
Column(type: int, nulls: yes) Field(id: 1)
|
||||
```
|
||||
|
||||
Which is parsed in PHP as follows:
|
||||
|
||||
```php
|
||||
// PHP
|
||||
new Nette\Neon\Entity(Nette\Neon\Neon::Chain, [
|
||||
new Nette\Neon\Entity('Column', ['type' => 'int', 'nulls' => true]),
|
||||
new Nette\Neon\Entity('Field', ['id' => 1]),
|
||||
])
|
||||
```
|
||||
|
||||
Inside the parentheses, the rules for inline notation used for mapping and sequences apply, so it can be divided into several lines and it is not necessary to add commas:
|
||||
|
||||
```neon
|
||||
Column(
|
||||
type: int
|
||||
nulls: yes
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
Comments
|
||||
--------
|
||||
Comments start with `#` and all of the following characters on the right are ignored:
|
||||
|
||||
```neon
|
||||
# this line will be ignored by the interpreter
|
||||
street: 742 Evergreen Terrace
|
||||
city: Springfield # this is ignored too
|
||||
country: USA
|
||||
```
|
||||
|
||||
|
||||
NEON versus JSON
|
||||
================
|
||||
JSON is a subset of NEON. Each JSON can therefore be parsed as NEON:
|
||||
|
||||
```neon
|
||||
{
|
||||
"php": {
|
||||
"date.timezone": "Europe\/Prague",
|
||||
"zlib.output_compression": true
|
||||
},
|
||||
"database": {
|
||||
"driver": "mysql",
|
||||
"username": "root",
|
||||
"password": "beruska92"
|
||||
},
|
||||
"users": [
|
||||
"Dave", "Kryten", "Rimmer"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
What if we could omit quotes?
|
||||
|
||||
```neon
|
||||
{
|
||||
php: {
|
||||
date.timezone: Europe/Prague,
|
||||
zlib.output_compression: true
|
||||
},
|
||||
database: {
|
||||
driver: mysql,
|
||||
username: root,
|
||||
password: beruska92
|
||||
},
|
||||
users: [
|
||||
Dave, Kryten, Rimmer
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
How about braces and commas?
|
||||
|
||||
```neon
|
||||
php:
|
||||
date.timezone: Europe/Prague
|
||||
zlib.output_compression: true
|
||||
|
||||
database:
|
||||
driver: mysql
|
||||
username: root
|
||||
password: beruska92
|
||||
|
||||
users: [
|
||||
Dave, Kryten, Rimmer
|
||||
]
|
||||
```
|
||||
|
||||
Are bullets more legible?
|
||||
|
||||
```neon
|
||||
php:
|
||||
date.timezone: Europe/Prague
|
||||
zlib.output_compression: true
|
||||
|
||||
database:
|
||||
driver: mysql
|
||||
username: root
|
||||
password: beruska92
|
||||
|
||||
users:
|
||||
- Dave
|
||||
- Kryten
|
||||
- Rimmer
|
||||
```
|
||||
|
||||
How about comments?
|
||||
|
||||
```neon
|
||||
# my web application config
|
||||
|
||||
php:
|
||||
date.timezone: Europe/Prague
|
||||
zlib.output_compression: true # use gzip
|
||||
|
||||
database:
|
||||
driver: mysql
|
||||
username: root
|
||||
password: beruska92
|
||||
|
||||
users:
|
||||
- Dave
|
||||
- Kryten
|
||||
- Rimmer
|
||||
```
|
||||
|
||||
You found NEON syntax!
|
||||
|
||||
If you like NEON, **[please make a donation now](https://github.com/sponsors/dg)**. Thank you!
|
32
vendor/nette/neon/src/Neon/Decoder.php
vendored
32
vendor/nette/neon/src/Neon/Decoder.php
vendored
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208\Nette\Neon;
|
||||
|
||||
/**
|
||||
* Parser for Nette Object Notation.
|
||||
* @internal
|
||||
*/
|
||||
final class Decoder
|
||||
{
|
||||
/**
|
||||
* Decodes a NEON string.
|
||||
* @return mixed
|
||||
*/
|
||||
public function decode(string $input)
|
||||
{
|
||||
$node = $this->parseToNode($input);
|
||||
return $node->toValue();
|
||||
}
|
||||
public function parseToNode(string $input) : Node
|
||||
{
|
||||
$lexer = new Lexer();
|
||||
$parser = new Parser();
|
||||
$tokens = $lexer->tokenize($input);
|
||||
return $parser->parse($tokens);
|
||||
}
|
||||
}
|
77
vendor/nette/neon/src/Neon/Encoder.php
vendored
77
vendor/nette/neon/src/Neon/Encoder.php
vendored
|
@ -1,77 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208\Nette\Neon;
|
||||
|
||||
/**
|
||||
* Converts value to NEON format.
|
||||
* @internal
|
||||
*/
|
||||
final class Encoder
|
||||
{
|
||||
/** @deprecated */
|
||||
public const BLOCK = \true;
|
||||
/** @var bool */
|
||||
public $blockMode = \false;
|
||||
/** @var string */
|
||||
public $indentation = "\t";
|
||||
/**
|
||||
* Returns the NEON representation of a value.
|
||||
*/
|
||||
public function encode($val) : string
|
||||
{
|
||||
$node = $this->valueToNode($val, $this->blockMode);
|
||||
return $node->toString();
|
||||
}
|
||||
public function valueToNode($val, bool $blockMode = \false) : Node
|
||||
{
|
||||
if ($val instanceof \DateTimeInterface) {
|
||||
return new Node\LiteralNode($val);
|
||||
} elseif ($val instanceof Entity && $val->value === Neon::Chain) {
|
||||
$node = new Node\EntityChainNode();
|
||||
foreach ($val->attributes as $entity) {
|
||||
$node->chain[] = $this->valueToNode($entity);
|
||||
}
|
||||
return $node;
|
||||
} elseif ($val instanceof Entity) {
|
||||
return new Node\EntityNode($this->valueToNode($val->value), $this->arrayToNodes((array) $val->attributes));
|
||||
} elseif (\is_object($val) || \is_array($val)) {
|
||||
if ($blockMode) {
|
||||
$node = new Node\BlockArrayNode();
|
||||
} else {
|
||||
$isList = \is_array($val) && (!$val || \array_keys($val) === \range(0, \count($val) - 1));
|
||||
$node = new Node\InlineArrayNode($isList ? '[' : '{');
|
||||
}
|
||||
$node->items = $this->arrayToNodes($val, $blockMode);
|
||||
return $node;
|
||||
} elseif (\is_string($val) && Lexer::requiresDelimiters($val)) {
|
||||
return new Node\StringNode($val);
|
||||
} else {
|
||||
return new Node\LiteralNode($val);
|
||||
}
|
||||
}
|
||||
/** @return Node\ArrayItemNode[] */
|
||||
private function arrayToNodes($val, bool $blockMode = \false) : array
|
||||
{
|
||||
$res = [];
|
||||
$counter = 0;
|
||||
$hide = \true;
|
||||
foreach ($val as $k => $v) {
|
||||
$res[] = $item = new Node\ArrayItemNode();
|
||||
$item->key = $hide && $k === $counter ? null : self::valueToNode($k);
|
||||
$item->value = self::valueToNode($v, $blockMode);
|
||||
if ($item->value instanceof Node\BlockArrayNode) {
|
||||
$item->value->indentation = $this->indentation;
|
||||
}
|
||||
if ($hide && \is_int($k)) {
|
||||
$hide = $k === $counter;
|
||||
$counter = \max($k + 1, $counter);
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
29
vendor/nette/neon/src/Neon/Entity.php
vendored
29
vendor/nette/neon/src/Neon/Entity.php
vendored
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208\Nette\Neon;
|
||||
|
||||
/**
|
||||
* Representation of NEON entity 'foo(bar=1)'
|
||||
*/
|
||||
final class Entity extends \stdClass
|
||||
{
|
||||
/** @var mixed */
|
||||
public $value;
|
||||
/** @var mixed[] */
|
||||
public $attributes;
|
||||
public function __construct($value, array $attrs = [])
|
||||
{
|
||||
$this->value = $value;
|
||||
$this->attributes = $attrs;
|
||||
}
|
||||
/** @param mixed[] $properties */
|
||||
public static function __set_state(array $properties)
|
||||
{
|
||||
return new self($properties['value'], $properties['attributes']);
|
||||
}
|
||||
}
|
15
vendor/nette/neon/src/Neon/Exception.php
vendored
15
vendor/nette/neon/src/Neon/Exception.php
vendored
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208\Nette\Neon;
|
||||
|
||||
/**
|
||||
* The exception that indicates error of NEON processing.
|
||||
*/
|
||||
class Exception extends \Exception
|
||||
{
|
||||
}
|
76
vendor/nette/neon/src/Neon/Lexer.php
vendored
76
vendor/nette/neon/src/Neon/Lexer.php
vendored
|
@ -1,76 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208\Nette\Neon;
|
||||
|
||||
/** @internal */
|
||||
final class Lexer
|
||||
{
|
||||
public const Patterns = [
|
||||
// strings
|
||||
Token::String => '
|
||||
\'\'\'\\n (?:(?: [^\\n] | \\n(?![\\t\\ ]*+\'\'\') )*+ \\n)?[\\t\\ ]*+\'\'\' |
|
||||
"""\\n (?:(?: [^\\n] | \\n(?![\\t\\ ]*+""") )*+ \\n)?[\\t\\ ]*+""" |
|
||||
\' (?: \'\' | [^\'\\n] )*+ \' |
|
||||
" (?: \\\\. | [^"\\\\\\n] )*+ "
|
||||
',
|
||||
// literal / boolean / integer / float
|
||||
Token::Literal => '
|
||||
(?: [^#"\',:=[\\]{}()\\n\\t\\ `-] | (?<!["\']) [:-] [^"\',=[\\]{}()\\n\\t\\ ] )
|
||||
(?:
|
||||
[^,:=\\]})(\\n\\t\\ ]++ |
|
||||
:(?! [\\n\\t\\ ,\\]})] | $ ) |
|
||||
[\\ \\t]++ [^#,:=\\]})(\\n\\t\\ ]
|
||||
)*+
|
||||
',
|
||||
// punctuation
|
||||
Token::Char => '[,:=[\\]{}()-]',
|
||||
// comment
|
||||
Token::Comment => '\\#.*+',
|
||||
// new line
|
||||
Token::Newline => '\\n++',
|
||||
// whitespace
|
||||
Token::Whitespace => '[\\t\\ ]++',
|
||||
];
|
||||
public function tokenize(string $input) : TokenStream
|
||||
{
|
||||
$input = \str_replace("\r", '', $input);
|
||||
$pattern = '~(' . \implode(')|(', self::Patterns) . ')~Amixu';
|
||||
$res = \preg_match_all($pattern, $input, $tokens, \PREG_SET_ORDER);
|
||||
if ($res === \false) {
|
||||
throw new Exception('Invalid UTF-8 sequence.');
|
||||
}
|
||||
$types = \array_keys(self::Patterns);
|
||||
$offset = 0;
|
||||
foreach ($tokens as &$token) {
|
||||
$type = null;
|
||||
for ($i = 1; $i <= \count($types); $i++) {
|
||||
if (!isset($token[$i])) {
|
||||
break;
|
||||
} elseif ($token[$i] !== '') {
|
||||
$type = $types[$i - 1];
|
||||
if ($type === Token::Char) {
|
||||
$type = $token[0];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$token = new Token($token[0], $type);
|
||||
$offset += \strlen($token->value);
|
||||
}
|
||||
$stream = new TokenStream($tokens);
|
||||
if ($offset !== \strlen($input)) {
|
||||
$s = \str_replace("\n", '\\n', \substr($input, $offset, 40));
|
||||
$stream->error("Unexpected '{$s}'", \count($tokens));
|
||||
}
|
||||
return $stream;
|
||||
}
|
||||
public static function requiresDelimiters(string $s) : bool
|
||||
{
|
||||
return \preg_match('~[\\x00-\\x1F]|^[+-.]?\\d|^(true|false|yes|no|on|off|null)$~Di', $s) || !\preg_match('~^' . self::Patterns[Token::Literal] . '$~Dx', $s);
|
||||
}
|
||||
}
|
54
vendor/nette/neon/src/Neon/Neon.php
vendored
54
vendor/nette/neon/src/Neon/Neon.php
vendored
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208\Nette\Neon;
|
||||
|
||||
/**
|
||||
* Simple parser & generator for Nette Object Notation.
|
||||
* @see https://ne-on.org
|
||||
*/
|
||||
final class Neon
|
||||
{
|
||||
public const BLOCK = Encoder::BLOCK;
|
||||
public const Chain = '!!chain';
|
||||
public const CHAIN = self::Chain;
|
||||
/**
|
||||
* Returns value converted to NEON.
|
||||
*/
|
||||
public static function encode($value, bool $blockMode = \false, string $indentation = "\t") : string
|
||||
{
|
||||
$encoder = new Encoder();
|
||||
$encoder->blockMode = $blockMode;
|
||||
$encoder->indentation = $indentation;
|
||||
return $encoder->encode($value);
|
||||
}
|
||||
/**
|
||||
* Converts given NEON to PHP value.
|
||||
* @return mixed
|
||||
*/
|
||||
public static function decode(string $input)
|
||||
{
|
||||
$decoder = new Decoder();
|
||||
return $decoder->decode($input);
|
||||
}
|
||||
/**
|
||||
* Converts given NEON file to PHP value.
|
||||
* @return mixed
|
||||
*/
|
||||
public static function decodeFile(string $file)
|
||||
{
|
||||
if (!\is_file($file)) {
|
||||
throw new Exception("File '{$file}' does not exist.");
|
||||
}
|
||||
$input = \file_get_contents($file);
|
||||
if (\substr($input, 0, 3) === "") {
|
||||
// BOM
|
||||
$input = \substr($input, 3);
|
||||
}
|
||||
return self::decode($input);
|
||||
}
|
||||
}
|
31
vendor/nette/neon/src/Neon/Node.php
vendored
31
vendor/nette/neon/src/Neon/Node.php
vendored
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208\Nette\Neon;
|
||||
|
||||
/**
|
||||
* @implements \IteratorAggregate<Node>
|
||||
*/
|
||||
abstract class Node implements \IteratorAggregate
|
||||
{
|
||||
/** @var ?int */
|
||||
public $startTokenPos;
|
||||
/** @var ?int */
|
||||
public $endTokenPos;
|
||||
/** @var ?int */
|
||||
public $startLine;
|
||||
/** @var ?int */
|
||||
public $endLine;
|
||||
/** @return mixed */
|
||||
public abstract function toValue();
|
||||
public abstract function toString() : string;
|
||||
public function &getIterator() : \Generator
|
||||
{
|
||||
return;
|
||||
yield;
|
||||
}
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208\Nette\Neon\Node;
|
||||
|
||||
use RectorPrefix202208\Nette\Neon\Node;
|
||||
/** @internal */
|
||||
final class ArrayItemNode extends Node
|
||||
{
|
||||
/** @var ?Node */
|
||||
public $key;
|
||||
/** @var Node */
|
||||
public $value;
|
||||
/**
|
||||
* @param self[] $items
|
||||
* @return mixed[]
|
||||
*/
|
||||
public static function itemsToArray(array $items) : array
|
||||
{
|
||||
$res = [];
|
||||
foreach ($items as $item) {
|
||||
if ($item->key === null) {
|
||||
$res[] = $item->value->toValue();
|
||||
} else {
|
||||
$res[(string) $item->key->toValue()] = $item->value->toValue();
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/** @param self[] $items */
|
||||
public static function itemsToInlineString(array $items) : string
|
||||
{
|
||||
$res = '';
|
||||
foreach ($items as $item) {
|
||||
$res .= ($res === '' ? '' : ', ') . ($item->key ? $item->key->toString() . ': ' : '') . $item->value->toString();
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/** @param self[] $items */
|
||||
public static function itemsToBlockString(array $items) : string
|
||||
{
|
||||
$res = '';
|
||||
foreach ($items as $item) {
|
||||
$v = $item->value->toString();
|
||||
$res .= ($item->key ? $item->key->toString() . ':' : '-') . ($item->value instanceof BlockArrayNode && $item->value->items ? "\n" . $v . (\substr($v, -2, 1) === "\n" ? '' : "\n") : ' ' . $v . "\n");
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
public function toValue()
|
||||
{
|
||||
throw new \LogicException();
|
||||
}
|
||||
public function toString() : string
|
||||
{
|
||||
throw new \LogicException();
|
||||
}
|
||||
public function &getIterator() : \Generator
|
||||
{
|
||||
if ($this->key) {
|
||||
(yield $this->key);
|
||||
}
|
||||
(yield $this->value);
|
||||
}
|
||||
}
|
27
vendor/nette/neon/src/Neon/Node/ArrayNode.php
vendored
27
vendor/nette/neon/src/Neon/Node/ArrayNode.php
vendored
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208\Nette\Neon\Node;
|
||||
|
||||
use RectorPrefix202208\Nette\Neon\Node;
|
||||
/** @internal */
|
||||
abstract class ArrayNode extends Node
|
||||
{
|
||||
/** @var ArrayItemNode[] */
|
||||
public $items = [];
|
||||
/** @return mixed[] */
|
||||
public function toValue() : array
|
||||
{
|
||||
return ArrayItemNode::itemsToArray($this->items);
|
||||
}
|
||||
public function &getIterator() : \Generator
|
||||
{
|
||||
foreach ($this->items as &$item) {
|
||||
(yield $item);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208\Nette\Neon\Node;
|
||||
|
||||
/** @internal */
|
||||
final class BlockArrayNode extends ArrayNode
|
||||
{
|
||||
/** @var string */
|
||||
public $indentation;
|
||||
public function __construct(string $indentation = '')
|
||||
{
|
||||
$this->indentation = $indentation;
|
||||
}
|
||||
public function toString() : string
|
||||
{
|
||||
if (\count($this->items) === 0) {
|
||||
return '[]';
|
||||
}
|
||||
$res = ArrayItemNode::itemsToBlockString($this->items);
|
||||
return \preg_replace('#^(?=.)#m', $this->indentation, $res);
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208\Nette\Neon\Node;
|
||||
|
||||
use RectorPrefix202208\Nette\Neon;
|
||||
use RectorPrefix202208\Nette\Neon\Node;
|
||||
/** @internal */
|
||||
final class EntityChainNode extends Node
|
||||
{
|
||||
/** @var EntityNode[] */
|
||||
public $chain = [];
|
||||
public function __construct(array $chain = [])
|
||||
{
|
||||
$this->chain = $chain;
|
||||
}
|
||||
public function toValue() : Neon\Entity
|
||||
{
|
||||
$entities = [];
|
||||
foreach ($this->chain as $item) {
|
||||
$entities[] = $item->toValue();
|
||||
}
|
||||
return new Neon\Entity(Neon\Neon::Chain, $entities);
|
||||
}
|
||||
public function toString() : string
|
||||
{
|
||||
return \implode('', \array_map(function ($entity) {
|
||||
return $entity->toString();
|
||||
}, $this->chain));
|
||||
}
|
||||
public function &getIterator() : \Generator
|
||||
{
|
||||
foreach ($this->chain as &$item) {
|
||||
(yield $item);
|
||||
}
|
||||
}
|
||||
}
|
39
vendor/nette/neon/src/Neon/Node/EntityNode.php
vendored
39
vendor/nette/neon/src/Neon/Node/EntityNode.php
vendored
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208\Nette\Neon\Node;
|
||||
|
||||
use RectorPrefix202208\Nette\Neon\Entity;
|
||||
use RectorPrefix202208\Nette\Neon\Node;
|
||||
/** @internal */
|
||||
final class EntityNode extends Node
|
||||
{
|
||||
/** @var Node */
|
||||
public $value;
|
||||
/** @var ArrayItemNode[] */
|
||||
public $attributes;
|
||||
public function __construct(Node $value, array $attributes = [])
|
||||
{
|
||||
$this->value = $value;
|
||||
$this->attributes = $attributes;
|
||||
}
|
||||
public function toValue() : Entity
|
||||
{
|
||||
return new Entity($this->value->toValue(), ArrayItemNode::itemsToArray($this->attributes));
|
||||
}
|
||||
public function toString() : string
|
||||
{
|
||||
return $this->value->toString() . '(' . ($this->attributes ? ArrayItemNode::itemsToInlineString($this->attributes) : '') . ')';
|
||||
}
|
||||
public function &getIterator() : \Generator
|
||||
{
|
||||
(yield $this->value);
|
||||
foreach ($this->attributes as &$item) {
|
||||
(yield $item);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208\Nette\Neon\Node;
|
||||
|
||||
/** @internal */
|
||||
final class InlineArrayNode extends ArrayNode
|
||||
{
|
||||
/** @var string */
|
||||
public $bracket;
|
||||
public function __construct(string $bracket)
|
||||
{
|
||||
$this->bracket = $bracket;
|
||||
}
|
||||
public function toString() : string
|
||||
{
|
||||
return $this->bracket . ArrayItemNode::itemsToInlineString($this->items) . ['[' => ']', '{' => '}', '(' => ')'][$this->bracket];
|
||||
}
|
||||
}
|
67
vendor/nette/neon/src/Neon/Node/LiteralNode.php
vendored
67
vendor/nette/neon/src/Neon/Node/LiteralNode.php
vendored
|
@ -1,67 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208\Nette\Neon\Node;
|
||||
|
||||
use RectorPrefix202208\Nette\Neon\Node;
|
||||
/** @internal */
|
||||
final class LiteralNode extends Node
|
||||
{
|
||||
private const SimpleTypes = ['true' => \true, 'True' => \true, 'TRUE' => \true, 'yes' => \true, 'Yes' => \true, 'YES' => \true, 'on' => \true, 'On' => \true, 'ON' => \true, 'false' => \false, 'False' => \false, 'FALSE' => \false, 'no' => \false, 'No' => \false, 'NO' => \false, 'off' => \false, 'Off' => \false, 'OFF' => \false, 'null' => null, 'Null' => null, 'NULL' => null];
|
||||
private const DeprecatedTypes = ['on' => 1, 'On' => 1, 'ON' => 1, 'off' => 1, 'Off' => 1, 'OFF' => 1];
|
||||
private const PatternDatetime = '#\\d\\d\\d\\d-\\d\\d?-\\d\\d?(?:(?:[Tt]| ++)\\d\\d?:\\d\\d:\\d\\d(?:\\.\\d*+)? *+(?:Z|[-+]\\d\\d?(?::?\\d\\d)?)?)?$#DA';
|
||||
private const PatternHex = '#0x[0-9a-fA-F]++$#DA';
|
||||
private const PatternOctal = '#0o[0-7]++$#DA';
|
||||
private const PatternBinary = '#0b[0-1]++$#DA';
|
||||
/** @var mixed */
|
||||
public $value;
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
public function toValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
/** @return mixed */
|
||||
public static function parse(string $value, bool $isKey = \false)
|
||||
{
|
||||
if (!$isKey && \array_key_exists($value, self::SimpleTypes)) {
|
||||
if (isset(self::DeprecatedTypes[$value])) {
|
||||
\trigger_error("Neon: keyword '{$value}' is deprecated, use true/yes or false/no.", \E_USER_DEPRECATED);
|
||||
}
|
||||
return self::SimpleTypes[$value];
|
||||
} elseif (\is_numeric($value)) {
|
||||
return $value * 1;
|
||||
} elseif (\preg_match(self::PatternHex, $value)) {
|
||||
return \hexdec($value);
|
||||
} elseif (\preg_match(self::PatternOctal, $value)) {
|
||||
return \octdec($value);
|
||||
} elseif (\preg_match(self::PatternBinary, $value)) {
|
||||
return \bindec($value);
|
||||
} elseif (!$isKey && \preg_match(self::PatternDatetime, $value)) {
|
||||
return new \DateTimeImmutable($value);
|
||||
} else {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
public function toString() : string
|
||||
{
|
||||
if ($this->value instanceof \DateTimeInterface) {
|
||||
return $this->value->format('Y-m-d H:i:s O');
|
||||
} elseif (\is_string($this->value)) {
|
||||
return $this->value;
|
||||
} elseif (\is_float($this->value)) {
|
||||
$res = \json_encode($this->value);
|
||||
return \strpos($res, '.') === \false ? $res . '.0' : $res;
|
||||
} elseif (\is_int($this->value) || \is_bool($this->value) || $this->value === null) {
|
||||
return \json_encode($this->value);
|
||||
} else {
|
||||
throw new \LogicException();
|
||||
}
|
||||
}
|
||||
}
|
77
vendor/nette/neon/src/Neon/Node/StringNode.php
vendored
77
vendor/nette/neon/src/Neon/Node/StringNode.php
vendored
|
@ -1,77 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208\Nette\Neon\Node;
|
||||
|
||||
use RectorPrefix202208\Nette;
|
||||
use RectorPrefix202208\Nette\Neon\Node;
|
||||
/** @internal */
|
||||
final class StringNode extends Node
|
||||
{
|
||||
private const EscapeSequences = ['t' => "\t", 'n' => "\n", 'r' => "\r", 'f' => "\f", 'b' => "\x08", '"' => '"', '\\' => '\\', '/' => '/', '_' => " "];
|
||||
/** @var string */
|
||||
public $value;
|
||||
public function __construct(string $value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
public function toValue() : string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
public static function parse(string $s) : string
|
||||
{
|
||||
if (\preg_match('#^...\\n++([\\t ]*+)#', $s, $m)) {
|
||||
// multiline
|
||||
$res = \substr($s, 3, -3);
|
||||
$res = \str_replace("\n" . $m[1], "\n", $res);
|
||||
$res = \preg_replace('#^\\n|\\n[\\t ]*+$#D', '', $res);
|
||||
} else {
|
||||
$res = \substr($s, 1, -1);
|
||||
if ($s[0] === "'") {
|
||||
$res = \str_replace("''", "'", $res);
|
||||
}
|
||||
}
|
||||
if ($s[0] === "'") {
|
||||
return $res;
|
||||
}
|
||||
return \preg_replace_callback('#\\\\(?:ud[89ab][0-9a-f]{2}\\\\ud[c-f][0-9a-f]{2}|u[0-9a-f]{4}|x[0-9a-f]{2}|.)#i', function (array $m) : string {
|
||||
$sq = $m[0];
|
||||
if (isset(self::EscapeSequences[$sq[1]])) {
|
||||
return self::EscapeSequences[$sq[1]];
|
||||
} elseif ($sq[1] === 'u' && \strlen($sq) >= 6) {
|
||||
if (($res = \json_decode('"' . $sq . '"')) !== null) {
|
||||
return $res;
|
||||
}
|
||||
throw new Nette\Neon\Exception("Invalid UTF-8 sequence {$sq}");
|
||||
} elseif ($sq[1] === 'x' && \strlen($sq) === 4) {
|
||||
\trigger_error("Neon: '{$sq}' is deprecated, use '\\uXXXX' instead.", \E_USER_DEPRECATED);
|
||||
return \chr(\hexdec(\substr($sq, 2)));
|
||||
} else {
|
||||
throw new Nette\Neon\Exception("Invalid escaping sequence {$sq}");
|
||||
}
|
||||
}, $res);
|
||||
}
|
||||
public function toString() : string
|
||||
{
|
||||
if (\strpos($this->value, "\n") === \false) {
|
||||
return "'" . \str_replace("'", "''", $this->value) . "'";
|
||||
} elseif (\preg_match('~\\n[\\t ]+\'{3}~', $this->value)) {
|
||||
$s = \json_encode($this->value, \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES);
|
||||
$s = \preg_replace_callback('#[^\\\\]|\\\\(.)#s', function ($m) {
|
||||
return ['n' => "\n", 't' => "\t", '"' => '"'][$m[1] ?? ''] ?? $m[0];
|
||||
}, \substr($s, 1, -1));
|
||||
$s = \str_replace('"""', '""\\"', $s);
|
||||
$delim = '"""';
|
||||
} else {
|
||||
$s = $this->value;
|
||||
$delim = "'''";
|
||||
}
|
||||
$s = \preg_replace('#^(?=.)#m', "\t", $s);
|
||||
return $delim . "\n" . $s . "\n" . $delim;
|
||||
}
|
||||
}
|
209
vendor/nette/neon/src/Neon/Parser.php
vendored
209
vendor/nette/neon/src/Neon/Parser.php
vendored
|
@ -1,209 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208\Nette\Neon;
|
||||
|
||||
/** @internal */
|
||||
final class Parser
|
||||
{
|
||||
/** @var TokenStream */
|
||||
private $tokens;
|
||||
/** @var int[] */
|
||||
private $posToLine = [];
|
||||
public function parse(TokenStream $tokens) : Node
|
||||
{
|
||||
$this->tokens = $tokens;
|
||||
$this->initLines();
|
||||
while ($this->tokens->consume(Token::Newline)) {
|
||||
}
|
||||
$node = $this->parseBlock($this->tokens->getIndentation());
|
||||
while ($this->tokens->consume(Token::Newline)) {
|
||||
}
|
||||
if ($this->tokens->isNext()) {
|
||||
$this->tokens->error();
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
private function parseBlock(string $indent, bool $onlyBullets = \false) : Node
|
||||
{
|
||||
$res = new Node\BlockArrayNode($indent);
|
||||
$this->injectPos($res);
|
||||
$keyCheck = [];
|
||||
loop:
|
||||
$item = new Node\ArrayItemNode();
|
||||
$this->injectPos($item);
|
||||
if ($this->tokens->consume('-')) {
|
||||
// continue
|
||||
} elseif (!$this->tokens->isNext() || $onlyBullets) {
|
||||
return $res->items ? $res : $this->injectPos(new Node\LiteralNode(null));
|
||||
} else {
|
||||
$value = $this->parseValue();
|
||||
if ($this->tokens->consume(':', '=')) {
|
||||
$this->checkArrayKey($value, $keyCheck);
|
||||
$item->key = $value;
|
||||
} else {
|
||||
if ($res->items) {
|
||||
$this->tokens->error();
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
$res->items[] = $item;
|
||||
$item->value = new Node\LiteralNode(null);
|
||||
$this->injectPos($item->value);
|
||||
if ($this->tokens->consume(Token::Newline)) {
|
||||
while ($this->tokens->consume(Token::Newline)) {
|
||||
}
|
||||
$nextIndent = $this->tokens->getIndentation();
|
||||
if (\strncmp($nextIndent, $indent, \min(\strlen($nextIndent), \strlen($indent)))) {
|
||||
$this->tokens->error('Invalid combination of tabs and spaces');
|
||||
} elseif (\strlen($nextIndent) > \strlen($indent)) {
|
||||
// open new block
|
||||
$item->value = $this->parseBlock($nextIndent);
|
||||
} elseif (\strlen($nextIndent) < \strlen($indent)) {
|
||||
// close block
|
||||
return $res;
|
||||
} elseif ($item->key !== null && $this->tokens->isNext('-')) {
|
||||
// special dash subblock
|
||||
$item->value = $this->parseBlock($indent, \true);
|
||||
}
|
||||
} elseif ($item->key === null) {
|
||||
$item->value = $this->parseBlock($indent . ' ');
|
||||
// open new block after dash
|
||||
} elseif ($this->tokens->isNext()) {
|
||||
$item->value = $this->parseValue();
|
||||
if ($this->tokens->isNext() && !$this->tokens->isNext(Token::Newline)) {
|
||||
$this->tokens->error();
|
||||
}
|
||||
}
|
||||
if ($item->value instanceof Node\BlockArrayNode) {
|
||||
$item->value->indentation = \substr($item->value->indentation, \strlen($indent));
|
||||
}
|
||||
$this->injectPos($res, $res->startTokenPos, $item->value->endTokenPos);
|
||||
$this->injectPos($item, $item->startTokenPos, $item->value->endTokenPos);
|
||||
while ($this->tokens->consume(Token::Newline)) {
|
||||
}
|
||||
if (!$this->tokens->isNext()) {
|
||||
return $res;
|
||||
}
|
||||
$nextIndent = $this->tokens->getIndentation();
|
||||
if (\strncmp($nextIndent, $indent, \min(\strlen($nextIndent), \strlen($indent)))) {
|
||||
$this->tokens->error('Invalid combination of tabs and spaces');
|
||||
} elseif (\strlen($nextIndent) > \strlen($indent)) {
|
||||
$this->tokens->error('Bad indentation');
|
||||
} elseif (\strlen($nextIndent) < \strlen($indent)) {
|
||||
// close block
|
||||
return $res;
|
||||
}
|
||||
goto loop;
|
||||
}
|
||||
private function parseValue() : Node
|
||||
{
|
||||
if ($token = $this->tokens->consume(Token::String)) {
|
||||
try {
|
||||
$node = new Node\StringNode(Node\StringNode::parse($token->value));
|
||||
$this->injectPos($node, $this->tokens->getPos() - 1);
|
||||
} catch (Exception $e) {
|
||||
$this->tokens->error($e->getMessage(), $this->tokens->getPos() - 1);
|
||||
}
|
||||
} elseif ($token = $this->tokens->consume(Token::Literal)) {
|
||||
$pos = $this->tokens->getPos() - 1;
|
||||
$node = new Node\LiteralNode(Node\LiteralNode::parse($token->value, $this->tokens->isNext(':', '=')));
|
||||
$this->injectPos($node, $pos);
|
||||
} elseif ($this->tokens->isNext('[', '(', '{')) {
|
||||
$node = $this->parseBraces();
|
||||
} else {
|
||||
$this->tokens->error();
|
||||
}
|
||||
return $this->parseEntity($node);
|
||||
}
|
||||
private function parseEntity(Node $node) : Node
|
||||
{
|
||||
if (!$this->tokens->isNext('(')) {
|
||||
return $node;
|
||||
}
|
||||
$attributes = $this->parseBraces();
|
||||
$entities[] = $this->injectPos(new Node\EntityNode($node, $attributes->items), $node->startTokenPos, $attributes->endTokenPos);
|
||||
while ($token = $this->tokens->consume(Token::Literal)) {
|
||||
$valueNode = new Node\LiteralNode(Node\LiteralNode::parse($token->value));
|
||||
$this->injectPos($valueNode, $this->tokens->getPos() - 1);
|
||||
if ($this->tokens->isNext('(')) {
|
||||
$attributes = $this->parseBraces();
|
||||
$entities[] = $this->injectPos(new Node\EntityNode($valueNode, $attributes->items), $valueNode->startTokenPos, $attributes->endTokenPos);
|
||||
} else {
|
||||
$entities[] = $this->injectPos(new Node\EntityNode($valueNode), $valueNode->startTokenPos);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return \count($entities) === 1 ? $entities[0] : $this->injectPos(new Node\EntityChainNode($entities), $node->startTokenPos, \end($entities)->endTokenPos);
|
||||
}
|
||||
private function parseBraces() : Node\InlineArrayNode
|
||||
{
|
||||
$token = $this->tokens->consume();
|
||||
$endBrace = ['[' => ']', '{' => '}', '(' => ')'][$token->value];
|
||||
$res = new Node\InlineArrayNode($token->value);
|
||||
$this->injectPos($res, $this->tokens->getPos() - 1);
|
||||
$keyCheck = [];
|
||||
loop:
|
||||
while ($this->tokens->consume(Token::Newline)) {
|
||||
}
|
||||
if ($this->tokens->consume($endBrace)) {
|
||||
$this->injectPos($res, $res->startTokenPos, $this->tokens->getPos() - 1);
|
||||
return $res;
|
||||
}
|
||||
$res->items[] = $item = new Node\ArrayItemNode();
|
||||
$this->injectPos($item, $this->tokens->getPos());
|
||||
$value = $this->parseValue();
|
||||
if ($this->tokens->consume(':', '=')) {
|
||||
$this->checkArrayKey($value, $keyCheck);
|
||||
$item->key = $value;
|
||||
$item->value = $this->tokens->isNext(Token::Newline, ',', $endBrace) ? $this->injectPos(new Node\LiteralNode(null), $this->tokens->getPos()) : $this->parseValue();
|
||||
} else {
|
||||
$item->value = $value;
|
||||
}
|
||||
$this->injectPos($item, $item->startTokenPos, $item->value->endTokenPos);
|
||||
if ($this->tokens->consume(',', Token::Newline)) {
|
||||
goto loop;
|
||||
}
|
||||
while ($this->tokens->consume(Token::Newline)) {
|
||||
}
|
||||
if (!$this->tokens->isNext($endBrace)) {
|
||||
$this->tokens->error();
|
||||
}
|
||||
goto loop;
|
||||
}
|
||||
/** @param true[] $arr */
|
||||
private function checkArrayKey(Node $key, array &$arr) : void
|
||||
{
|
||||
if (!$key instanceof Node\StringNode && !$key instanceof Node\LiteralNode || !\is_scalar($key->value)) {
|
||||
$this->tokens->error('Unacceptable key', $key->startTokenPos);
|
||||
}
|
||||
$k = (string) $key->value;
|
||||
if (\array_key_exists($k, $arr)) {
|
||||
$this->tokens->error("Duplicated key '{$k}'", $key->startTokenPos);
|
||||
}
|
||||
$arr[$k] = \true;
|
||||
}
|
||||
private function injectPos(Node $node, int $start = null, int $end = null) : Node
|
||||
{
|
||||
$node->startTokenPos = $start ?? $this->tokens->getPos();
|
||||
$node->startLine = $this->posToLine[$node->startTokenPos];
|
||||
$node->endTokenPos = $end ?? $node->startTokenPos;
|
||||
$node->endLine = $this->posToLine[$node->endTokenPos + 1] ?? \end($this->posToLine);
|
||||
return $node;
|
||||
}
|
||||
private function initLines() : void
|
||||
{
|
||||
$this->posToLine = [];
|
||||
$line = 1;
|
||||
foreach ($this->tokens->getTokens() as $token) {
|
||||
$this->posToLine[] = $line;
|
||||
$line += \substr_count($token->value, "\n");
|
||||
}
|
||||
$this->posToLine[] = $line;
|
||||
}
|
||||
}
|
28
vendor/nette/neon/src/Neon/Token.php
vendored
28
vendor/nette/neon/src/Neon/Token.php
vendored
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208\Nette\Neon;
|
||||
|
||||
/** @internal */
|
||||
final class Token
|
||||
{
|
||||
public const String = 1;
|
||||
public const Literal = 2;
|
||||
public const Char = 0;
|
||||
public const Comment = 3;
|
||||
public const Newline = 4;
|
||||
public const Whitespace = 5;
|
||||
/** @var string */
|
||||
public $value;
|
||||
/** @var int|string */
|
||||
public $type;
|
||||
public function __construct(string $value, $type)
|
||||
{
|
||||
$this->value = $value;
|
||||
$this->type = $type;
|
||||
}
|
||||
}
|
62
vendor/nette/neon/src/Neon/TokenStream.php
vendored
62
vendor/nette/neon/src/Neon/TokenStream.php
vendored
|
@ -1,62 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208\Nette\Neon;
|
||||
|
||||
/** @internal */
|
||||
final class TokenStream
|
||||
{
|
||||
/** @var Token[] */
|
||||
private $tokens;
|
||||
/** @var int */
|
||||
private $pos = 0;
|
||||
public function __construct(array $tokens)
|
||||
{
|
||||
$this->tokens = $tokens;
|
||||
}
|
||||
public function getPos() : int
|
||||
{
|
||||
return $this->pos;
|
||||
}
|
||||
/** @return Token[] */
|
||||
public function getTokens() : array
|
||||
{
|
||||
return $this->tokens;
|
||||
}
|
||||
public function isNext(...$types) : bool
|
||||
{
|
||||
while (\in_array($this->tokens[$this->pos]->type ?? null, [Token::Comment, Token::Whitespace], \true)) {
|
||||
$this->pos++;
|
||||
}
|
||||
return $types ? \in_array($this->tokens[$this->pos]->type ?? null, $types, \true) : isset($this->tokens[$this->pos]);
|
||||
}
|
||||
public function consume(...$types) : ?Token
|
||||
{
|
||||
return $this->isNext(...$types) ? $this->tokens[$this->pos++] : null;
|
||||
}
|
||||
public function getIndentation() : string
|
||||
{
|
||||
return \in_array($this->tokens[$this->pos - 2]->type ?? null, [Token::Newline, null], \true) && ($this->tokens[$this->pos - 1]->type ?? null) === Token::Whitespace ? $this->tokens[$this->pos - 1]->value : '';
|
||||
}
|
||||
/** @return never */
|
||||
public function error(?string $message = null, ?int $pos = null) : void
|
||||
{
|
||||
$pos = $pos ?? $this->pos;
|
||||
$input = '';
|
||||
foreach ($this->tokens as $i => $token) {
|
||||
if ($i >= $pos) {
|
||||
break;
|
||||
}
|
||||
$input .= $token->value;
|
||||
}
|
||||
$line = \substr_count($input, "\n") + 1;
|
||||
$col = \strlen($input) - \strrpos("\n" . $input, "\n") + 1;
|
||||
$token = $this->tokens[$pos] ?? null;
|
||||
$message = $message ?? 'Unexpected ' . ($token === null ? 'end' : "'" . \str_replace("\n", '<new line>', \substr($this->tokens[$pos]->value, 0, 40)) . "'");
|
||||
throw new Exception("{$message} on line {$line}, column {$col}.");
|
||||
}
|
||||
}
|
64
vendor/nette/neon/src/Neon/Traverser.php
vendored
64
vendor/nette/neon/src/Neon/Traverser.php
vendored
|
@ -1,64 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208\Nette\Neon;
|
||||
|
||||
/** @internal */
|
||||
final class Traverser
|
||||
{
|
||||
public const DontTraverseChildren = 1;
|
||||
public const StopTraversal = 2;
|
||||
/** @var callable(Node): (Node|int|null)|null */
|
||||
private $enter;
|
||||
/** @var callable(Node): (Node|int|null)|null */
|
||||
private $leave;
|
||||
/** @var bool */
|
||||
private $stop;
|
||||
/**
|
||||
* @param callable(Node): (Node|int|null)|null $enter
|
||||
* @param callable(Node): (Node|int|null)|null $leave
|
||||
*/
|
||||
public function traverse(Node $node, ?callable $enter = null, ?callable $leave = null) : Node
|
||||
{
|
||||
$this->enter = $enter;
|
||||
$this->leave = $leave;
|
||||
$this->stop = \false;
|
||||
return $this->traverseNode($node);
|
||||
}
|
||||
private function traverseNode(Node $node) : Node
|
||||
{
|
||||
$children = \true;
|
||||
if ($this->enter) {
|
||||
$res = ($this->enter)($node);
|
||||
if ($res instanceof Node) {
|
||||
$node = $res;
|
||||
} elseif ($res === self::DontTraverseChildren) {
|
||||
$children = \false;
|
||||
} elseif ($res === self::StopTraversal) {
|
||||
$this->stop = \true;
|
||||
$children = \false;
|
||||
}
|
||||
}
|
||||
if ($children) {
|
||||
foreach ($node as &$subnode) {
|
||||
$subnode = $this->traverseNode($subnode);
|
||||
if ($this->stop) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$this->stop && $this->leave) {
|
||||
$res = ($this->leave)($node);
|
||||
if ($res instanceof Node) {
|
||||
$node = $res;
|
||||
} elseif ($res === self::StopTraversal) {
|
||||
$this->stop = \true;
|
||||
}
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
}
|
|
@ -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 ec96616'), '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 ea5a50c'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 7ee4e58'), '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 0e86e69'), '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 987bdb4'), '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 0509d31'), '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 ad7cfce'), '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 d876ff2'), '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 8e81496'));
|
||||
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 ec96616'), '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 3e935b4'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 7ee4e58'), '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 0e86e69'), '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 987bdb4'), '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 9c8bf10'), '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 ad7cfce'), '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 d876ff2'), '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 8e81496'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
|
11
vendor/rector/rector-doctrine/config/sets/doctrine-gedmo-annotations-to-attributes.php
vendored
Normal file
11
vendor/rector/rector-doctrine/config/sets/doctrine-gedmo-annotations-to-attributes.php
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
|
||||
use Rector\Php80\ValueObject\AnnotationToAttribute;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\Blameable'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\IpTraceable'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\Language'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\Locale'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\Loggable'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\Reference'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\ReferenceIntegrity'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\ReferenceMany'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\ReferenceManyEmbed'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\ReferenceOne'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\Slug'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\SlugHandler'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\SlugHandlerOption'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\SoftDeleteable'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\SortableGroup'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\SortablePosition'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\Timestampable'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\Translatable'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\TranslationEntity'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\Tree'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\TreeClosure'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\TreeLeft'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\TreeLevel'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\TreeLockTime'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\TreeParent'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\TreePath'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\TreePathHash'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\TreePathSource'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\TreeRight'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\TreeRoot'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\Uploadable'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\UploadableFileMimeType'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\UploadableFileName'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\UploadableFilePath'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\UploadableFileSize'), new AnnotationToAttribute('Gedmo\\Mapping\\Annotation\\Versioned')]);
|
||||
};
|
|
@ -53,6 +53,10 @@ final class DoctrineSetList implements SetListInterface
|
|||
* @var string
|
||||
*/
|
||||
public const ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/doctrine-annotations-to-attributes.php';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const GEDMO_ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/doctrine-gedmo-annotations-to-attributes.php';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
12
vendor/rector/rector-nette/composer.json
vendored
12
vendor/rector/rector-nette/composer.json
vendored
|
@ -5,10 +5,7 @@
|
|||
"description": "Rector upgrades rules for Nette Framework",
|
||||
"require": {
|
||||
"php": ">=8.1",
|
||||
"ext-xml": "*",
|
||||
"nette\/neon": "^3.3.3",
|
||||
"rector\/rector-phpunit": "^0.11",
|
||||
"symfony\/string": "^6.1"
|
||||
"rector\/rector-phpunit": "^0.11"
|
||||
},
|
||||
"require-dev": {
|
||||
"rector\/rector-src": "dev-main",
|
||||
|
@ -32,10 +29,7 @@
|
|||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Rector\\Nette\\": [
|
||||
"src",
|
||||
"packages"
|
||||
]
|
||||
"Rector\\Nette\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
|
@ -68,7 +62,7 @@
|
|||
}
|
||||
},
|
||||
"conflict": {
|
||||
"rector\/rector": "<0.11"
|
||||
"rector\/rector": "<0.12"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
|
|
3
vendor/rector/rector-nette/config/config.php
vendored
3
vendor/rector/rector-nette/config/config.php
vendored
|
@ -6,13 +6,10 @@ namespace RectorPrefix202208;
|
|||
use Rector\Config\RectorConfig;
|
||||
use Rector\Core\NonPhpFile\Rector\RenameClassNonPhpRector;
|
||||
use Rector\Nette\Rector\Latte\RenameMethodLatteRector;
|
||||
use Rector\Nette\Rector\Neon\RenameMethodNeonRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->import(__DIR__ . '/packages.php');
|
||||
$services = $rectorConfig->services();
|
||||
$services->defaults()->public()->autowire()->autoconfigure();
|
||||
$services->load('Rector\\Nette\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/Contract', __DIR__ . '/../src/Rector', __DIR__ . '/../src/ValueObject', __DIR__ . '/../src/Kdyby/Rector', __DIR__ . '/../src/Kdyby/ValueObject']);
|
||||
$rectorConfig->rule(RenameClassNonPhpRector::class);
|
||||
$rectorConfig->rule(RenameMethodNeonRector::class);
|
||||
$rectorConfig->rule(RenameMethodLatteRector::class);
|
||||
};
|
||||
|
|
12
vendor/rector/rector-nette/config/packages.php
vendored
12
vendor/rector/rector-nette/config/packages.php
vendored
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208;
|
||||
|
||||
use RectorPrefix202208\Nette\Neon\Decoder;
|
||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
||||
$services = $rectorConfig->services();
|
||||
$services->defaults()->public()->autowire()->autoconfigure();
|
||||
$services->load('Rector\\Nette\\NeonParser\\', __DIR__ . '/../packages/NeonParser')->exclude([__DIR__ . '/../packages/NeonParser/NeonNodeTraverser.php', __DIR__ . '/../packages/NeonParser/Node']);
|
||||
$services->set(Decoder::class);
|
||||
};
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208;
|
||||
|
||||
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
|
||||
use Rector\Php80\ValueObject\AnnotationToAttribute;
|
||||
// @see https://github.com/apitte/core/pull/161
|
||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [new AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\Id'), new AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\Method'), new AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\Negotiation'), new AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\OpenApi'), new AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\Path'), new AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\RequestBody'), new AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\RequestParameter'), new AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\Response'), new AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\Tag')]);
|
||||
};
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Core\ValueObject\Visibility;
|
||||
use Rector\Nette\Kdyby\Rector\ClassMethod\ChangeNetteEventNamesInGetSubscribedEventsRector;
|
||||
use Rector\Nette\Kdyby\Rector\MethodCall\ReplaceEventManagerWithEventSubscriberRector;
|
||||
use Rector\Renaming\Rector\Name\RenameClassRector;
|
||||
use Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector;
|
||||
use Rector\Visibility\ValueObject\ChangeMethodVisibility;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rule(ChangeNetteEventNamesInGetSubscribedEventsRector::class);
|
||||
$rectorConfig->rule(ReplaceEventManagerWithEventSubscriberRector::class);
|
||||
$rectorConfig->ruleWithConfiguration(ChangeMethodVisibilityRector::class, [new ChangeMethodVisibility('Kdyby\\Events\\Subscriber', 'getSubscribedEvents', Visibility::STATIC)]);
|
||||
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Kdyby\\Events\\Subscriber' => 'Symfony\\Component\\EventDispatcher\\EventSubscriberInterface', 'Kdyby\\Events\\EventManager' => 'Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface']);
|
||||
};
|
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
||||
use Rector\Renaming\Rector\Name\RenameClassRector;
|
||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Kdyby\\RabbitMq\\IConsumer', 'process', 'execute')]);
|
||||
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Kdyby\\RabbitMq\\IConsumer' => 'OldSound\\RabbitMqBundle\\RabbitMq\\ConsumerInterface', 'Kdyby\\RabbitMq\\IProducer' => 'OldSound\\RabbitMqBundle\\RabbitMq\\ProducerInterface']);
|
||||
};
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Nette\Kdyby\Rector\MethodCall\WrapTransParameterNameRector;
|
||||
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
||||
use Rector\Renaming\Rector\Name\RenameClassRector;
|
||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Kdyby\\Translation\\Translator', 'translate', 'trans')]);
|
||||
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Kdyby\\Translation\\Translator' => 'Nette\\Localization\\ITranslator', 'Kdyby\\Translation\\DI\\ITranslationProvider' => 'Contributte\\Translation\\DI\\TranslationProviderInterface', 'Kdyby\\Translation\\Phrase' => 'Contributte\\Translation\\Wrappers\\Message']);
|
||||
$rectorConfig->rule(WrapTransParameterNameRector::class);
|
||||
};
|
|
@ -7,9 +7,7 @@ use Rector\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector;
|
|||
use Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue;
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector;
|
||||
use Rector\Nette\Rector\Class_\MoveFinalGetUserToCheckRequirementsClassMethodRector;
|
||||
use Rector\Nette\Rector\ClassMethod\RemoveParentAndNameFromComponentConstructorRector;
|
||||
use Rector\Nette\Rector\MethodCall\AddNextrasDatePickerToDateControlRector;
|
||||
use Rector\Nette\Rector\MethodCall\ConvertAddUploadWithThirdArgumentTrueToAddMultiUploadRector;
|
||||
use Rector\Nette\Rector\MethodCall\MagicHtmlCallToAppendAttributeRector;
|
||||
use Rector\Nette\Rector\MethodCall\MergeDefaultsInGetConfigCompilerExtensionRector;
|
||||
|
@ -23,7 +21,6 @@ use Rector\Transform\Rector\StaticCall\StaticCallToMethodCallRector;
|
|||
use Rector\Transform\ValueObject\StaticCallToMethodCall;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->sets([__DIR__ . '/nette-30/nette-30-composer.php', __DIR__ . '/nette-30/nette-30-dependency-injection.php', __DIR__ . '/nette-30/nette-30-return-types.php', __DIR__ . '/nette-30/nette-30-param-types.php']);
|
||||
$rectorConfig->rule(AddNextrasDatePickerToDateControlRector::class);
|
||||
$rectorConfig->rule(MergeDefaultsInGetConfigCompilerExtensionRector::class);
|
||||
// Control class has remove __construct(), e.g. https://github.com/Pixidos/GPWebPay/pull/16/files#diff-fdc8251950f85c5467c63c249df05786
|
||||
$rectorConfig->rule(RemoveParentCallWithoutParentRector::class);
|
||||
|
@ -60,6 +57,5 @@ return static function (RectorConfig $rectorConfig) : void {
|
|||
$rectorConfig->rule(MagicHtmlCallToAppendAttributeRector::class);
|
||||
$rectorConfig->rule(RequestGetCookieDefaultArgumentToCoalesceRector::class);
|
||||
$rectorConfig->rule(RemoveParentAndNameFromComponentConstructorRector::class);
|
||||
$rectorConfig->rule(MoveFinalGetUserToCheckRequirementsClassMethodRector::class);
|
||||
$rectorConfig->rule(ConvertAddUploadWithThirdArgumentTrueToAddMultiUploadRector::class);
|
||||
};
|
||||
|
|
|
@ -5,8 +5,19 @@ namespace RectorPrefix202208;
|
|||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Nette\Rector\ClassMethod\TemplateMagicAssignToExplicitVariableArrayRector;
|
||||
use Rector\Nette\Rector\Identical\SubstrMinusToStringEndsWithRector;
|
||||
use Rector\Nette\Rector\FuncCall\JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector;
|
||||
use Rector\Nette\Rector\FuncCall\PregFunctionToNetteUtilsStringsRector;
|
||||
use Rector\Nette\Rector\FuncCall\PregMatchFunctionToNetteUtilsStringsRector;
|
||||
use Rector\Nette\Rector\FuncCall\SubstrStrlenFunctionToNetteUtilsStringsRector;
|
||||
use Rector\Nette\Rector\LNumber\ReplaceTimeNumberWithDateTimeConstantRector;
|
||||
use Rector\Transform\Rector\FuncCall\FuncCallToStaticCallRector;
|
||||
use Rector\Transform\ValueObject\FuncCallToStaticCall;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rule(TemplateMagicAssignToExplicitVariableArrayRector::class);
|
||||
$rectorConfig->rule(SubstrMinusToStringEndsWithRector::class);
|
||||
$rectorConfig->ruleWithConfiguration(FuncCallToStaticCallRector::class, [new FuncCallToStaticCall('file_get_contents', 'Nette\\Utils\\FileSystem', 'read'), new FuncCallToStaticCall('unlink', 'Nette\\Utils\\FileSystem', 'delete'), new FuncCallToStaticCall('rmdir', 'Nette\\Utils\\FileSystem', 'delete')]);
|
||||
$rectorConfig->rule(SubstrStrlenFunctionToNetteUtilsStringsRector::class);
|
||||
$rectorConfig->rule(PregMatchFunctionToNetteUtilsStringsRector::class);
|
||||
$rectorConfig->rule(PregFunctionToNetteUtilsStringsRector::class);
|
||||
$rectorConfig->rule(JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector::class);
|
||||
$rectorConfig->rule(ReplaceTimeNumberWithDateTimeConstantRector::class);
|
||||
};
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Nette\Rector\ClassMethod\RenderMethodParamToTypeDeclarationRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rule(RenderMethodParamToTypeDeclarationRector::class);
|
||||
};
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202208;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Nette\Rector\FuncCall\FilePutContentsToFileSystemWriteRector;
|
||||
use Rector\Nette\Rector\FuncCall\JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector;
|
||||
use Rector\Nette\Rector\FuncCall\PregFunctionToNetteUtilsStringsRector;
|
||||
use Rector\Nette\Rector\FuncCall\PregMatchFunctionToNetteUtilsStringsRector;
|
||||
use Rector\Nette\Rector\FuncCall\SubstrStrlenFunctionToNetteUtilsStringsRector;
|
||||
use Rector\Nette\Rector\Identical\EndsWithFunctionToNetteUtilsStringsRector;
|
||||
use Rector\Nette\Rector\LNumber\ReplaceTimeNumberWithDateTimeConstantRector;
|
||||
use Rector\Nette\Rector\NotIdentical\StrposToStringsContainsRector;
|
||||
use Rector\Transform\Rector\FuncCall\FuncCallToStaticCallRector;
|
||||
use Rector\Transform\ValueObject\FuncCallToStaticCall;
|
||||
# @see https://tomasvotruba.com/blog/2018/07/30/hidden-gems-of-php-packages-nette-utils
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->ruleWithConfiguration(FuncCallToStaticCallRector::class, [new FuncCallToStaticCall('file_get_contents', 'Nette\\Utils\\FileSystem', 'read'), new FuncCallToStaticCall('unlink', 'Nette\\Utils\\FileSystem', 'delete'), new FuncCallToStaticCall('rmdir', 'Nette\\Utils\\FileSystem', 'delete')]);
|
||||
$rectorConfig->rule(StrposToStringsContainsRector::class);
|
||||
$rectorConfig->rule(SubstrStrlenFunctionToNetteUtilsStringsRector::class);
|
||||
$rectorConfig->rule(PregMatchFunctionToNetteUtilsStringsRector::class);
|
||||
$rectorConfig->rule(PregFunctionToNetteUtilsStringsRector::class);
|
||||
$rectorConfig->rule(EndsWithFunctionToNetteUtilsStringsRector::class);
|
||||
$rectorConfig->rule(JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector::class);
|
||||
$rectorConfig->rule(FilePutContentsToFileSystemWriteRector::class);
|
||||
$rectorConfig->rule(ReplaceTimeNumberWithDateTimeConstantRector::class);
|
||||
};
|
|
@ -1,26 +1,4 @@
|
|||
# 33 Rules Overview
|
||||
|
||||
## AddNextrasDatePickerToDateControlRector
|
||||
|
||||
Nextras/Form upgrade of addDatePicker method call to DateControl assign
|
||||
|
||||
- class: [`Rector\Nette\Rector\MethodCall\AddNextrasDatePickerToDateControlRector`](../src/Rector/MethodCall/AddNextrasDatePickerToDateControlRector.php)
|
||||
|
||||
```diff
|
||||
use Nette\Application\UI\Form;
|
||||
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$form = new Form();
|
||||
- $form->addDatePicker('key', 'Label');
|
||||
+ $form['key'] = new \Nextras\FormComponents\Controls\DateControl('Label');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
# 22 Rules Overview
|
||||
|
||||
## BuilderExpandToHelperExpandRector
|
||||
|
||||
|
@ -43,41 +21,6 @@ Change `containerBuilder->expand()` to static call with parameters
|
|||
|
||||
<br>
|
||||
|
||||
## ChangeNetteEventNamesInGetSubscribedEventsRector
|
||||
|
||||
Change EventSubscriber from Kdyby to Contributte
|
||||
|
||||
- class: [`Rector\Nette\Kdyby\Rector\ClassMethod\ChangeNetteEventNamesInGetSubscribedEventsRector`](../src/Kdyby/Rector/ClassMethod/ChangeNetteEventNamesInGetSubscribedEventsRector.php)
|
||||
|
||||
```diff
|
||||
+use Contributte\Events\Extra\Event\Application\ShutdownEvent;
|
||||
use Kdyby\Events\Subscriber;
|
||||
use Nette\Application\Application;
|
||||
-use Nette\Application\UI\Presenter;
|
||||
|
||||
class GetApplesSubscriber implements Subscriber
|
||||
{
|
||||
- public function getSubscribedEvents()
|
||||
+ public static function getSubscribedEvents()
|
||||
{
|
||||
return [
|
||||
- Application::class . '::onShutdown',
|
||||
+ ShutdownEvent::class => 'onShutdown',
|
||||
];
|
||||
}
|
||||
|
||||
- public function onShutdown(Presenter $presenter)
|
||||
+ public function onShutdown(ShutdownEvent $shutdownEvent)
|
||||
{
|
||||
+ $presenter = $shutdownEvent->getPresenter();
|
||||
$presenterName = $presenter->getName();
|
||||
// ...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## ContextGetByTypeToConstructorInjectionRector
|
||||
|
||||
Move dependency get via `$context->getByType()` to constructor injection
|
||||
|
@ -120,50 +63,6 @@ convert `addUpload()` with 3rd argument true to `addMultiUpload()`
|
|||
|
||||
<br>
|
||||
|
||||
## EndsWithFunctionToNetteUtilsStringsRector
|
||||
|
||||
Use `Nette\Utils\Strings::endsWith()` over bare string-functions
|
||||
|
||||
- class: [`Rector\Nette\Rector\Identical\EndsWithFunctionToNetteUtilsStringsRector`](../src/Rector/Identical/EndsWithFunctionToNetteUtilsStringsRector.php)
|
||||
|
||||
```diff
|
||||
+use Nette\Utils\Strings;
|
||||
+
|
||||
class SomeClass
|
||||
{
|
||||
public function end($needle)
|
||||
{
|
||||
$content = 'Hi, my name is Tom';
|
||||
-
|
||||
- $yes = substr($content, -strlen($needle)) === $needle;
|
||||
+ $yes = Strings::endsWith($content, $needle);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## FilePutContentsToFileSystemWriteRector
|
||||
|
||||
Change `file_put_contents()` to `FileSystem::write()`
|
||||
|
||||
- class: [`Rector\Nette\Rector\FuncCall\FilePutContentsToFileSystemWriteRector`](../src/Rector/FuncCall/FilePutContentsToFileSystemWriteRector.php)
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
- file_put_contents('file.txt', 'content');
|
||||
+ \Nette\Utils\FileSystem::write('file.txt', 'content');
|
||||
|
||||
file_put_contents('file.txt', 'content_to_append', FILE_APPEND);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## FormDataRector
|
||||
|
||||
Create form data class with all fields of Form
|
||||
|
@ -344,32 +243,6 @@ Change `$this->template->setFile()` `$this->template->render()`
|
|||
|
||||
<br>
|
||||
|
||||
## MoveFinalGetUserToCheckRequirementsClassMethodRector
|
||||
|
||||
Presenter method `getUser()` is now final, move logic to `checkRequirements()`
|
||||
|
||||
- class: [`Rector\Nette\Rector\Class_\MoveFinalGetUserToCheckRequirementsClassMethodRector`](../src/Rector/Class_/MoveFinalGetUserToCheckRequirementsClassMethodRector.php)
|
||||
|
||||
```diff
|
||||
use Nette\Application\UI\Presenter;
|
||||
|
||||
class SomeControl extends Presenter
|
||||
{
|
||||
- public function getUser()
|
||||
+ public function checkRequirements()
|
||||
{
|
||||
- $user = parent::getUser();
|
||||
+ $user = $this->getUser();
|
||||
$user->getStorage()->setNamespace('admin_session');
|
||||
- return $user;
|
||||
+
|
||||
+ parent::checkRequirements();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## MoveInjectToExistingConstructorRector
|
||||
|
||||
Move `@inject` properties to constructor, if there already is one
|
||||
|
@ -505,78 +378,6 @@ Renames method calls in LATTE templates
|
|||
|
||||
<br>
|
||||
|
||||
## RenameMethodNeonRector
|
||||
|
||||
Renames method calls in NEON configs
|
||||
|
||||
- class: [`Rector\Nette\Rector\Neon\RenameMethodNeonRector`](../src/Rector/Neon/RenameMethodNeonRector.php)
|
||||
|
||||
```diff
|
||||
services:
|
||||
-
|
||||
class: SomeClass
|
||||
setup:
|
||||
- - oldCall
|
||||
+ - newCall
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## RenderMethodParamToTypeDeclarationRector
|
||||
|
||||
Move `@param` declarations on `render()` method in Nette components and presenter to strict type declarations
|
||||
|
||||
- class: [`Rector\Nette\Rector\ClassMethod\RenderMethodParamToTypeDeclarationRector`](../src/Rector/ClassMethod/RenderMethodParamToTypeDeclarationRector.php)
|
||||
|
||||
```diff
|
||||
use Nette\Application\UI\Control;
|
||||
|
||||
final class SomeControl extends Control
|
||||
{
|
||||
- /**
|
||||
- * @param string $name
|
||||
- */
|
||||
- public function render($name)
|
||||
+ public function render(string $name)
|
||||
{
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## ReplaceEventManagerWithEventSubscriberRector
|
||||
|
||||
Change Kdyby EventManager to EventDispatcher
|
||||
|
||||
- class: [`Rector\Nette\Kdyby\Rector\MethodCall\ReplaceEventManagerWithEventSubscriberRector`](../src/Kdyby/Rector/MethodCall/ReplaceEventManagerWithEventSubscriberRector.php)
|
||||
|
||||
```diff
|
||||
use Kdyby\Events\EventManager;
|
||||
|
||||
final class SomeClass
|
||||
{
|
||||
/**
|
||||
* @var EventManager
|
||||
*/
|
||||
private $eventManager;
|
||||
|
||||
public function __construct(EventManager $eventManager)
|
||||
{
|
||||
$this->eventManager = eventManager;
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
$key = '2000';
|
||||
- $this->eventManager->dispatchEvent(static::class . '::onCopy', new EventArgsList([$this, $key]));
|
||||
+ $this->eventManager->dispatch(new SomeClassCopyEvent($this, $key));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## ReplaceTimeNumberWithDateTimeConstantRector
|
||||
|
||||
Replace time numbers with `Nette\Utils\DateTime` constants
|
||||
|
@ -639,41 +440,6 @@ Change setClass with class and arguments to separated methods
|
|||
|
||||
<br>
|
||||
|
||||
## StrposToStringsContainsRector
|
||||
|
||||
Use `Nette\Utils\Strings` over bare string-functions
|
||||
|
||||
- class: [`Rector\Nette\Rector\NotIdentical\StrposToStringsContainsRector`](../src/Rector/NotIdentical/StrposToStringsContainsRector.php)
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$name = 'Hi, my name is Tom';
|
||||
- return strpos($name, 'Hi') !== false;
|
||||
+ return \Nette\Utils\Strings::contains($name, 'Hi');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## SubstrMinusToStringEndsWithRector
|
||||
|
||||
Change substr function with minus to `Strings::endsWith()`
|
||||
|
||||
- class: [`Rector\Nette\Rector\Identical\SubstrMinusToStringEndsWithRector`](../src/Rector/Identical/SubstrMinusToStringEndsWithRector.php)
|
||||
|
||||
```diff
|
||||
-substr($var, -4) !== 'Test';
|
||||
-substr($var, -4) === 'Test';
|
||||
+! \Nette\Utils\Strings::endsWith($var, 'Test');
|
||||
+\Nette\Utils\Strings::endsWith($var, 'Test');
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## SubstrStrlenFunctionToNetteUtilsStringsRector
|
||||
|
||||
Use `Nette\Utils\Strings` over bare string-functions
|
||||
|
@ -793,28 +559,3 @@ Change `translate()` method call 2nd arg to variadic
|
|||
```
|
||||
|
||||
<br>
|
||||
|
||||
## WrapTransParameterNameRector
|
||||
|
||||
Adds %% to placeholder name of `trans()` method if missing
|
||||
|
||||
- class: [`Rector\Nette\Kdyby\Rector\MethodCall\WrapTransParameterNameRector`](../src/Kdyby/Rector/MethodCall/WrapTransParameterNameRector.php)
|
||||
|
||||
```diff
|
||||
use Symfony\Component\Translation\Translator;
|
||||
|
||||
final class SomeController
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$translator = new Translator('');
|
||||
$translated = $translator->trans(
|
||||
'Hello %name%',
|
||||
- ['name' => $name]
|
||||
+ ['%name%' => $name]
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\Nette\NeonParser\Contract;
|
||||
|
||||
use RectorPrefix202208\Nette\Neon\Node;
|
||||
interface NeonNodeVisitorInterface
|
||||
{
|
||||
/**
|
||||
* @return class-string<\PhpParser\Node>
|
||||
*/
|
||||
public function getNodeType() : string;
|
||||
public function enterNode(Node $node) : Node;
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\NeonParser\Exception;
|
||||
|
||||
use Exception;
|
||||
final class NotImplementedYetException extends Exception
|
||||
{
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\NeonParser\Exception;
|
||||
|
||||
use Exception;
|
||||
final class UnusedVirtualMethodException extends Exception
|
||||
{
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\NeonParser;
|
||||
|
||||
use RectorPrefix202208\Nette\Neon\Node;
|
||||
use Rector\Nette\Contract\Rector\NeonRectorInterface;
|
||||
use Rector\Nette\NeonParser\Contract\NeonNodeVisitorInterface;
|
||||
use Rector\Nette\NeonParser\Node\Service_;
|
||||
use Rector\Nette\NeonParser\NodeFactory\ServiceFactory;
|
||||
use Rector\Nette\NeonParser\Services\ServiceTypeResolver;
|
||||
/**
|
||||
* @see https://forum.nette.org/en/34804-neon-with-ast-parser-and-format-preserving-printing
|
||||
*/
|
||||
final class NeonNodeTraverser
|
||||
{
|
||||
/**
|
||||
* @var NeonNodeVisitorInterface[]
|
||||
*/
|
||||
private $neonRectors = [];
|
||||
/**
|
||||
* @var \Rector\Nette\NeonParser\Services\ServiceTypeResolver
|
||||
*/
|
||||
private $serviceTypeResolver;
|
||||
/**
|
||||
* @var \Rector\Nette\NeonParser\NodeFactory\ServiceFactory
|
||||
*/
|
||||
private $serviceFactory;
|
||||
public function __construct(ServiceTypeResolver $serviceTypeResolver, ServiceFactory $serviceFactory)
|
||||
{
|
||||
$this->serviceTypeResolver = $serviceTypeResolver;
|
||||
$this->serviceFactory = $serviceFactory;
|
||||
}
|
||||
public function addNeonNodeVisitor(NeonRectorInterface $neonRector) : void
|
||||
{
|
||||
$this->neonRectors[] = $neonRector;
|
||||
}
|
||||
public function traverse(Node $node) : Node
|
||||
{
|
||||
foreach ($this->neonRectors as $neonRector) {
|
||||
// is service node?
|
||||
// iterate single service
|
||||
$serviceType = $this->serviceTypeResolver->resolve($node);
|
||||
// create virtual node
|
||||
if (\is_string($serviceType)) {
|
||||
$service = $this->serviceFactory->create($node);
|
||||
if ($service instanceof Service_) {
|
||||
// enter meta node
|
||||
$node = $service;
|
||||
}
|
||||
}
|
||||
// enter node only in case of matching type
|
||||
if (\is_a($node, $neonRector->getNodeType(), \true)) {
|
||||
$neonRector->enterNode($node);
|
||||
}
|
||||
// traverse all children
|
||||
foreach ($node->getIterator() as $subnode) {
|
||||
$this->traverse($subnode);
|
||||
}
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\NeonParser;
|
||||
|
||||
use Rector\Nette\NeonParser\NodeFactory\ServiceFactory;
|
||||
use Rector\Nette\NeonParser\Services\ServiceTypeResolver;
|
||||
final class NeonNodeTraverserFactory
|
||||
{
|
||||
/**
|
||||
* @var \Rector\Nette\NeonParser\Services\ServiceTypeResolver
|
||||
*/
|
||||
private $serviceTypeResolver;
|
||||
/**
|
||||
* @var \Rector\Nette\NeonParser\NodeFactory\ServiceFactory
|
||||
*/
|
||||
private $serviceFactory;
|
||||
public function __construct(ServiceTypeResolver $serviceTypeResolver, ServiceFactory $serviceFactory)
|
||||
{
|
||||
$this->serviceTypeResolver = $serviceTypeResolver;
|
||||
$this->serviceFactory = $serviceFactory;
|
||||
}
|
||||
public function create() : \Rector\Nette\NeonParser\NeonNodeTraverser
|
||||
{
|
||||
return new \Rector\Nette\NeonParser\NeonNodeTraverser($this->serviceTypeResolver, $this->serviceFactory);
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\NeonParser\NeonNodeVisitor;
|
||||
|
||||
use Rector\Nette\NeonParser\Contract\NeonNodeVisitorInterface;
|
||||
abstract class AbstractServiceNeonNodeVisitor implements NeonNodeVisitorInterface
|
||||
{
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\NeonParser;
|
||||
|
||||
use RectorPrefix202208\Nette\Neon\Decoder;
|
||||
use RectorPrefix202208\Nette\Neon\Node;
|
||||
final class NeonParser
|
||||
{
|
||||
/**
|
||||
* @var \Nette\Neon\Decoder
|
||||
*/
|
||||
private $decoder;
|
||||
public function __construct(Decoder $decoder)
|
||||
{
|
||||
$this->decoder = $decoder;
|
||||
}
|
||||
public function parseString(string $neonContent) : Node
|
||||
{
|
||||
return $this->decoder->parseToNode($neonContent);
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\NeonParser\Node;
|
||||
|
||||
use RectorPrefix202208\Nette\Neon\Node;
|
||||
use Rector\Nette\NeonParser\Exception\UnusedVirtualMethodException;
|
||||
abstract class AbstractVirtualNode extends Node
|
||||
{
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function toValue()
|
||||
{
|
||||
// never used, just to make parent contract happy
|
||||
throw new UnusedVirtualMethodException();
|
||||
}
|
||||
public function toString() : string
|
||||
{
|
||||
// never used, just to make parent contract happy
|
||||
throw new UnusedVirtualMethodException();
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\NeonParser\Node;
|
||||
|
||||
use RectorPrefix202208\Nette\Neon\Node;
|
||||
use RectorPrefix202208\Nette\Neon\Node\LiteralNode;
|
||||
use Rector\Nette\NeonParser\Node\Service_\SetupMethodCall;
|
||||
/**
|
||||
* Metanode for easier subscribing
|
||||
*/
|
||||
final class Service_ extends \Rector\Nette\NeonParser\Node\AbstractVirtualNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const UNKNOWN_TYPE = '__UNKNOWN_TYPE__';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $className;
|
||||
/**
|
||||
* @var \Nette\Neon\Node\LiteralNode|null
|
||||
*/
|
||||
private $classLiteralNode;
|
||||
/**
|
||||
* @var \Nette\Neon\Node\LiteralNode|null
|
||||
*/
|
||||
private $factoryLiteralNode;
|
||||
/**
|
||||
* @var SetupMethodCall[]
|
||||
*/
|
||||
private $setupMethodCalls;
|
||||
/**
|
||||
* @param SetupMethodCall[] $setupMethodCalls
|
||||
* @param \Nette\Neon\Node\LiteralNode|null $classLiteralNode
|
||||
* @param \Nette\Neon\Node\LiteralNode|null $factoryLiteralNode
|
||||
*/
|
||||
public function __construct(string $className, $classLiteralNode, $factoryLiteralNode, array $setupMethodCalls)
|
||||
{
|
||||
$this->className = $className;
|
||||
$this->classLiteralNode = $classLiteralNode;
|
||||
$this->factoryLiteralNode = $factoryLiteralNode;
|
||||
$this->setupMethodCalls = $setupMethodCalls;
|
||||
}
|
||||
public function getClassName() : string
|
||||
{
|
||||
return $this->className;
|
||||
}
|
||||
public function getServiceType() : string
|
||||
{
|
||||
if ($this->classLiteralNode) {
|
||||
return $this->classLiteralNode->toString();
|
||||
}
|
||||
if ($this->factoryLiteralNode) {
|
||||
return $this->factoryLiteralNode->toString();
|
||||
}
|
||||
return self::UNKNOWN_TYPE;
|
||||
}
|
||||
/**
|
||||
* @return Node[]
|
||||
*/
|
||||
public function &getIterator() : \Generator
|
||||
{
|
||||
if ($this->classLiteralNode instanceof LiteralNode) {
|
||||
(yield $this->classLiteralNode);
|
||||
}
|
||||
if ($this->factoryLiteralNode instanceof LiteralNode) {
|
||||
(yield $this->factoryLiteralNode);
|
||||
}
|
||||
foreach ($this->setupMethodCalls as $setupMethodCall) {
|
||||
(yield $setupMethodCall);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\NeonParser\Node\Service_;
|
||||
|
||||
use RectorPrefix202208\Nette\Neon\Node\EntityNode;
|
||||
use RectorPrefix202208\Nette\Neon\Node\LiteralNode;
|
||||
use Rector\Nette\NeonParser\Node\AbstractVirtualNode;
|
||||
final class SetupMethodCall extends AbstractVirtualNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $className;
|
||||
/**
|
||||
* @var \Nette\Neon\Node\LiteralNode
|
||||
*/
|
||||
public $methodNameLiteralNode;
|
||||
/**
|
||||
* @var \Nette\Neon\Node\EntityNode
|
||||
*/
|
||||
public $entityNode;
|
||||
public function __construct(string $className, LiteralNode $methodNameLiteralNode, EntityNode $entityNode)
|
||||
{
|
||||
$this->className = $className;
|
||||
$this->methodNameLiteralNode = $methodNameLiteralNode;
|
||||
$this->entityNode = $entityNode;
|
||||
}
|
||||
public function getMethodName() : string
|
||||
{
|
||||
return $this->methodNameLiteralNode->toValue();
|
||||
}
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\NeonParser\NodeFactory;
|
||||
|
||||
use RectorPrefix202208\Nette\Neon\Node\ArrayItemNode;
|
||||
use RectorPrefix202208\Nette\Neon\Node\ArrayNode;
|
||||
use RectorPrefix202208\Nette\Neon\Node\EntityNode;
|
||||
use RectorPrefix202208\Nette\Neon\Node\LiteralNode;
|
||||
use Rector\Nette\NeonParser\Node\Service_;
|
||||
use RectorPrefix202208\Nette\Neon\Node;
|
||||
use Rector\Nette\NeonParser\Node\Service_\SetupMethodCall;
|
||||
final class ServiceFactory
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const CLASS_KEYWORD = 'class';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const SETUP_KEYWORD = 'setup';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const FACTORY_KEYWORD = 'factory';
|
||||
/**
|
||||
* @return \Rector\Nette\NeonParser\Node\Service_|null
|
||||
*/
|
||||
public function create(Node $node)
|
||||
{
|
||||
if (!$node instanceof ArrayItemNode) {
|
||||
return null;
|
||||
}
|
||||
$class = $this->resolveArrayItemByKeyword($node, self::CLASS_KEYWORD);
|
||||
$factory = $this->resolveArrayItemByKeyword($node, self::FACTORY_KEYWORD);
|
||||
$className = $this->resolveServiceName($class, $factory);
|
||||
// resolve later
|
||||
if (!\is_string($className)) {
|
||||
return null;
|
||||
}
|
||||
$setupMethodCalls = $this->resolveSetupMethodCalls($className, $node);
|
||||
return new Service_($className, $class, $factory, $setupMethodCalls);
|
||||
}
|
||||
/**
|
||||
* @return \Nette\Neon\Node\LiteralNode|null
|
||||
*/
|
||||
private function resolveArrayItemByKeyword(ArrayItemNode $arrayItemNode, string $keyword)
|
||||
{
|
||||
if (!$arrayItemNode->value instanceof ArrayNode) {
|
||||
return null;
|
||||
}
|
||||
$arrayNode = $arrayItemNode->value;
|
||||
foreach ($arrayNode->items as $arrayItemNode) {
|
||||
if (!$arrayItemNode->key instanceof LiteralNode) {
|
||||
continue;
|
||||
}
|
||||
if ($arrayItemNode->key->toString() !== $keyword) {
|
||||
continue;
|
||||
}
|
||||
if ($arrayItemNode->value instanceof EntityNode) {
|
||||
return $arrayItemNode->value->value;
|
||||
}
|
||||
if ($arrayItemNode->value instanceof LiteralNode) {
|
||||
return $arrayItemNode->value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @return SetupMethodCall[]
|
||||
*/
|
||||
private function resolveSetupMethodCalls(string $className, ArrayItemNode $arrayItemNode) : array
|
||||
{
|
||||
if (!$arrayItemNode->value instanceof ArrayNode) {
|
||||
return [];
|
||||
}
|
||||
$setupMethodCalls = [];
|
||||
$arrayNode = $arrayItemNode->value;
|
||||
foreach ($arrayNode->items as $arrayItemNode) {
|
||||
if ($arrayItemNode->key instanceof LiteralNode) {
|
||||
if ($arrayItemNode->key->toString() !== self::SETUP_KEYWORD) {
|
||||
continue;
|
||||
}
|
||||
if (!$arrayItemNode->value instanceof ArrayNode) {
|
||||
continue;
|
||||
}
|
||||
foreach ($arrayItemNode->value->items as $setupArrayItemNode) {
|
||||
if ($setupArrayItemNode->value instanceof EntityNode) {
|
||||
// probably method call
|
||||
$entityNode = $setupArrayItemNode->value;
|
||||
if ($entityNode->value instanceof LiteralNode) {
|
||||
// not a method call - probably property assign
|
||||
if (\strncmp($entityNode->value->toString(), '$', \strlen('$')) === 0) {
|
||||
continue;
|
||||
}
|
||||
$setupMethodCalls[] = new SetupMethodCall($className, $entityNode->value, $entityNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $setupMethodCalls;
|
||||
}
|
||||
/**
|
||||
* @param \Nette\Neon\Node\LiteralNode|null $classLiteralNode
|
||||
* @param \Nette\Neon\Node\LiteralNode|null $factoryLiteralNode
|
||||
* @return string|null
|
||||
*/
|
||||
private function resolveServiceName($classLiteralNode, $factoryLiteralNode)
|
||||
{
|
||||
if ($classLiteralNode) {
|
||||
return $classLiteralNode->toString();
|
||||
}
|
||||
if ($factoryLiteralNode) {
|
||||
return $factoryLiteralNode->toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\NeonParser\Printer;
|
||||
|
||||
use RectorPrefix202208\Nette\Neon\Node;
|
||||
use RectorPrefix202208\Nette\Utils\Strings;
|
||||
final class FormatPreservingNeonPrinter
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const INDENT_TABS = 'tabs';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const INDENT_SPACES = 'spaces';
|
||||
public function printNode(Node $node, string $originalContenet) : string
|
||||
{
|
||||
$neonContent = $node->toString();
|
||||
$indentType = $this->resolveIndentType($originalContenet);
|
||||
$neonContent = $this->formatIndent($neonContent, $indentType);
|
||||
// replace quotes - @todo resolve defaults
|
||||
return Strings::replace($neonContent, '#\\"#', '\'');
|
||||
}
|
||||
/**
|
||||
* Some files prefer tabs, some spaces. This will resolve first found space.
|
||||
*/
|
||||
private function resolveIndentType(string $neonContent) : string
|
||||
{
|
||||
$indentMatch = Strings::match($neonContent, '#(\\t| )#ms');
|
||||
if ($indentMatch[0] === "\t") {
|
||||
return self::INDENT_TABS;
|
||||
}
|
||||
return self::INDENT_SPACES;
|
||||
}
|
||||
private function formatIndent(string $neonContent, string $indentType) : string
|
||||
{
|
||||
if ($indentType === self::INDENT_SPACES) {
|
||||
return Strings::replace($neonContent, '#\\t#', ' ');
|
||||
}
|
||||
return $neonContent;
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\NeonParser\Services;
|
||||
|
||||
use RectorPrefix202208\Nette\Neon\Node;
|
||||
use RectorPrefix202208\Nette\Neon\Node\ArrayItemNode;
|
||||
use RectorPrefix202208\Nette\Neon\Node\ArrayNode;
|
||||
use RectorPrefix202208\Nette\Neon\Node\EntityNode;
|
||||
final class ServiceTypeResolver
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const FACTORY_KEYWORD = 'factory';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const CLASS_KEYWORD = 'class';
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function resolve(Node $serviceNode)
|
||||
{
|
||||
if (!$serviceNode instanceof ArrayItemNode) {
|
||||
return null;
|
||||
}
|
||||
if (!$serviceNode->value instanceof ArrayNode) {
|
||||
return null;
|
||||
}
|
||||
foreach ($serviceNode->value->items as $serviceConfigurationItem) {
|
||||
if ($serviceConfigurationItem->key === null) {
|
||||
continue;
|
||||
}
|
||||
if ($serviceConfigurationItem->key->toString() === self::FACTORY_KEYWORD) {
|
||||
if ($serviceConfigurationItem->value instanceof EntityNode) {
|
||||
return $serviceConfigurationItem->value->value->toString();
|
||||
}
|
||||
return $serviceConfigurationItem->value->toString();
|
||||
}
|
||||
if ($serviceConfigurationItem->key->toString() === self::CLASS_KEYWORD) {
|
||||
if ($serviceConfigurationItem->value instanceof EntityNode) {
|
||||
return $serviceConfigurationItem->value->value->toString();
|
||||
}
|
||||
return $serviceConfigurationItem->value->toString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Contract\Rector;
|
||||
|
||||
use RectorPrefix202208\Nette\Neon\Node;
|
||||
use Rector\Core\Contract\Rector\RectorInterface;
|
||||
/**
|
||||
* @template TNode as Node
|
||||
*/
|
||||
interface NeonRectorInterface extends RectorInterface
|
||||
{
|
||||
/**
|
||||
* @return class-string<TNode>
|
||||
*/
|
||||
public function getNodeType() : string;
|
||||
/**
|
||||
* @param TNode $node
|
||||
* @return \Nette\Neon\Node|null
|
||||
*/
|
||||
public function enterNode(Node $node);
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\FileProcessor;
|
||||
|
||||
use Rector\ChangesReporting\ValueObjectFactory\FileDiffFactory;
|
||||
use Rector\Core\Contract\Processor\FileProcessorInterface;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\Core\ValueObject\Configuration;
|
||||
use Rector\Core\ValueObject\Error\SystemError;
|
||||
use Rector\Core\ValueObject\Reporting\FileDiff;
|
||||
use Rector\Nette\Contract\Rector\NeonRectorInterface;
|
||||
use Rector\Nette\NeonParser\NeonNodeTraverserFactory;
|
||||
use Rector\Nette\NeonParser\NeonParser;
|
||||
use Rector\Nette\NeonParser\Printer\FormatPreservingNeonPrinter;
|
||||
use Rector\Parallel\ValueObject\Bridge;
|
||||
final class NeonFileProcessor implements FileProcessorInterface
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Nette\NeonParser\NeonParser
|
||||
*/
|
||||
private $neonParser;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Nette\NeonParser\NeonNodeTraverserFactory
|
||||
*/
|
||||
private $neonNodeTraverserFactory;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Nette\NeonParser\Printer\FormatPreservingNeonPrinter
|
||||
*/
|
||||
private $formatPreservingNeonPrinter;
|
||||
/**
|
||||
* @var NeonRectorInterface[]
|
||||
* @readonly
|
||||
*/
|
||||
private $neonRectors;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\ChangesReporting\ValueObjectFactory\FileDiffFactory
|
||||
*/
|
||||
private $fileDiffFactory;
|
||||
/**
|
||||
* @param NeonRectorInterface[] $neonRectors
|
||||
*/
|
||||
public function __construct(NeonParser $neonParser, NeonNodeTraverserFactory $neonNodeTraverserFactory, FormatPreservingNeonPrinter $formatPreservingNeonPrinter, array $neonRectors, FileDiffFactory $fileDiffFactory)
|
||||
{
|
||||
$this->neonParser = $neonParser;
|
||||
$this->neonNodeTraverserFactory = $neonNodeTraverserFactory;
|
||||
$this->formatPreservingNeonPrinter = $formatPreservingNeonPrinter;
|
||||
$this->neonRectors = $neonRectors;
|
||||
$this->fileDiffFactory = $fileDiffFactory;
|
||||
}
|
||||
/**
|
||||
* @return array{system_errors: SystemError[], file_diffs: FileDiff[]}
|
||||
*/
|
||||
public function process(File $file, Configuration $configuration) : array
|
||||
{
|
||||
$systemErrorsAndFileDiffs = [Bridge::SYSTEM_ERRORS => [], Bridge::FILE_DIFFS => []];
|
||||
if ($this->neonRectors === []) {
|
||||
return $systemErrorsAndFileDiffs;
|
||||
}
|
||||
$fileContent = $file->getFileContent();
|
||||
$neonNode = $this->neonParser->parseString($fileContent);
|
||||
$neonNodeTraverser = $this->neonNodeTraverserFactory->create();
|
||||
foreach ($this->neonRectors as $neonRector) {
|
||||
$neonNodeTraverser->addNeonNodeVisitor($neonRector);
|
||||
}
|
||||
$originalPrintedContent = $this->formatPreservingNeonPrinter->printNode($neonNode, $fileContent);
|
||||
$neonNode = $neonNodeTraverser->traverse($neonNode);
|
||||
$changedFileContent = $this->formatPreservingNeonPrinter->printNode($neonNode, $fileContent);
|
||||
// has node changed?
|
||||
if ($changedFileContent === $originalPrintedContent) {
|
||||
return $systemErrorsAndFileDiffs;
|
||||
}
|
||||
$file->changeFileContent($changedFileContent);
|
||||
$fileDiff = $this->fileDiffFactory->createFileDiff($file, $originalPrintedContent, $changedFileContent);
|
||||
$systemErrorsAndFileDiffs[Bridge::FILE_DIFFS][] = $fileDiff;
|
||||
return $systemErrorsAndFileDiffs;
|
||||
}
|
||||
public function supports(File $file, Configuration $configuration) : bool
|
||||
{
|
||||
$fileInfo = $file->getSmartFileInfo();
|
||||
return $fileInfo->hasSuffixes($this->getSupportedFileExtensions());
|
||||
}
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSupportedFileExtensions() : array
|
||||
{
|
||||
return ['neon'];
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Kdyby\BlueprintFactory;
|
||||
|
||||
use PhpParser\Node\Arg;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\StaticType;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Naming\Naming\VariableNaming;
|
||||
use Rector\Nette\Kdyby\ValueObject\VariableWithType;
|
||||
use Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
final class VariableWithTypesFactory
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeTypeResolver\NodeTypeResolver
|
||||
*/
|
||||
private $nodeTypeResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\StaticTypeMapper\StaticTypeMapper
|
||||
*/
|
||||
private $staticTypeMapper;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Naming\Naming\VariableNaming
|
||||
*/
|
||||
private $variableNaming;
|
||||
public function __construct(NodeTypeResolver $nodeTypeResolver, StaticTypeMapper $staticTypeMapper, VariableNaming $variableNaming)
|
||||
{
|
||||
$this->nodeTypeResolver = $nodeTypeResolver;
|
||||
$this->staticTypeMapper = $staticTypeMapper;
|
||||
$this->variableNaming = $variableNaming;
|
||||
}
|
||||
/**
|
||||
* @param Arg[] $args
|
||||
* @return VariableWithType[]
|
||||
*/
|
||||
public function createVariablesWithTypesFromArgs(array $args) : array
|
||||
{
|
||||
$variablesWithTypes = [];
|
||||
foreach ($args as $arg) {
|
||||
$staticType = $this->nodeTypeResolver->getType($arg->value);
|
||||
$variableName = $this->variableNaming->resolveFromNodeAndType($arg, $staticType);
|
||||
if ($variableName === null) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
// compensate for static
|
||||
if ($staticType instanceof StaticType) {
|
||||
$staticType = new ObjectType($staticType->getClassName());
|
||||
}
|
||||
$phpParserTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($staticType, TypeKind::PROPERTY);
|
||||
$variablesWithTypes[] = new VariableWithType($variableName, $staticType, $phpParserTypeNode);
|
||||
}
|
||||
return $variablesWithTypes;
|
||||
}
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Kdyby;
|
||||
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\NullableType;
|
||||
use PhpParser\Node\Param;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Naming\Naming\VariableNaming;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
final class ContributeEventClassResolver
|
||||
{
|
||||
/**
|
||||
* @var array<string, array<string, string>>
|
||||
*/
|
||||
private const CONTRIBUTTE_EVENT_GETTER_METHODS_WITH_TYPE = [
|
||||
// application
|
||||
'Contributte\\Events\\Extra\\Event\\Application\\ShutdownEvent' => ['Nette\\Application\\Application' => 'getApplication', 'Throwable' => 'getThrowable'],
|
||||
'Contributte\\Events\\Extra\\Event\\Application\\StartupEvent' => ['Nette\\Application\\Application' => 'getApplication'],
|
||||
'Contributte\\Events\\Extra\\Event\\Application\\ErrorEvent' => ['Nette\\Application\\Application' => 'getApplication', 'Throwable' => 'getThrowable'],
|
||||
'Contributte\\Events\\Extra\\Event\\Application\\PresenterEvent' => ['Nette\\Application\\Application' => 'getApplication', 'Nette\\Application\\IPresenter' => 'getPresenter'],
|
||||
'Contributte\\Events\\Extra\\Event\\Application\\RequestEvent' => ['Nette\\Application\\Application' => 'getApplication', 'Nette\\Application\\Request' => 'getRequest'],
|
||||
'Contributte\\Events\\Extra\\Event\\Application\\ResponseEvent' => ['Nette\\Application\\Application' => 'getApplication', 'Nette\\Application\\IResponse' => 'getResponse'],
|
||||
// presenter
|
||||
'Contributte\\Events\\Extra\\Event\\Application\\PresenterShutdownEvent' => ['Nette\\Application\\IPresenter' => 'getPresenter', 'Nette\\Application\\IResponse' => 'getResponse'],
|
||||
'Contributte\\Events\\Extra\\Event\\Application\\PresenterStartupEvent' => ['Nette\\Application\\UI\\Presenter' => 'getPresenter'],
|
||||
// nette/security
|
||||
'Contributte\\Events\\Extra\\Event\\Security\\LoggedInEvent' => ['Nette\\Security\\User' => 'getUser'],
|
||||
'Contributte\\Events\\Extra\\Event\\Security\\LoggedOutEvent' => ['Nette\\Security\\User' => 'getUser'],
|
||||
// latte
|
||||
'Contributte\\Events\\Extra\\Event\\Latte\\LatteCompileEvent' => ['Latte\\Engine' => 'getEngine'],
|
||||
'Contributte\\Events\\Extra\\Event\\Latte\\TemplateCreateEvent' => ['Nette\\Bridges\\ApplicationLatte\\Template' => 'getTemplate'],
|
||||
];
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\StaticTypeMapper\StaticTypeMapper
|
||||
*/
|
||||
private $staticTypeMapper;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Naming\Naming\VariableNaming
|
||||
*/
|
||||
private $variableNaming;
|
||||
public function __construct(NodeNameResolver $nodeNameResolver, StaticTypeMapper $staticTypeMapper, VariableNaming $variableNaming)
|
||||
{
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->staticTypeMapper = $staticTypeMapper;
|
||||
$this->variableNaming = $variableNaming;
|
||||
}
|
||||
public function resolveGetterMethodByEventClassAndParam(string $eventClass, Param $param) : string
|
||||
{
|
||||
$getterMethodsWithType = self::CONTRIBUTTE_EVENT_GETTER_METHODS_WITH_TYPE[$eventClass] ?? null;
|
||||
$paramType = $param->type;
|
||||
// unwrap nullable type
|
||||
if ($paramType instanceof NullableType) {
|
||||
$paramType = $paramType->type;
|
||||
}
|
||||
if ($paramType === null || $paramType instanceof Identifier) {
|
||||
return $this->resolveParamType($paramType, $param);
|
||||
}
|
||||
$type = $this->nodeNameResolver->getName($paramType);
|
||||
if ($type === null) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
// system contribute event
|
||||
if (isset($getterMethodsWithType[$type])) {
|
||||
return $getterMethodsWithType[$type];
|
||||
}
|
||||
$staticType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($paramType);
|
||||
return $this->createGetterFromParamAndStaticType($param, $staticType);
|
||||
}
|
||||
private function createGetterFromParamAndStaticType(Param $param, Type $type) : string
|
||||
{
|
||||
$variableName = $this->variableNaming->resolveFromNodeAndType($param, $type);
|
||||
if ($variableName === null) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
return 'get' . \ucfirst($variableName);
|
||||
}
|
||||
private function resolveParamType(?Identifier $identifier, Param $param) : string
|
||||
{
|
||||
$staticType = $identifier === null ? new MixedType() : $this->staticTypeMapper->mapPhpParserNodePHPStanType($identifier);
|
||||
return $this->createGetterFromParamAndStaticType($param, $staticType);
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Kdyby\Naming;
|
||||
|
||||
use RectorPrefix202208\Nette\Utils\Strings;
|
||||
use Rector\CodingStyle\Naming\ClassNaming;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use RectorPrefix202208\Symplify\SmartFileSystem\SmartFileInfo;
|
||||
final class EventClassNaming
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const EVENT = 'Event';
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\CodingStyle\Naming\ClassNaming
|
||||
*/
|
||||
private $classNaming;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
public function __construct(ClassNaming $classNaming, NodeNameResolver $nodeNameResolver)
|
||||
{
|
||||
$this->classNaming = $classNaming;
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
}
|
||||
public function resolveEventFileLocationFromClassNameAndFileInfo(string $className, SmartFileInfo $smartFileInfo) : string
|
||||
{
|
||||
$shortClassName = $this->nodeNameResolver->getShortName($className);
|
||||
return $smartFileInfo->getPath() . \DIRECTORY_SEPARATOR . self::EVENT . \DIRECTORY_SEPARATOR . $shortClassName . '.php';
|
||||
}
|
||||
public function createEventClassNameFromClassAndProperty(string $className, string $methodName) : string
|
||||
{
|
||||
$shortEventClass = $this->createShortEventClassNameFromClassAndProperty($className, $methodName);
|
||||
return $this->prependShortClassEventWithNamespace($shortEventClass, $className);
|
||||
}
|
||||
public function createEventClassNameFromClassPropertyReference(string $classAndPropertyName) : string
|
||||
{
|
||||
[$class, $property] = \explode('::', $classAndPropertyName);
|
||||
$shortEventClass = $this->createShortEventClassNameFromClassAndProperty($class, $property);
|
||||
return $this->prependShortClassEventWithNamespace($shortEventClass, $class);
|
||||
}
|
||||
private function prependShortClassEventWithNamespace(string $shortEventClassName, string $orinalClassName) : string
|
||||
{
|
||||
$namespaceAbove = Strings::before($orinalClassName, '\\', -1);
|
||||
return $namespaceAbove . '\\Event\\' . $shortEventClassName;
|
||||
}
|
||||
/**
|
||||
* TomatoMarket, onBuy → TomatoMarketBuyEvent
|
||||
*/
|
||||
private function createShortEventClassNameFromClassAndProperty(string $class, string $property) : string
|
||||
{
|
||||
$shortClassName = $this->classNaming->getShortName($class);
|
||||
// "onMagic" => "Magic"
|
||||
$shortPropertyName = Strings::substring($property, \strlen('on'));
|
||||
return $shortClassName . $shortPropertyName . self::EVENT;
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Kdyby\NodeAnalyzer;
|
||||
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
final class GetSubscribedEventsClassMethodAnalyzer
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeTypeResolver\NodeTypeResolver
|
||||
*/
|
||||
private $nodeTypeResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Node\BetterNodeFinder
|
||||
*/
|
||||
private $betterNodeFinder;
|
||||
public function __construct(NodeTypeResolver $nodeTypeResolver, NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder)
|
||||
{
|
||||
$this->nodeTypeResolver = $nodeTypeResolver;
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
}
|
||||
public function detect(ClassMethod $classMethod) : bool
|
||||
{
|
||||
$classLike = $this->betterNodeFinder->findParentType($classMethod, ClassLike::class);
|
||||
if (!$classLike instanceof ClassLike) {
|
||||
return \false;
|
||||
}
|
||||
if (!$this->nodeTypeResolver->isObjectType($classLike, new ObjectType('Kdyby\\Events\\Subscriber'))) {
|
||||
return \false;
|
||||
}
|
||||
return $this->nodeNameResolver->isName($classMethod, 'getSubscribedEvents');
|
||||
}
|
||||
}
|
|
@ -1,144 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Kdyby\NodeFactory;
|
||||
|
||||
use RectorPrefix202208\Nette\Utils\Strings;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Namespace_;
|
||||
use PhpParser\NodeTraverser;
|
||||
use PhpParser\NodeVisitor\NameResolver;
|
||||
use Rector\CodingStyle\Naming\ClassNaming;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\PhpParser\Node\NodeFactory;
|
||||
use Rector\Core\ValueObject\MethodName;
|
||||
use Rector\Nette\Kdyby\BlueprintFactory\VariableWithTypesFactory;
|
||||
use Rector\Nette\Kdyby\ValueObject\VariableWithType;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use RectorPrefix202208\Symplify\Astral\ValueObject\NodeBuilder\ClassBuilder;
|
||||
use RectorPrefix202208\Symplify\Astral\ValueObject\NodeBuilder\MethodBuilder;
|
||||
use RectorPrefix202208\Symplify\Astral\ValueObject\NodeBuilder\NamespaceBuilder;
|
||||
/**
|
||||
* @todo decouple to generic object factory for better re-use, e.g. this is just value object pattern
|
||||
*/
|
||||
final class EventValueObjectClassFactory
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\CodingStyle\Naming\ClassNaming
|
||||
*/
|
||||
private $classNaming;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Node\NodeFactory
|
||||
*/
|
||||
private $nodeFactory;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Nette\Kdyby\BlueprintFactory\VariableWithTypesFactory
|
||||
*/
|
||||
private $variableWithTypesFactory;
|
||||
public function __construct(ClassNaming $classNaming, NodeFactory $nodeFactory, NodeNameResolver $nodeNameResolver, VariableWithTypesFactory $variableWithTypesFactory)
|
||||
{
|
||||
$this->classNaming = $classNaming;
|
||||
$this->nodeFactory = $nodeFactory;
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->variableWithTypesFactory = $variableWithTypesFactory;
|
||||
}
|
||||
/**
|
||||
* @param Arg[] $args
|
||||
*/
|
||||
public function create(string $className, array $args) : Namespace_
|
||||
{
|
||||
$classBuilder = $this->createEventClassBuilder($className);
|
||||
$this->decorateWithConstructorIfHasArgs($classBuilder, $args);
|
||||
$class = $classBuilder->getNode();
|
||||
// traverse with node name resolver, to to comply with PHPStan default parser
|
||||
$nameResolver = new NameResolver(null, ['replaceNodes' => \false, 'preserveOriginalNames' => \true]);
|
||||
$nodeTraverser = new NodeTraverser();
|
||||
$nodeTraverser->addVisitor($nameResolver);
|
||||
$nodeTraverser->traverse([$class]);
|
||||
return $this->wrapClassToNamespace($className, $class);
|
||||
}
|
||||
private function createEventClassBuilder(string $className) : ClassBuilder
|
||||
{
|
||||
$shortClassName = $this->classNaming->getShortName($className);
|
||||
$classBuilder = new ClassBuilder($shortClassName);
|
||||
$classBuilder->makeFinal();
|
||||
$classBuilder->extend(new FullyQualified('Symfony\\Contracts\\EventDispatcher\\Event'));
|
||||
return $classBuilder;
|
||||
}
|
||||
/**
|
||||
* @param Arg[] $args
|
||||
*/
|
||||
private function decorateWithConstructorIfHasArgs(ClassBuilder $classBuilder, array $args) : void
|
||||
{
|
||||
if ($args === []) {
|
||||
return;
|
||||
}
|
||||
$variablesWithTypes = $this->variableWithTypesFactory->createVariablesWithTypesFromArgs($args);
|
||||
$this->ensureVariablesAreUnique($variablesWithTypes, $classBuilder);
|
||||
$classMethod = $this->createConstructClassMethod($variablesWithTypes);
|
||||
$classBuilder->addStmt($classMethod);
|
||||
// add properties
|
||||
foreach ($variablesWithTypes as $variableWithType) {
|
||||
$property = $this->nodeFactory->createPrivatePropertyFromNameAndType($variableWithType->getName(), $variableWithType->getType());
|
||||
$classBuilder->addStmt($property);
|
||||
}
|
||||
// add getters
|
||||
foreach ($variablesWithTypes as $variableWithType) {
|
||||
$getterClassMethod = $this->nodeFactory->createGetterClassMethod($variableWithType->getName(), $variableWithType->getType());
|
||||
$classBuilder->addStmt($getterClassMethod);
|
||||
}
|
||||
}
|
||||
private function wrapClassToNamespace(string $className, Class_ $class) : Namespace_
|
||||
{
|
||||
$namespace = Strings::before($className, '\\', -1);
|
||||
$namespaceBuilder = new NamespaceBuilder($namespace);
|
||||
$namespaceBuilder->addStmt($class);
|
||||
return $namespaceBuilder->getNode();
|
||||
}
|
||||
/**
|
||||
* @param VariableWithType[] $variablesWithTypes
|
||||
*/
|
||||
private function ensureVariablesAreUnique(array $variablesWithTypes, ClassBuilder $classBuilder) : void
|
||||
{
|
||||
$usedVariableNames = [];
|
||||
foreach ($variablesWithTypes as $variablesWithType) {
|
||||
if (\in_array($variablesWithType->getName(), $usedVariableNames, \true)) {
|
||||
$className = $this->nodeNameResolver->getName($classBuilder->getNode());
|
||||
$message = \sprintf('Variable "$%s" is duplicated in to be created "%s" class', $variablesWithType->getName(), $className);
|
||||
throw new ShouldNotHappenException($message);
|
||||
}
|
||||
$usedVariableNames[] = $variablesWithType->getName();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param VariableWithType[] $variableWithTypes
|
||||
*/
|
||||
private function createConstructClassMethod(array $variableWithTypes) : ClassMethod
|
||||
{
|
||||
$methodBuilder = new MethodBuilder(MethodName::CONSTRUCT);
|
||||
$methodBuilder->makePublic();
|
||||
foreach ($variableWithTypes as $variableWithType) {
|
||||
$param = new Param(new Variable($variableWithType->getName()));
|
||||
if ($variableWithType->getPhpParserTypeNode() !== null) {
|
||||
$param->type = $variableWithType->getPhpParserTypeNode();
|
||||
}
|
||||
$methodBuilder->addParam($param);
|
||||
$assign = $this->nodeFactory->createPropertyAssignment($variableWithType->getName());
|
||||
$methodBuilder->addStmt($assign);
|
||||
}
|
||||
return $methodBuilder->getNode();
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Kdyby\NodeManipulator;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Array_;
|
||||
use PhpParser\Node\Expr\ArrayItem;
|
||||
use PhpParser\Node\Expr\ClassConstFetch;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use Rector\Core\PhpParser\Node\Value\ValueResolver;
|
||||
use Rector\Nette\Kdyby\ValueObject\NetteEventToContributeEventClass;
|
||||
use RectorPrefix202208\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser;
|
||||
final class GetSubscribedEventsArrayManipulator
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser
|
||||
*/
|
||||
private $simpleCallableNodeTraverser;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Node\Value\ValueResolver
|
||||
*/
|
||||
private $valueResolver;
|
||||
public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, ValueResolver $valueResolver)
|
||||
{
|
||||
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
|
||||
$this->valueResolver = $valueResolver;
|
||||
}
|
||||
public function change(Array_ $array) : void
|
||||
{
|
||||
$arrayItems = \array_filter($array->items, function ($arrayItem) : bool {
|
||||
return $arrayItem !== null;
|
||||
});
|
||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($arrayItems, function (Node $node) : ?Node {
|
||||
if (!$node instanceof ArrayItem) {
|
||||
return null;
|
||||
}
|
||||
foreach (NetteEventToContributeEventClass::PROPERTY_TO_EVENT_CLASS as $netteEventProperty => $contributeEventClass) {
|
||||
if ($node->key === null) {
|
||||
continue;
|
||||
}
|
||||
if (!$this->valueResolver->isValue($node->key, $netteEventProperty)) {
|
||||
continue;
|
||||
}
|
||||
$node->key = new ClassConstFetch(new FullyQualified($contributeEventClass), 'class');
|
||||
}
|
||||
return $node;
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Kdyby\NodeManipulator;
|
||||
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use Rector\CodingStyle\Naming\ClassNaming;
|
||||
use Rector\Core\NodeAnalyzer\ParamAnalyzer;
|
||||
use Rector\Nette\Kdyby\ContributeEventClassResolver;
|
||||
use Rector\Nette\Kdyby\ValueObject\EventClassAndClassMethod;
|
||||
final class ListeningClassMethodArgumentManipulator
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const EVENT_PARAMETER_REPLACED = 'event_parameter_replaced';
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\CodingStyle\Naming\ClassNaming
|
||||
*/
|
||||
private $classNaming;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Nette\Kdyby\ContributeEventClassResolver
|
||||
*/
|
||||
private $contributeEventClassResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\NodeAnalyzer\ParamAnalyzer
|
||||
*/
|
||||
private $paramAnalyzer;
|
||||
public function __construct(ClassNaming $classNaming, ContributeEventClassResolver $contributeEventClassResolver, ParamAnalyzer $paramAnalyzer)
|
||||
{
|
||||
$this->classNaming = $classNaming;
|
||||
$this->contributeEventClassResolver = $contributeEventClassResolver;
|
||||
$this->paramAnalyzer = $paramAnalyzer;
|
||||
}
|
||||
/**
|
||||
* @param EventClassAndClassMethod[] $classMethodsByEventClass
|
||||
*/
|
||||
public function change(array $classMethodsByEventClass) : void
|
||||
{
|
||||
foreach ($classMethodsByEventClass as $classMethods) {
|
||||
// are attributes already replaced
|
||||
$classMethod = $classMethods->getClassMethod();
|
||||
$eventParameterReplaced = (bool) $classMethod->getAttribute(self::EVENT_PARAMETER_REPLACED, \false);
|
||||
if ($eventParameterReplaced) {
|
||||
continue;
|
||||
}
|
||||
$oldParams = $classMethod->params;
|
||||
$eventClass = $classMethods->getEventClass();
|
||||
$this->changeClassParamToEventClass($eventClass, $classMethod);
|
||||
// move params to getter on event
|
||||
foreach ($oldParams as $oldParam) {
|
||||
if (!$this->paramAnalyzer->isParamUsedInClassMethod($classMethod, $oldParam)) {
|
||||
continue;
|
||||
}
|
||||
$eventGetterToVariableAssign = $this->createEventGetterToVariableMethodCall($eventClass, $oldParam);
|
||||
$expression = new Expression($eventGetterToVariableAssign);
|
||||
$classMethod->stmts = \array_merge([$expression], (array) $classMethod->stmts);
|
||||
}
|
||||
$classMethod->setAttribute(self::EVENT_PARAMETER_REPLACED, \true);
|
||||
}
|
||||
}
|
||||
private function changeClassParamToEventClass(string $eventClass, ClassMethod $classMethod) : void
|
||||
{
|
||||
$paramName = $this->classNaming->getVariableName($eventClass);
|
||||
$eventVariable = new Variable($paramName);
|
||||
$param = new Param($eventVariable, null, new FullyQualified($eventClass));
|
||||
$classMethod->params = [$param];
|
||||
}
|
||||
private function createEventGetterToVariableMethodCall(string $eventClass, Param $param) : Assign
|
||||
{
|
||||
$paramName = $this->classNaming->getVariableName($eventClass);
|
||||
$eventVariable = new Variable($paramName);
|
||||
$getterMethod = $this->contributeEventClassResolver->resolveGetterMethodByEventClassAndParam($eventClass, $param);
|
||||
$methodCall = new MethodCall($eventVariable, $getterMethod);
|
||||
return new Assign($param->var, $methodCall);
|
||||
}
|
||||
}
|
|
@ -1,156 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Kdyby\NodeResolver;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\ArrayItem;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Core\PhpParser\Node\Value\ValueResolver;
|
||||
use Rector\Nette\Kdyby\Naming\EventClassNaming;
|
||||
use Rector\Nette\Kdyby\ValueObject\EventClassAndClassMethod;
|
||||
use Rector\Nette\Kdyby\ValueObject\NetteEventToContributeEventClass;
|
||||
use RectorPrefix202208\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser;
|
||||
final class ListeningMethodsCollector
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const EVENT_TYPE_CONTRIBUTTE = 'contributte';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const EVENT_TYPE_CUSTOM = 'custom';
|
||||
/**
|
||||
* @var EventClassAndClassMethod[]
|
||||
*/
|
||||
private $eventClassesAndClassMethods = [];
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser
|
||||
*/
|
||||
private $simpleCallableNodeTraverser;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Nette\Kdyby\Naming\EventClassNaming
|
||||
*/
|
||||
private $eventClassNaming;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Node\Value\ValueResolver
|
||||
*/
|
||||
private $valueResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Node\BetterNodeFinder
|
||||
*/
|
||||
private $betterNodeFinder;
|
||||
public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, EventClassNaming $eventClassNaming, ValueResolver $valueResolver, BetterNodeFinder $betterNodeFinder)
|
||||
{
|
||||
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
|
||||
$this->eventClassNaming = $eventClassNaming;
|
||||
$this->valueResolver = $valueResolver;
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
}
|
||||
/**
|
||||
* @return EventClassAndClassMethod[]
|
||||
*/
|
||||
public function collectFromClassAndGetSubscribedEventClassMethod(ClassMethod $getSubscribedEventsClassMethod, string $type) : array
|
||||
{
|
||||
$class = $this->betterNodeFinder->findParentType($getSubscribedEventsClassMethod, Class_::class);
|
||||
if (!$class instanceof Class_) {
|
||||
return [];
|
||||
}
|
||||
$this->eventClassesAndClassMethods = [];
|
||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $getSubscribedEventsClassMethod->stmts, function (Node $node) use($class, $type) {
|
||||
$classMethod = $this->matchClassMethodByArrayItem($node, $class);
|
||||
if (!$classMethod instanceof ClassMethod) {
|
||||
return null;
|
||||
}
|
||||
if (!$node instanceof ArrayItem) {
|
||||
return;
|
||||
}
|
||||
if ($node->key === null) {
|
||||
return;
|
||||
}
|
||||
$eventClass = $this->valueResolver->getValue($node->key);
|
||||
if (!\is_string($eventClass)) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
if ($type === self::EVENT_TYPE_CONTRIBUTTE) {
|
||||
/** @var string $eventClass */
|
||||
$this->resolveContributeEventClassAndSubscribedClassMethod($eventClass, $classMethod);
|
||||
return null;
|
||||
}
|
||||
$eventClassAndClassMethod = $this->resolveCustomClassMethodAndEventClass($node, $class, $eventClass);
|
||||
if (!$eventClassAndClassMethod instanceof EventClassAndClassMethod) {
|
||||
return null;
|
||||
}
|
||||
$this->eventClassesAndClassMethods[] = $eventClassAndClassMethod;
|
||||
return null;
|
||||
});
|
||||
return $this->eventClassesAndClassMethods;
|
||||
}
|
||||
/**
|
||||
* @return ClassMethod[]
|
||||
*/
|
||||
public function classMethodsListeningToEventClass(ClassMethod $getSubscribedEventsClassMethod, string $type, string $eventClassName) : array
|
||||
{
|
||||
$eventClassesAndClassMethods = $this->collectFromClassAndGetSubscribedEventClassMethod($getSubscribedEventsClassMethod, $type);
|
||||
$classMethods = [];
|
||||
foreach ($eventClassesAndClassMethods as $eventClassAndClassMethod) {
|
||||
if ($eventClassAndClassMethod->getEventClass() !== $eventClassName) {
|
||||
continue;
|
||||
}
|
||||
$classMethods[] = $eventClassAndClassMethod->getClassMethod();
|
||||
}
|
||||
return $classMethods;
|
||||
}
|
||||
private function matchClassMethodByArrayItem(Node $node, Class_ $class) : ?ClassMethod
|
||||
{
|
||||
if (!$node instanceof ArrayItem) {
|
||||
return null;
|
||||
}
|
||||
if ($node->key === null) {
|
||||
return null;
|
||||
}
|
||||
return $this->matchClassMethodByNodeValue($class, $node->value);
|
||||
}
|
||||
private function resolveContributeEventClassAndSubscribedClassMethod(string $eventClass, ClassMethod $classMethod) : void
|
||||
{
|
||||
$contributeEventClasses = NetteEventToContributeEventClass::PROPERTY_TO_EVENT_CLASS;
|
||||
if (!\in_array($eventClass, $contributeEventClasses, \true)) {
|
||||
return;
|
||||
}
|
||||
$this->eventClassesAndClassMethods[] = new EventClassAndClassMethod($eventClass, $classMethod);
|
||||
}
|
||||
private function resolveCustomClassMethodAndEventClass(ArrayItem $arrayItem, Class_ $class, string $eventClass) : ?EventClassAndClassMethod
|
||||
{
|
||||
// custom method name
|
||||
$classMethodName = $this->valueResolver->getValue($arrayItem->value);
|
||||
if (!\is_string($classMethodName)) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
$classMethod = $class->getMethod($classMethodName);
|
||||
if (\strpos($eventClass, '::') !== \false) {
|
||||
[$dispatchingClass, $property] = \explode('::', $eventClass);
|
||||
$eventClass = $this->eventClassNaming->createEventClassNameFromClassAndProperty($dispatchingClass, $property);
|
||||
}
|
||||
if (!$classMethod instanceof ClassMethod) {
|
||||
return null;
|
||||
}
|
||||
return new EventClassAndClassMethod($eventClass, $classMethod);
|
||||
}
|
||||
private function matchClassMethodByNodeValue(Class_ $class, Expr $expr) : ?ClassMethod
|
||||
{
|
||||
$possibleMethodName = $this->valueResolver->getValue($expr);
|
||||
if (!\is_string($possibleMethodName)) {
|
||||
return null;
|
||||
}
|
||||
return $class->getMethod($possibleMethodName);
|
||||
}
|
||||
}
|
|
@ -1,171 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Kdyby\Rector\ClassMethod;
|
||||
|
||||
use RectorPrefix202208\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\Array_;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use Rector\Core\Exception\NotImplementedYetException;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Nette\Kdyby\NodeAnalyzer\GetSubscribedEventsClassMethodAnalyzer;
|
||||
use Rector\Nette\Kdyby\NodeManipulator\GetSubscribedEventsArrayManipulator;
|
||||
use Rector\Nette\Kdyby\NodeManipulator\ListeningClassMethodArgumentManipulator;
|
||||
use Rector\Nette\Kdyby\NodeResolver\ListeningMethodsCollector;
|
||||
use Rector\Privatization\NodeManipulator\VisibilityManipulator;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Nette\Tests\Kdyby\Rector\ClassMethod\ChangeNetteEventNamesInGetSubscribedEventsRector\ChangeNetteEventNamesInGetSubscribedEventsRectorTest
|
||||
*/
|
||||
final class ChangeNetteEventNamesInGetSubscribedEventsRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Nette\Kdyby\NodeManipulator\GetSubscribedEventsArrayManipulator
|
||||
*/
|
||||
private $getSubscribedEventsArrayManipulator;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Nette\Kdyby\NodeManipulator\ListeningClassMethodArgumentManipulator
|
||||
*/
|
||||
private $listeningClassMethodArgumentManipulator;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Nette\Kdyby\NodeResolver\ListeningMethodsCollector
|
||||
*/
|
||||
private $listeningMethodsCollector;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Nette\Kdyby\NodeAnalyzer\GetSubscribedEventsClassMethodAnalyzer
|
||||
*/
|
||||
private $getSubscribedEventsClassMethodAnalyzer;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Privatization\NodeManipulator\VisibilityManipulator
|
||||
*/
|
||||
private $visibilityManipulator;
|
||||
public function __construct(GetSubscribedEventsArrayManipulator $getSubscribedEventsArrayManipulator, ListeningClassMethodArgumentManipulator $listeningClassMethodArgumentManipulator, ListeningMethodsCollector $listeningMethodsCollector, GetSubscribedEventsClassMethodAnalyzer $getSubscribedEventsClassMethodAnalyzer, VisibilityManipulator $visibilityManipulator)
|
||||
{
|
||||
$this->getSubscribedEventsArrayManipulator = $getSubscribedEventsArrayManipulator;
|
||||
$this->listeningClassMethodArgumentManipulator = $listeningClassMethodArgumentManipulator;
|
||||
$this->listeningMethodsCollector = $listeningMethodsCollector;
|
||||
$this->getSubscribedEventsClassMethodAnalyzer = $getSubscribedEventsClassMethodAnalyzer;
|
||||
$this->visibilityManipulator = $visibilityManipulator;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Change EventSubscriber from Kdyby to Contributte', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
use Kdyby\Events\Subscriber;
|
||||
use Nette\Application\Application;
|
||||
use Nette\Application\UI\Presenter;
|
||||
|
||||
class GetApplesSubscriber implements Subscriber
|
||||
{
|
||||
public function getSubscribedEvents()
|
||||
{
|
||||
return [
|
||||
Application::class . '::onShutdown',
|
||||
];
|
||||
}
|
||||
|
||||
public function onShutdown(Presenter $presenter)
|
||||
{
|
||||
$presenterName = $presenter->getName();
|
||||
// ...
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
use Contributte\Events\Extra\Event\Application\ShutdownEvent;
|
||||
use Kdyby\Events\Subscriber;
|
||||
use Nette\Application\Application;
|
||||
|
||||
class GetApplesSubscriber implements Subscriber
|
||||
{
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return [
|
||||
ShutdownEvent::class => 'onShutdown',
|
||||
];
|
||||
}
|
||||
|
||||
public function onShutdown(ShutdownEvent $shutdownEvent)
|
||||
{
|
||||
$presenter = $shutdownEvent->getPresenter();
|
||||
$presenterName = $presenter->getName();
|
||||
// ...
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [ClassMethod::class];
|
||||
}
|
||||
/**
|
||||
* @param ClassMethod $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$this->getSubscribedEventsClassMethodAnalyzer->detect($node)) {
|
||||
return null;
|
||||
}
|
||||
$this->visibilityManipulator->makeStatic($node);
|
||||
$this->refactorEventNames($node);
|
||||
$listeningClassMethods = $this->listeningMethodsCollector->collectFromClassAndGetSubscribedEventClassMethod($node, ListeningMethodsCollector::EVENT_TYPE_CONTRIBUTTE);
|
||||
$this->listeningClassMethodArgumentManipulator->change($listeningClassMethods);
|
||||
return $node;
|
||||
}
|
||||
private function refactorEventNames(ClassMethod $classMethod) : void
|
||||
{
|
||||
$this->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) {
|
||||
if (!$node instanceof Return_) {
|
||||
return null;
|
||||
}
|
||||
if ($node->expr === null) {
|
||||
return null;
|
||||
}
|
||||
$returnedExpr = $node->expr;
|
||||
if (!$returnedExpr instanceof Array_) {
|
||||
return null;
|
||||
}
|
||||
$this->refactorArrayWithEventTable($returnedExpr);
|
||||
$this->getSubscribedEventsArrayManipulator->change($returnedExpr);
|
||||
});
|
||||
}
|
||||
private function refactorArrayWithEventTable(Array_ $array) : void
|
||||
{
|
||||
foreach ($array->items as $arrayItem) {
|
||||
if ($arrayItem === null) {
|
||||
continue;
|
||||
}
|
||||
if ($arrayItem->key !== null) {
|
||||
continue;
|
||||
}
|
||||
$methodName = $this->resolveMethodNameFromKdybyEventName($arrayItem->value);
|
||||
$arrayItem->key = $arrayItem->value;
|
||||
$arrayItem->value = new String_($methodName);
|
||||
}
|
||||
}
|
||||
private function resolveMethodNameFromKdybyEventName(Expr $expr) : string
|
||||
{
|
||||
$kdybyEventName = $this->valueResolver->getValue($expr);
|
||||
if (!\is_string($kdybyEventName)) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
if (\strpos($kdybyEventName, '::') !== \false) {
|
||||
return (string) Strings::after($kdybyEventName, '::', -1);
|
||||
}
|
||||
throw new NotImplementedYetException($kdybyEventName);
|
||||
}
|
||||
}
|
|
@ -1,161 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Kdyby\Rector\MethodCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\Array_;
|
||||
use PhpParser\Node\Expr\ArrayItem;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\FileSystemRector\ValueObject\AddedFileWithNodes;
|
||||
use Rector\Nette\Kdyby\Naming\EventClassNaming;
|
||||
use Rector\Nette\Kdyby\NodeFactory\EventValueObjectClassFactory;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Nette\Tests\Kdyby\Rector\MethodCall\ReplaceEventManagerWithEventSubscriberRector\ReplaceEventManagerWithEventSubscriberRectorTest
|
||||
*/
|
||||
final class ReplaceEventManagerWithEventSubscriberRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Nette\Kdyby\Naming\EventClassNaming
|
||||
*/
|
||||
private $eventClassNaming;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Nette\Kdyby\NodeFactory\EventValueObjectClassFactory
|
||||
*/
|
||||
private $eventValueObjectClassFactory;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector
|
||||
*/
|
||||
private $removedAndAddedFilesCollector;
|
||||
public function __construct(EventClassNaming $eventClassNaming, EventValueObjectClassFactory $eventValueObjectClassFactory, RemovedAndAddedFilesCollector $removedAndAddedFilesCollector)
|
||||
{
|
||||
$this->eventClassNaming = $eventClassNaming;
|
||||
$this->eventValueObjectClassFactory = $eventValueObjectClassFactory;
|
||||
$this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Change Kdyby EventManager to EventDispatcher', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
use Kdyby\Events\EventManager;
|
||||
|
||||
final class SomeClass
|
||||
{
|
||||
/**
|
||||
* @var EventManager
|
||||
*/
|
||||
private $eventManager;
|
||||
|
||||
public function __construct(EventManager $eventManager)
|
||||
{
|
||||
$this->eventManager = eventManager;
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
$key = '2000';
|
||||
$this->eventManager->dispatchEvent(static::class . '::onCopy', new EventArgsList([$this, $key]));
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
use Kdyby\Events\EventManager;
|
||||
|
||||
final class SomeClass
|
||||
{
|
||||
/**
|
||||
* @var EventManager
|
||||
*/
|
||||
private $eventManager;
|
||||
|
||||
public function __construct(EventManager $eventManager)
|
||||
{
|
||||
$this->eventManager = eventManager;
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
$key = '2000';
|
||||
$this->eventManager->dispatch(new SomeClassCopyEvent($this, $key));
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [MethodCall::class];
|
||||
}
|
||||
/**
|
||||
* @param MethodCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if ($this->shouldSkip($node)) {
|
||||
return null;
|
||||
}
|
||||
$node->name = new Identifier('dispatch');
|
||||
$oldArgs = $node->args;
|
||||
$node->args = [];
|
||||
$eventReference = $oldArgs[0]->value;
|
||||
$classAndStaticProperty = $this->valueResolver->getValue($eventReference, \true);
|
||||
if (!\is_string($classAndStaticProperty)) {
|
||||
return null;
|
||||
}
|
||||
$eventClassName = $this->eventClassNaming->createEventClassNameFromClassPropertyReference($classAndStaticProperty);
|
||||
$args = $this->createNewArgs($oldArgs);
|
||||
$new = new New_(new FullyQualified($eventClassName), $args);
|
||||
$node->args[] = new Arg($new);
|
||||
// 3. create new event class with args
|
||||
$eventClassInNamespace = $this->eventValueObjectClassFactory->create($eventClassName, $args);
|
||||
$fileInfo = $this->file->getSmartFileInfo();
|
||||
$eventFileLocation = $this->eventClassNaming->resolveEventFileLocationFromClassNameAndFileInfo($eventClassName, $fileInfo);
|
||||
$addedFileWithNodes = new AddedFileWithNodes($eventFileLocation, [$eventClassInNamespace]);
|
||||
$this->removedAndAddedFilesCollector->addAddedFile($addedFileWithNodes);
|
||||
return $node;
|
||||
}
|
||||
private function shouldSkip(MethodCall $methodCall) : bool
|
||||
{
|
||||
if (!$this->isObjectType($methodCall->var, new ObjectType('Kdyby\\Events\\EventManager'))) {
|
||||
return \true;
|
||||
}
|
||||
return !$this->isName($methodCall->name, 'dispatchEvent');
|
||||
}
|
||||
/**
|
||||
* @param Arg[] $oldArgs
|
||||
* @return Arg[]
|
||||
*/
|
||||
private function createNewArgs(array $oldArgs) : array
|
||||
{
|
||||
$args = [];
|
||||
if ($oldArgs[1]->value instanceof New_) {
|
||||
/** @var New_ $new */
|
||||
$new = $oldArgs[1]->value;
|
||||
$array = $new->args[0]->value;
|
||||
if (!$array instanceof Array_) {
|
||||
return [];
|
||||
}
|
||||
foreach ($array->items as $arrayItem) {
|
||||
if (!$arrayItem instanceof ArrayItem) {
|
||||
continue;
|
||||
}
|
||||
$args[] = new Arg($arrayItem->value);
|
||||
}
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Kdyby\Rector\MethodCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Array_;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://symfony.com/doc/current/components/translation/usage.html#message-placeholders
|
||||
* @changelog https://github.com/Kdyby/Translation/blob/master/docs/en/index.md#placeholders
|
||||
* https://github.com/Kdyby/Translation/blob/6b0721c767a7be7f15b2fb13c529bea8536230aa/src/Translator.php#L172
|
||||
*
|
||||
* @see \Rector\Nette\Tests\Kdyby\Rector\MethodCall\WrapTransParameterNameRector\WrapTransParameterNameRectorTest
|
||||
*/
|
||||
final class WrapTransParameterNameRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
* @see https://regex101.com/r/b8boED/1
|
||||
*/
|
||||
private const BETWEEN_PERCENT_CHARS_REGEX = '#%(.*?)%#';
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Adds %% to placeholder name of trans() method if missing', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
use Symfony\Component\Translation\Translator;
|
||||
|
||||
final class SomeController
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$translator = new Translator('');
|
||||
$translated = $translator->trans(
|
||||
'Hello %name%',
|
||||
['name' => $name]
|
||||
);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
use Symfony\Component\Translation\Translator;
|
||||
|
||||
final class SomeController
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$translator = new Translator('');
|
||||
$translated = $translator->trans(
|
||||
'Hello %name%',
|
||||
['%name%' => $name]
|
||||
);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [MethodCall::class];
|
||||
}
|
||||
/**
|
||||
* @param MethodCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$this->isObjectType($node->var, new ObjectType('Symfony\\Component\\Translation\\TranslatorInterface'))) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isName($node->name, 'trans')) {
|
||||
return null;
|
||||
}
|
||||
if (\count($node->args) < 2) {
|
||||
return null;
|
||||
}
|
||||
if (!$node->args[1]->value instanceof Array_) {
|
||||
return null;
|
||||
}
|
||||
/** @var Array_ $parametersArrayNode */
|
||||
$parametersArrayNode = $node->args[1]->value;
|
||||
foreach ($parametersArrayNode->items as $arrayItem) {
|
||||
if ($arrayItem === null) {
|
||||
continue;
|
||||
}
|
||||
if (!$arrayItem->key instanceof String_) {
|
||||
continue;
|
||||
}
|
||||
if (StringUtils::isMatch($arrayItem->key->value, self::BETWEEN_PERCENT_CHARS_REGEX)) {
|
||||
continue;
|
||||
}
|
||||
$arrayItem->key = new String_('%' . $arrayItem->key->value . '%');
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Kdyby\ValueObject;
|
||||
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
final class EventClassAndClassMethod
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var string
|
||||
*/
|
||||
private $eventClass;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \PhpParser\Node\Stmt\ClassMethod
|
||||
*/
|
||||
private $classMethod;
|
||||
public function __construct(string $eventClass, ClassMethod $classMethod)
|
||||
{
|
||||
$this->eventClass = $eventClass;
|
||||
$this->classMethod = $classMethod;
|
||||
}
|
||||
public function getEventClass() : string
|
||||
{
|
||||
return $this->eventClass;
|
||||
}
|
||||
public function getClassMethod() : ClassMethod
|
||||
{
|
||||
return $this->classMethod;
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Kdyby\ValueObject;
|
||||
|
||||
final class NetteEventToContributeEventClass
|
||||
{
|
||||
/**
|
||||
* @var array<string, string>
|
||||
* @see https://github.com/contributte/event-dispatcher-extra/tree/master/src/Event
|
||||
*/
|
||||
public const PROPERTY_TO_EVENT_CLASS = [
|
||||
// application
|
||||
'Nette\\Application\\Application::onShutdown' => 'Contributte\\Events\\Extra\\Event\\Application\\ShutdownEvent',
|
||||
'Nette\\Application\\Application::onStartup' => 'Contributte\\Events\\Extra\\Event\\Application\\StartupEvent',
|
||||
'Nette\\Application\\Application::onError' => 'Contributte\\Events\\Extra\\Event\\Application\\ErrorEvent',
|
||||
'Nette\\Application\\Application::onPresenter' => 'Contributte\\Events\\Extra\\Event\\Application\\PresenterEvent',
|
||||
'Nette\\Application\\Application::onRequest' => 'Contributte\\Events\\Extra\\Event\\Application\\RequestEvent',
|
||||
'Nette\\Application\\Application::onResponse' => 'Contributte\\Events\\Extra\\Event\\Application\\ResponseEvent',
|
||||
// presenter
|
||||
'Nette\\Application\\UI\\Presenter::onStartup' => 'Contributte\\Events\\Extra\\Event\\Application\\PresenterShutdownEvent',
|
||||
'Nette\\Application\\UI\\Presenter::onShutdown' => 'Contributte\\Events\\Extra\\Event\\Application\\PresenterStartupEvent',
|
||||
// nette/security
|
||||
'Nette\\Security\\User::onLoggedIn' => 'Contributte\\Events\\Extra\\Event\\Security\\LoggedInEvent',
|
||||
'Nette\\Security\\User::onLoggedOut' => 'Contributte\\Events\\Extra\\Event\\Security\\LoggedOutEvent',
|
||||
// latte
|
||||
'Latte\\Engine::onCompile' => 'Contributte\\Events\\Extra\\Event\\Latte\\LatteCompileEvent',
|
||||
'Nette\\Bridges\\ApplicationLatte\\TemplateFactory::onCreate' => 'Contributte\\Events\\Extra\\Event\\Latte\\TemplateCreateEvent',
|
||||
];
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Kdyby\ValueObject;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\ComplexType;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\NullableType;
|
||||
use PhpParser\Node\UnionType;
|
||||
use PHPStan\Type\Type;
|
||||
final class VariableWithType
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \PHPStan\Type\Type
|
||||
*/
|
||||
private $type;
|
||||
/**
|
||||
* @var ComplexType|Identifier|Name|NullableType|UnionType|null
|
||||
*/
|
||||
private $phpParserTypeNode;
|
||||
/**
|
||||
* @param ComplexType|Identifier|Name|NullableType|UnionType|null $phpParserTypeNode
|
||||
*/
|
||||
public function __construct(string $name, Type $type, $phpParserTypeNode)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->type = $type;
|
||||
$this->phpParserTypeNode = $phpParserTypeNode;
|
||||
}
|
||||
public function getName() : string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
public function getType() : Type
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
/**
|
||||
* @return ComplexType|Identifier|Name|NullableType|UnionType|null
|
||||
*/
|
||||
public function getPhpParserTypeNode() : ?Node
|
||||
{
|
||||
return $this->phpParserTypeNode;
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\NodeAnalyzer;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use Rector\Nette\ValueObject\FuncCallAndExpr;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
final class BinaryOpAnalyzer
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
public function __construct(NodeNameResolver $nodeNameResolver)
|
||||
{
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
}
|
||||
public function matchFuncCallAndOtherExpr(BinaryOp $binaryOp, string $funcCallName) : ?FuncCallAndExpr
|
||||
{
|
||||
if ($binaryOp->left instanceof FuncCall) {
|
||||
if (!$this->nodeNameResolver->isName($binaryOp->left, $funcCallName)) {
|
||||
return null;
|
||||
}
|
||||
return new FuncCallAndExpr($binaryOp->left, $binaryOp->right);
|
||||
}
|
||||
if ($binaryOp->right instanceof FuncCall) {
|
||||
if (!$this->nodeNameResolver->isName($binaryOp->right, $funcCallName)) {
|
||||
return null;
|
||||
}
|
||||
return new FuncCallAndExpr($binaryOp->right, $binaryOp->left);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -11,11 +11,12 @@ final class MethodCallArgMerger
|
|||
{
|
||||
public function mergeOrApendArray(MethodCall $methodCall, int $argumentPosition, Array_ $array) : void
|
||||
{
|
||||
if (!isset($methodCall->args[$argumentPosition])) {
|
||||
$methodCallArgs = $methodCall->getArgs();
|
||||
if (!isset($methodCallArgs[$argumentPosition])) {
|
||||
$methodCall->args[$argumentPosition] = new Arg($array);
|
||||
return;
|
||||
}
|
||||
$existingParameterArgValue = $methodCall->args[$argumentPosition]->value;
|
||||
$existingParameterArgValue = $methodCallArgs[$argumentPosition]->value;
|
||||
if (!$existingParameterArgValue instanceof Array_) {
|
||||
// another parameters than array are not suported yet
|
||||
throw new NotImplementedYetException();
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\NodeAnalyzer;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\BinaryOp\Identical;
|
||||
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Expr\UnaryMinus;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use Rector\Core\PhpParser\Comparing\NodeComparator;
|
||||
use Rector\Nette\ValueObject\ContentExprAndNeedleExpr;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
final class StrlenEndsWithResolver
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Comparing\NodeComparator
|
||||
*/
|
||||
private $nodeComparator;
|
||||
public function __construct(NodeNameResolver $nodeNameResolver, NodeComparator $nodeComparator)
|
||||
{
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->nodeComparator = $nodeComparator;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical $binaryOp
|
||||
*/
|
||||
public function resolveBinaryOpForFunction($binaryOp) : ?ContentExprAndNeedleExpr
|
||||
{
|
||||
if ($binaryOp->left instanceof Variable) {
|
||||
return $this->matchContentExprAndNeedleExpr($binaryOp->right, $binaryOp->left);
|
||||
}
|
||||
if ($binaryOp->right instanceof Variable) {
|
||||
return $this->matchContentExprAndNeedleExpr($binaryOp->left, $binaryOp->right);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function matchContentExprAndNeedleExpr(Node $node, Variable $variable) : ?ContentExprAndNeedleExpr
|
||||
{
|
||||
if (!$node instanceof FuncCall) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->nodeNameResolver->isName($node, 'substr')) {
|
||||
return null;
|
||||
}
|
||||
/** @var FuncCall $node */
|
||||
if (!$node->args[1]->value instanceof UnaryMinus) {
|
||||
return null;
|
||||
}
|
||||
/** @var UnaryMinus $unaryMinus */
|
||||
$unaryMinus = $node->args[1]->value;
|
||||
if (!$unaryMinus->expr instanceof FuncCall) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->nodeNameResolver->isName($unaryMinus->expr, 'strlen')) {
|
||||
return null;
|
||||
}
|
||||
/** @var FuncCall $strlenFuncCall */
|
||||
$strlenFuncCall = $unaryMinus->expr;
|
||||
if ($this->nodeComparator->areNodesEqual($strlenFuncCall->args[0]->value, $variable)) {
|
||||
return new ContentExprAndNeedleExpr($node->args[0]->value, $strlenFuncCall->args[0]->value);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\NodeFactory;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use RectorPrefix202208\Symplify\Astral\ValueObject\NodeBuilder\MethodBuilder;
|
||||
use RectorPrefix202208\Symplify\Astral\ValueObject\NodeBuilder\ParamBuilder;
|
||||
final class CheckRequirementsClassMethodFactory
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const CHECK_REQUIREMENTS_METHOD_NAME = 'checkRequirements';
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Nette\NodeFactory\ParentGetterStmtsToExternalStmtsFactory
|
||||
*/
|
||||
private $parentGetterStmtsToExternalStmtsFactory;
|
||||
public function __construct(\Rector\Nette\NodeFactory\ParentGetterStmtsToExternalStmtsFactory $parentGetterStmtsToExternalStmtsFactory)
|
||||
{
|
||||
$this->parentGetterStmtsToExternalStmtsFactory = $parentGetterStmtsToExternalStmtsFactory;
|
||||
}
|
||||
/**
|
||||
* @param Node[] $getUserStmts
|
||||
*/
|
||||
public function create(array $getUserStmts) : ClassMethod
|
||||
{
|
||||
$methodBuilder = new MethodBuilder(self::CHECK_REQUIREMENTS_METHOD_NAME);
|
||||
$methodBuilder->makePublic();
|
||||
$paramBuilder = new ParamBuilder('element');
|
||||
$methodBuilder->addParam($paramBuilder);
|
||||
$methodBuilder->setReturnType('void');
|
||||
$parentStaticCall = $this->creatParentStaticCall();
|
||||
$newStmts = $this->parentGetterStmtsToExternalStmtsFactory->create($getUserStmts);
|
||||
$methodBuilder->addStmts($newStmts);
|
||||
$methodBuilder->addStmt($parentStaticCall);
|
||||
return $methodBuilder->getNode();
|
||||
}
|
||||
private function creatParentStaticCall() : StaticCall
|
||||
{
|
||||
$args = [new Arg(new Variable('element'))];
|
||||
return new StaticCall(new Name('parent'), new Identifier(self::CHECK_REQUIREMENTS_METHOD_NAME), $args);
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\NodeFactory;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\PhpParser\Comparing\NodeComparator;
|
||||
use Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
use RectorPrefix202208\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser;
|
||||
final class ParentGetterStmtsToExternalStmtsFactory
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeTypeResolver\NodeTypeResolver
|
||||
*/
|
||||
private $nodeTypeResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser
|
||||
*/
|
||||
private $simpleCallableNodeTraverser;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Comparing\NodeComparator
|
||||
*/
|
||||
private $nodeComparator;
|
||||
public function __construct(NodeTypeResolver $nodeTypeResolver, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeComparator $nodeComparator)
|
||||
{
|
||||
$this->nodeTypeResolver = $nodeTypeResolver;
|
||||
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
|
||||
$this->nodeComparator = $nodeComparator;
|
||||
}
|
||||
/**
|
||||
* @param Node[] $getUserStmts
|
||||
* @return Node[]
|
||||
*/
|
||||
public function create(array $getUserStmts) : array
|
||||
{
|
||||
$userExpression = null;
|
||||
foreach ($getUserStmts as $key => $getUserStmt) {
|
||||
if (!$getUserStmt instanceof Expression) {
|
||||
continue;
|
||||
}
|
||||
$getUserStmt = $getUserStmt->expr;
|
||||
if (!$getUserStmt instanceof Assign) {
|
||||
continue;
|
||||
}
|
||||
if (!$getUserStmt->expr instanceof StaticCall) {
|
||||
continue;
|
||||
}
|
||||
if (!$this->nodeTypeResolver->isObjectType($getUserStmt->expr, new ObjectType('Nette\\Security\\User'))) {
|
||||
continue;
|
||||
}
|
||||
$userExpression = $getUserStmt->var;
|
||||
unset($getUserStmts[$key]);
|
||||
}
|
||||
$getUserStmts = $this->removeReturn($getUserStmts);
|
||||
// nothing we can do
|
||||
if ($userExpression === null) {
|
||||
return [];
|
||||
}
|
||||
// stmts without assign
|
||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($getUserStmts, function (Node $node) use($userExpression) : ?MethodCall {
|
||||
if (!$this->nodeComparator->areNodesEqual($node, $userExpression)) {
|
||||
return null;
|
||||
}
|
||||
return new MethodCall(new Variable('this'), 'getUser');
|
||||
});
|
||||
return $getUserStmts;
|
||||
}
|
||||
/**
|
||||
* @param Node[] $stmts
|
||||
* @return Node[]
|
||||
*/
|
||||
private function removeReturn(array $stmts) : array
|
||||
{
|
||||
foreach ($stmts as $key => $stmt) {
|
||||
if (!$stmt instanceof Return_) {
|
||||
continue;
|
||||
}
|
||||
unset($stmts[$key]);
|
||||
}
|
||||
return $stmts;
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\Nette\NodeFinder;
|
||||
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
|
@ -120,8 +121,8 @@ final class FormFieldsFinder
|
|||
*/
|
||||
private function addFormField(array $formFields, MethodCall $addFieldMethodCall, MethodCall $methodCall) : array
|
||||
{
|
||||
$arg = $addFieldMethodCall->args[0] ?? null;
|
||||
if (!$arg) {
|
||||
$arg = $addFieldMethodCall->getArgs()[0] ?? null;
|
||||
if (!$arg instanceof Arg) {
|
||||
return $formFields;
|
||||
}
|
||||
$name = $arg->value;
|
||||
|
|
|
@ -4,7 +4,6 @@ declare (strict_types=1);
|
|||
namespace Rector\Nette\Rector\ClassMethod;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
|
@ -77,11 +76,12 @@ CODE_SAMPLE
|
|||
if (!$this->isName($methodCall->name, 'render')) {
|
||||
continue;
|
||||
}
|
||||
if (isset($methodCall->args[0])) {
|
||||
$methodCallArgs = $methodCall->getArgs();
|
||||
if (isset($methodCallArgs[0])) {
|
||||
continue;
|
||||
}
|
||||
$this->removeNode($setFileMethodCall);
|
||||
$methodCall->args[0] = new Arg($setFileMethodCall->args[0]->value);
|
||||
$methodCall->args[0] = $setFileMethodCall->getArgs()[0];
|
||||
return $node;
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -133,7 +133,7 @@ CODE_SAMPLE
|
|||
if (!$this->staticCallAnalyzer->isParentCallNamed($staticCall, MethodName::CONSTRUCT)) {
|
||||
return null;
|
||||
}
|
||||
foreach ($staticCall->args as $position => $staticCallArg) {
|
||||
foreach ($staticCall->getArgs() as $position => $staticCallArg) {
|
||||
if (!$staticCallArg->value instanceof Variable) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -1,116 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Rector\ClassMethod;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\TypeDeclaration\NodeAnalyzer\ControllerRenderMethodAnalyzer;
|
||||
use Rector\TypeDeclaration\TypeInferer\ParamTypeInferer;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Nette\Tests\Rector\ClassMethod\RenderMethodParamToTypeDeclarationRector\RenderMethodParamToTypeDeclarationRectorTest
|
||||
*/
|
||||
final class RenderMethodParamToTypeDeclarationRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $hasChanged = \false;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\TypeDeclaration\TypeInferer\ParamTypeInferer
|
||||
*/
|
||||
private $paramTypeInferer;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover
|
||||
*/
|
||||
private $paramTagRemover;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\TypeDeclaration\NodeAnalyzer\ControllerRenderMethodAnalyzer
|
||||
*/
|
||||
private $controllerRenderMethodAnalyzer;
|
||||
public function __construct(ParamTypeInferer $paramTypeInferer, ParamTagRemover $paramTagRemover, ControllerRenderMethodAnalyzer $controllerRenderMethodAnalyzer)
|
||||
{
|
||||
$this->paramTypeInferer = $paramTypeInferer;
|
||||
$this->paramTagRemover = $paramTagRemover;
|
||||
$this->controllerRenderMethodAnalyzer = $controllerRenderMethodAnalyzer;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Move @param declarations on render() method in Nette components and presenter to strict type declarations', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
use Nette\Application\UI\Control;
|
||||
|
||||
final class SomeControl extends Control
|
||||
{
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function render($name)
|
||||
{
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
use Nette\Application\UI\Control;
|
||||
|
||||
final class SomeControl extends Control
|
||||
{
|
||||
public function render(string $name)
|
||||
{
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [ClassMethod::class];
|
||||
}
|
||||
/**
|
||||
* @param ClassMethod $node
|
||||
*/
|
||||
public function refactor(Node $node)
|
||||
{
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($node);
|
||||
if (!$phpDocInfo instanceof PhpDocInfo) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->controllerRenderMethodAnalyzer->isRenderMethod($node)) {
|
||||
return null;
|
||||
}
|
||||
// $node->getParams()
|
||||
foreach ($node->params as $param) {
|
||||
$this->refactorParam($param, $phpDocInfo, $node);
|
||||
}
|
||||
if ($this->hasChanged) {
|
||||
return $node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private function refactorParam(Param $param, PhpDocInfo $phpDocInfo, ClassMethod $classMethod) : void
|
||||
{
|
||||
if ($param->type !== null) {
|
||||
return;
|
||||
}
|
||||
$inferedType = $this->paramTypeInferer->inferParam($param);
|
||||
$paramType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferedType, TypeKind::PARAM);
|
||||
if (!$paramType instanceof Node) {
|
||||
return;
|
||||
}
|
||||
$param->type = $paramType;
|
||||
$this->hasChanged = \true;
|
||||
$this->paramTagRemover->removeParamTagsIfUseless($phpDocInfo, $classMethod);
|
||||
}
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Rector\Class_;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Exception\NotImplementedYetException;
|
||||
use Rector\Core\NodeManipulator\ClassInsertManipulator;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Nette\NodeFactory\CheckRequirementsClassMethodFactory;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see https://github.com/nette/application/commit/a70c7256b645a2bee0b0c2c735020d7043a14558#diff-549e1fc650c1fc7e138900598027656a50d12b031605f8a63a38bd69a3985fafR1324
|
||||
*/
|
||||
final class MoveFinalGetUserToCheckRequirementsClassMethodRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Nette\NodeFactory\CheckRequirementsClassMethodFactory
|
||||
*/
|
||||
private $checkRequirementsClassMethodFactory;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\NodeManipulator\ClassInsertManipulator
|
||||
*/
|
||||
private $classInsertManipulator;
|
||||
public function __construct(CheckRequirementsClassMethodFactory $checkRequirementsClassMethodFactory, ClassInsertManipulator $classInsertManipulator)
|
||||
{
|
||||
$this->checkRequirementsClassMethodFactory = $checkRequirementsClassMethodFactory;
|
||||
$this->classInsertManipulator = $classInsertManipulator;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Presenter method getUser() is now final, move logic to checkRequirements()', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
use Nette\Application\UI\Presenter;
|
||||
|
||||
class SomeControl extends Presenter
|
||||
{
|
||||
public function getUser()
|
||||
{
|
||||
$user = parent::getUser();
|
||||
$user->getStorage()->setNamespace('admin_session');
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
use Nette\Application\UI\Presenter;
|
||||
|
||||
class SomeControl extends Presenter
|
||||
{
|
||||
public function checkRequirements()
|
||||
{
|
||||
$user = $this->getUser();
|
||||
$user->getStorage()->setNamespace('admin_session');
|
||||
|
||||
parent::checkRequirements();
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [Class_::class];
|
||||
}
|
||||
/**
|
||||
* @param Class_ $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$this->isObjectType($node, new ObjectType('Nette\\Application\\UI\\Presenter'))) {
|
||||
return null;
|
||||
}
|
||||
$getUserClassMethod = $node->getMethod('getUser');
|
||||
if (!$getUserClassMethod instanceof ClassMethod) {
|
||||
return null;
|
||||
}
|
||||
$checkRequirementsClassMethod = $node->getMethod('checkRequirements');
|
||||
if (!$checkRequirementsClassMethod instanceof ClassMethod) {
|
||||
$checkRequirementsClassMethod = $this->checkRequirementsClassMethodFactory->create((array) $getUserClassMethod->stmts);
|
||||
$this->classInsertManipulator->addAsFirstMethod($node, $checkRequirementsClassMethod);
|
||||
} else {
|
||||
throw new NotImplementedYetException();
|
||||
}
|
||||
$this->removeNode($getUserClassMethod);
|
||||
return $node;
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Rector\FuncCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Nette\Tests\Rector\FuncCall\FilePutContentsToFileSystemWriteRector\FilePutContentsToFileSystemWriteRectorTest
|
||||
*/
|
||||
final class FilePutContentsToFileSystemWriteRector extends AbstractRector
|
||||
{
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Change file_put_contents() to FileSystem::write()', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
file_put_contents('file.txt', 'content');
|
||||
|
||||
file_put_contents('file.txt', 'content_to_append', FILE_APPEND);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
\Nette\Utils\FileSystem::write('file.txt', 'content');
|
||||
|
||||
file_put_contents('file.txt', 'content_to_append', FILE_APPEND);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [FuncCall::class];
|
||||
}
|
||||
/**
|
||||
* @param FuncCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$this->isName($node, 'file_put_contents')) {
|
||||
return null;
|
||||
}
|
||||
if (\count($node->args) !== 2) {
|
||||
return null;
|
||||
}
|
||||
return $this->nodeFactory->createStaticCall('Nette\\Utils\\FileSystem', 'write', $node->args);
|
||||
}
|
||||
}
|
|
@ -79,7 +79,7 @@ CODE_SAMPLE
|
|||
}
|
||||
private function refactorJsonEncode(FuncCall $funcCall) : StaticCall
|
||||
{
|
||||
$args = $funcCall->args;
|
||||
$args = $funcCall->getArgs();
|
||||
if (isset($args[1])) {
|
||||
$secondArgumentValue = $args[1]->value;
|
||||
if ($this->isName($secondArgumentValue, 'JSON_PRETTY_PRINT')) {
|
||||
|
@ -91,7 +91,7 @@ CODE_SAMPLE
|
|||
}
|
||||
private function refactorJsonDecode(FuncCall $funcCall) : StaticCall
|
||||
{
|
||||
$args = $funcCall->args;
|
||||
$args = $funcCall->getArgs();
|
||||
if (isset($args[1])) {
|
||||
$secondArgumentValue = $args[1]->value;
|
||||
if ($this->valueResolver->isFalse($secondArgumentValue)) {
|
||||
|
|
|
@ -123,9 +123,10 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
$currentFunctionName = $this->getName($funcCall);
|
||||
$args = $funcCall->getArgs();
|
||||
// assign
|
||||
if (isset($funcCall->args[2]) && $currentFunctionName !== 'preg_replace') {
|
||||
return new Assign($funcCall->args[2]->value, $matchStaticCall);
|
||||
if (isset($args[2]) && $currentFunctionName !== 'preg_replace') {
|
||||
return new Assign($args[2]->value, $matchStaticCall);
|
||||
}
|
||||
return $matchStaticCall;
|
||||
}
|
||||
|
@ -158,12 +159,14 @@ CODE_SAMPLE
|
|||
private function processSplit(FuncCall $funcCall, StaticCall $matchStaticCall) : Expr
|
||||
{
|
||||
$this->compensateNetteUtilsSplitDelimCapture($matchStaticCall);
|
||||
if (!isset($funcCall->args[2])) {
|
||||
$funcCallArgs = $funcCall->getArgs();
|
||||
if (!isset($funcCallArgs[2])) {
|
||||
return $matchStaticCall;
|
||||
}
|
||||
if ($this->valueResolver->isValue($funcCall->args[2]->value, -1)) {
|
||||
if (isset($funcCall->args[3])) {
|
||||
$matchStaticCall->args[] = $funcCall->args[3];
|
||||
$thirdArg = $funcCallArgs[2];
|
||||
if ($this->valueResolver->isValue($thirdArg->value, -1)) {
|
||||
if (isset($funcCallArgs[3])) {
|
||||
$matchStaticCall->args[] = $funcCallArgs[3];
|
||||
}
|
||||
return $matchStaticCall;
|
||||
}
|
||||
|
@ -174,7 +177,8 @@ CODE_SAMPLE
|
|||
*/
|
||||
private function compensateNetteUtilsSplitDelimCapture(StaticCall $staticCall) : void
|
||||
{
|
||||
$patternValue = $this->valueResolver->getValue($staticCall->args[1]->value);
|
||||
$args = $staticCall->getArgs();
|
||||
$patternValue = $this->valueResolver->getValue($args[1]->value);
|
||||
if (!\is_string($patternValue)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -120,9 +120,10 @@ CODE_SAMPLE
|
|||
}
|
||||
return null;
|
||||
}
|
||||
$args = $funcCall->getArgs();
|
||||
// assign
|
||||
if (isset($funcCall->args[2])) {
|
||||
return new Assign($funcCall->args[2]->value, $matchStaticCall);
|
||||
if (isset($args[2])) {
|
||||
return new Assign($args[2]->value, $matchStaticCall);
|
||||
}
|
||||
return $matchStaticCall;
|
||||
}
|
||||
|
@ -138,9 +139,10 @@ CODE_SAMPLE
|
|||
}
|
||||
private function createMatchStaticCall(FuncCall $funcCall, string $methodName) : StaticCall
|
||||
{
|
||||
$originalArgs = $funcCall->getArgs();
|
||||
$args = [];
|
||||
$args[] = $funcCall->args[1];
|
||||
$args[] = $funcCall->args[0];
|
||||
$args[] = $originalArgs[1];
|
||||
$args[] = $originalArgs[0];
|
||||
$args = $this->pregMatchAllAnalyzer->compensateEnforcedFlag($methodName, $funcCall, $args);
|
||||
return $this->nodeFactory->createStaticCall('Nette\\Utils\\Strings', $methodName, $args);
|
||||
}
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Rector\Identical;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\BinaryOp\Identical;
|
||||
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
|
||||
use PhpParser\Node\Expr\BooleanNot;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Nette\NodeAnalyzer\StrlenEndsWithResolver;
|
||||
use Rector\Nette\ValueObject\ContentExprAndNeedleExpr;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see https://github.com/nette/utils/blob/master/src/Utils/Strings.php
|
||||
* @see \Rector\Nette\Tests\Rector\Identical\EndsWithFunctionToNetteUtilsStringsRector\EndsWithFunctionToNetteUtilsStringsRectorTest
|
||||
*/
|
||||
final class EndsWithFunctionToNetteUtilsStringsRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Nette\NodeAnalyzer\StrlenEndsWithResolver
|
||||
*/
|
||||
private $strlenEndsWithResolver;
|
||||
public function __construct(StrlenEndsWithResolver $strlenEndsWithResolver)
|
||||
{
|
||||
$this->strlenEndsWithResolver = $strlenEndsWithResolver;
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [Identical::class, NotIdentical::class];
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Use Nette\\Utils\\Strings::endsWith() over bare string-functions', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
public function end($needle)
|
||||
{
|
||||
$content = 'Hi, my name is Tom';
|
||||
|
||||
$yes = substr($content, -strlen($needle)) === $needle;
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
use Nette\Utils\Strings;
|
||||
|
||||
class SomeClass
|
||||
{
|
||||
public function end($needle)
|
||||
{
|
||||
$content = 'Hi, my name is Tom';
|
||||
$yes = Strings::endsWith($content, $needle);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @param Identical|NotIdentical $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
$contentExprAndNeedleExpr = $this->strlenEndsWithResolver->resolveBinaryOpForFunction($node);
|
||||
if (!$contentExprAndNeedleExpr instanceof ContentExprAndNeedleExpr) {
|
||||
return null;
|
||||
}
|
||||
$staticCall = $this->nodeFactory->createStaticCall('Nette\\Utils\\Strings', 'endsWith', [$contentExprAndNeedleExpr->getContentExpr(), $contentExprAndNeedleExpr->getNeedleExpr()]);
|
||||
if ($node instanceof NotIdentical) {
|
||||
return new BooleanNot($staticCall);
|
||||
}
|
||||
return $staticCall;
|
||||
}
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Rector\Identical;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\BinaryOp\Identical;
|
||||
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
|
||||
use PhpParser\Node\Expr\BooleanNot;
|
||||
use PhpParser\Node\Expr\UnaryMinus;
|
||||
use PhpParser\Node\Scalar\LNumber;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Nette\NodeAnalyzer\BinaryOpAnalyzer;
|
||||
use Rector\Nette\ValueObject\FuncCallAndExpr;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Nette\Tests\Rector\Identical\SubstrMinusToStringEndsWithRector\SubstrMinusToStringEndsWithRectorTest
|
||||
*/
|
||||
final class SubstrMinusToStringEndsWithRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const SUBSTR = 'substr';
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Nette\NodeAnalyzer\BinaryOpAnalyzer
|
||||
*/
|
||||
private $binaryOpAnalyzer;
|
||||
public function __construct(BinaryOpAnalyzer $binaryOpAnalyzer)
|
||||
{
|
||||
$this->binaryOpAnalyzer = $binaryOpAnalyzer;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Change substr function with minus to Strings::endsWith()', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
substr($var, -4) !== 'Test';
|
||||
substr($var, -4) === 'Test';
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
! \Nette\Utils\Strings::endsWith($var, 'Test');
|
||||
\Nette\Utils\Strings::endsWith($var, 'Test');
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [Identical::class, NotIdentical::class];
|
||||
}
|
||||
/**
|
||||
* @param Identical|NotIdentical $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
$funcCallAndExpr = $this->binaryOpAnalyzer->matchFuncCallAndOtherExpr($node, self::SUBSTR);
|
||||
if (!$funcCallAndExpr instanceof FuncCallAndExpr) {
|
||||
return null;
|
||||
}
|
||||
$substrFuncCall = $funcCallAndExpr->getFuncCall();
|
||||
if (!$substrFuncCall->args[1]->value instanceof UnaryMinus) {
|
||||
return null;
|
||||
}
|
||||
/** @var UnaryMinus $unaryMinus */
|
||||
$unaryMinus = $substrFuncCall->args[1]->value;
|
||||
if (!$unaryMinus->expr instanceof LNumber) {
|
||||
return null;
|
||||
}
|
||||
$string = $funcCallAndExpr->getExpr();
|
||||
$wordLength = $unaryMinus->expr->value;
|
||||
if ($string instanceof String_ && \strlen($string->value) !== $wordLength) {
|
||||
return null;
|
||||
}
|
||||
$arguments = [$substrFuncCall->args[0]->value, $string];
|
||||
$staticCall = $this->nodeFactory->createStaticCall('Nette\\Utils\\Strings', 'endsWith', $arguments);
|
||||
if ($node instanceof Identical) {
|
||||
return $staticCall;
|
||||
}
|
||||
return new BooleanNot($staticCall);
|
||||
}
|
||||
}
|
|
@ -1,142 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Rector\MethodCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\ArrayDimFetch;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PostRector\Collector\NodesToAddCollector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Nette\Tests\Rector\MethodCall\AddNextrasDatePickerToDateControlRector\AddNextrasDatePickerToDateControlRectorTest
|
||||
*/
|
||||
final class AddNextrasDatePickerToDateControlRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PostRector\Collector\NodesToAddCollector
|
||||
*/
|
||||
private $nodesToAddCollector;
|
||||
public function __construct(NodesToAddCollector $nodesToAddCollector)
|
||||
{
|
||||
$this->nodesToAddCollector = $nodesToAddCollector;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Nextras/Form upgrade of addDatePicker method call to DateControl assign', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
use Nette\Application\UI\Form;
|
||||
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$form = new Form();
|
||||
$form->addDatePicker('key', 'Label');
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
use Nette\Application\UI\Form;
|
||||
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$form = new Form();
|
||||
$form['key'] = new \Nextras\FormComponents\Controls\DateControl('Label');
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [MethodCall::class];
|
||||
}
|
||||
/**
|
||||
* @param MethodCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
// 1. chain call
|
||||
if ($node->var instanceof MethodCall) {
|
||||
if (!$this->isObjectType($node->var->var, new ObjectType('Nette\\Application\\UI\\Form'))) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isName($node->var->name, 'addDatePicker')) {
|
||||
return null;
|
||||
}
|
||||
$assign = $this->createAssign($node->var);
|
||||
if (!$assign instanceof Node) {
|
||||
return null;
|
||||
}
|
||||
$controlName = $this->resolveControlName($node->var);
|
||||
$node->var = new Variable($controlName);
|
||||
// this fixes printing indent
|
||||
$node->setAttribute(AttributeKey::ORIGINAL_NODE, null);
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($assign, $node);
|
||||
return $node;
|
||||
}
|
||||
// 2. assign call
|
||||
if (!$this->isObjectType($node->var, new ObjectType('Nette\\Application\\UI\\Form'))) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isName($node->name, 'addDatePicker')) {
|
||||
return null;
|
||||
}
|
||||
return $this->createAssign($node);
|
||||
}
|
||||
private function createAssign(MethodCall $methodCall) : ?Node
|
||||
{
|
||||
$key = $methodCall->args[0]->value;
|
||||
if (!$key instanceof String_) {
|
||||
return null;
|
||||
}
|
||||
$new = $this->createDateTimeControlNew($methodCall);
|
||||
$parent = $methodCall->getAttribute(AttributeKey::PARENT_NODE);
|
||||
if ($parent instanceof Assign) {
|
||||
return $new;
|
||||
}
|
||||
$arrayDimFetch = new ArrayDimFetch($methodCall->var, $key);
|
||||
$formAssign = new Assign($arrayDimFetch, $new);
|
||||
if ($parent instanceof Node) {
|
||||
$methodCalls = $this->betterNodeFinder->findInstanceOf($parent, MethodCall::class);
|
||||
if (\count($methodCalls) > 1) {
|
||||
$controlName = $this->resolveControlName($methodCall);
|
||||
return new Assign(new Variable($controlName), $formAssign);
|
||||
}
|
||||
}
|
||||
return $formAssign;
|
||||
}
|
||||
private function resolveControlName(MethodCall $methodCall) : string
|
||||
{
|
||||
$controlName = $methodCall->args[0]->value;
|
||||
if (!$controlName instanceof String_) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
return $controlName->value . 'DateControl';
|
||||
}
|
||||
private function createDateTimeControlNew(MethodCall $methodCall) : New_
|
||||
{
|
||||
$fullyQualified = new FullyQualified('Nextras\\FormComponents\\Controls\\DateControl');
|
||||
$new = new New_($fullyQualified);
|
||||
if (isset($methodCall->args[1])) {
|
||||
$new->args[] = $methodCall->args[1];
|
||||
}
|
||||
return $new;
|
||||
}
|
||||
}
|
|
@ -45,11 +45,12 @@ CODE_SAMPLE
|
|||
if (!$this->isName($node->name, 'addUpload')) {
|
||||
return null;
|
||||
}
|
||||
$args = $node->args;
|
||||
$args = $node->getArgs();
|
||||
if (!isset($args[2])) {
|
||||
return null;
|
||||
}
|
||||
if ($this->valueResolver->isTrue($node->args[2]->value)) {
|
||||
$thirdArg = $args[2];
|
||||
if ($this->valueResolver->isTrue($thirdArg->value)) {
|
||||
$node->name = new Identifier('addMultiUpload');
|
||||
unset($node->args[2]);
|
||||
return $node;
|
||||
|
|
|
@ -67,11 +67,12 @@ CODE_SAMPLE
|
|||
if (!$this->isName($node->name, 'getConfig')) {
|
||||
return null;
|
||||
}
|
||||
if (\count($node->args) !== 1) {
|
||||
$args = $node->getArgs();
|
||||
if (\count($args) !== 1) {
|
||||
return null;
|
||||
}
|
||||
$getConfigMethodCall = new MethodCall(new Variable('this'), 'getConfig');
|
||||
$firstArgValue = $node->args[0]->value;
|
||||
$firstArgValue = $args[0]->value;
|
||||
return $this->nodeFactory->createFuncCall('array_merge', [$firstArgValue, $getConfigMethodCall]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,11 +59,12 @@ CODE_SAMPLE
|
|||
if (!$this->isName($node->name, 'getCookie')) {
|
||||
return null;
|
||||
}
|
||||
$args = $node->getArgs();
|
||||
// no default value
|
||||
if (!isset($node->args[1])) {
|
||||
if (!isset($args[1])) {
|
||||
return null;
|
||||
}
|
||||
$defaultValue = $node->args[1]->value;
|
||||
$defaultValue = $args[1]->value;
|
||||
unset($node->args[1]);
|
||||
return new Coalesce($node, $defaultValue);
|
||||
}
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Rector\Neon;
|
||||
|
||||
use RectorPrefix202208\Nette\Neon\Node;
|
||||
use Rector\Nette\Contract\Rector\NeonRectorInterface;
|
||||
use Rector\Nette\NeonParser\Node\Service_\SetupMethodCall;
|
||||
use Rector\Renaming\Collector\MethodCallRenameCollector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Nette\Tests\Rector\Neon\RenameMethodNeonRector\RenameMethodNeonRectorTest
|
||||
*
|
||||
* @implements NeonRectorInterface<SetupMethodCall>
|
||||
*/
|
||||
final class RenameMethodNeonRector implements NeonRectorInterface
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Renaming\Collector\MethodCallRenameCollector
|
||||
*/
|
||||
private $methodCallRenameCollector;
|
||||
public function __construct(MethodCallRenameCollector $methodCallRenameCollector)
|
||||
{
|
||||
$this->methodCallRenameCollector = $methodCallRenameCollector;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Renames method calls in NEON configs', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
services:
|
||||
-
|
||||
class: SomeClass
|
||||
setup:
|
||||
- oldCall
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
services:
|
||||
-
|
||||
class: SomeClass
|
||||
setup:
|
||||
- newCall
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
public function getNodeType() : string
|
||||
{
|
||||
return SetupMethodCall::class;
|
||||
}
|
||||
/**
|
||||
* @param SetupMethodCall $node
|
||||
* @return \Nette\Neon\Node|null
|
||||
*/
|
||||
public function enterNode(Node $node)
|
||||
{
|
||||
foreach ($this->methodCallRenameCollector->getMethodCallRenames() as $methodCallRename) {
|
||||
if (!\is_a($node->className, $methodCallRename->getClass(), \true)) {
|
||||
continue;
|
||||
}
|
||||
if ($node->getMethodName() !== $methodCallRename->getOldMethod()) {
|
||||
continue;
|
||||
}
|
||||
$node->methodNameLiteralNode->value = $methodCallRename->getNewMethod();
|
||||
return $node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Rector\NotIdentical;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
use PhpParser\Node\Expr\BinaryOp\Identical;
|
||||
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
|
||||
use PhpParser\Node\Expr\BooleanNot;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see https://3v4l.org/CubLi
|
||||
* @see https://github.com/nette/utils/blob/bd961f49b211997202bda1d0fbc410905be370d4/src/Utils/Strings.php#L81
|
||||
*
|
||||
* @see \Rector\Nette\Tests\Rector\NotIdentical\StrposToStringsContainsRector\StrposToStringsContainsRectorTest
|
||||
*/
|
||||
final class StrposToStringsContainsRector extends AbstractRector
|
||||
{
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Use Nette\\Utils\\Strings over bare string-functions', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$name = 'Hi, my name is Tom';
|
||||
return strpos($name, 'Hi') !== false;
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$name = 'Hi, my name is Tom';
|
||||
return \Nette\Utils\Strings::contains($name, 'Hi');
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [NotIdentical::class, Identical::class];
|
||||
}
|
||||
/**
|
||||
* @param NotIdentical|Identical $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
$funcCall = $this->matchStrposInComparisonToFalse($node);
|
||||
if (!$funcCall instanceof FuncCall) {
|
||||
return null;
|
||||
}
|
||||
if (isset($funcCall->args[2]) && !$this->valueResolver->isValue($funcCall->args[2]->value, 0)) {
|
||||
return null;
|
||||
}
|
||||
$containsStaticCall = $this->nodeFactory->createStaticCall('Nette\\Utils\\Strings', 'contains');
|
||||
$containsStaticCall->args[0] = $funcCall->args[0];
|
||||
$containsStaticCall->args[1] = $funcCall->args[1];
|
||||
if ($node instanceof Identical) {
|
||||
return new BooleanNot($containsStaticCall);
|
||||
}
|
||||
return $containsStaticCall;
|
||||
}
|
||||
private function matchStrposInComparisonToFalse(BinaryOp $binaryOp) : ?Expr
|
||||
{
|
||||
if ($this->valueResolver->isFalse($binaryOp->left)) {
|
||||
$rightExpr = $binaryOp->right;
|
||||
if ($this->isStrposFuncCall($rightExpr)) {
|
||||
return $rightExpr;
|
||||
}
|
||||
}
|
||||
if ($this->valueResolver->isFalse($binaryOp->right)) {
|
||||
$leftExpr = $binaryOp->left;
|
||||
if ($this->isStrposFuncCall($leftExpr)) {
|
||||
return $leftExpr;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private function isStrposFuncCall(Expr $expr) : bool
|
||||
{
|
||||
if (!$expr instanceof FuncCall) {
|
||||
return \false;
|
||||
}
|
||||
return $this->isName($expr, 'strpos');
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Nette\Set;
|
||||
|
||||
use Rector\Set\Contract\SetListInterface;
|
||||
final class ContributteSetList implements SetListInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const APITTE_ATTRIBUTES = __DIR__ . '/../../config/sets/contributte/apitte-attributes.php';
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user