mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit 8961d20f56fa4b39bb21feec1f24422398f13dba
8961d20f56
[DX] Localize multi instance checker and privates accessor from Symplify + bump to PHPStan 1.8.3 (#2883)
This commit is contained in:
parent
9632c3edb1
commit
28c719d1fb
|
@ -11,9 +11,9 @@ use Rector\Core\Console\ConsoleApplication;
|
|||
use Rector\Core\Console\Style\RectorConsoleOutputStyleFactory;
|
||||
use Rector\Core\DependencyInjection\RectorContainerFactory;
|
||||
use Rector\Core\Kernel\RectorKernel;
|
||||
use Rector\Core\Util\Reflection\PrivatesAccessor;
|
||||
use RectorPrefix202209\Symfony\Component\Console\Command\Command;
|
||||
use RectorPrefix202209\Symfony\Component\Console\Input\ArgvInput;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
||||
// @ intentionally: continue anyway
|
||||
@\ini_set('memory_limit', '-1');
|
||||
// Performance boost
|
||||
|
@ -117,7 +117,7 @@ try {
|
|||
echo Json::encode(['fatal_errors' => [$throwable->getMessage()]]);
|
||||
} else {
|
||||
// report fatal errors in console format
|
||||
$rectorConsoleOutputStyleFactory = new RectorConsoleOutputStyleFactory(new PrivatesCaller());
|
||||
$rectorConsoleOutputStyleFactory = new RectorConsoleOutputStyleFactory(new PrivatesAccessor());
|
||||
$rectorConsoleOutputStyle = $rectorConsoleOutputStyleFactory->create();
|
||||
$rectorConsoleOutputStyle->error($throwable->getMessage());
|
||||
}
|
||||
|
|
|
@ -50,10 +50,7 @@ use RectorPrefix202209\Symfony\Component\Filesystem\Filesystem;
|
|||
use RectorPrefix202209\Symplify\EasyParallel\ValueObject\EasyParallelConfig;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Php\TypeChecker;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Reflection\ClassLikeExistenceChecker;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Yaml\ParametersMerger;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
// make use of https://github.com/symplify/easy-parallel
|
||||
|
@ -118,14 +115,10 @@ return static function (RectorConfig $rectorConfig) : void {
|
|||
$services->set(RectorConsoleOutputStyle::class)->factory([service(RectorConsoleOutputStyleFactory::class), 'create']);
|
||||
$services->set(Parser::class)->factory([service(PHPStanServicesFactory::class), 'createPHPStanParser']);
|
||||
$services->set(Lexer::class)->factory([service(PHPStanServicesFactory::class), 'createEmulativeLexer']);
|
||||
// symplify/package-builder
|
||||
$services->set(PrivatesAccessor::class);
|
||||
$services->set(PrivatesCaller::class);
|
||||
$services->set(ParameterProvider::class)->arg('$container', service('service_container'));
|
||||
$services->set(InflectorFactory::class);
|
||||
$services->set(Inflector::class)->factory([service(InflectorFactory::class), 'build']);
|
||||
$services->set(VersionParser::class);
|
||||
$services->set(TypeChecker::class);
|
||||
// console
|
||||
$services->set(SymfonyStyleFactory::class);
|
||||
$services->set(SymfonyStyle::class)->factory([service(SymfonyStyleFactory::class), 'create']);
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Rector\BetterPhpDocParser\PhpDocInfo;
|
|||
use PHPStan\PhpDocParser\Lexer\Lexer;
|
||||
use PHPStan\PhpDocParser\Parser\TokenIterator;
|
||||
use Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
use Rector\Core\Util\Reflection\PrivatesAccessor;
|
||||
final class TokenIteratorFactory
|
||||
{
|
||||
/**
|
||||
|
@ -20,7 +20,7 @@ final class TokenIteratorFactory
|
|||
private $lexer;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\PackageBuilder\Reflection\PrivatesAccessor
|
||||
* @var \Rector\Core\Util\Reflection\PrivatesAccessor
|
||||
*/
|
||||
private $privatesAccessor;
|
||||
public function __construct(Lexer $lexer, PrivatesAccessor $privatesAccessor)
|
||||
|
|
|
@ -21,7 +21,7 @@ use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
|||
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
|
||||
use Rector\Core\Configuration\CurrentNodeProvider;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
||||
use Rector\Core\Util\Reflection\PrivatesAccessor;
|
||||
/**
|
||||
* @see \Rector\Tests\BetterPhpDocParser\PhpDocParser\TagValueNodeReprint\TagValueNodeReprintTest
|
||||
*/
|
||||
|
@ -44,19 +44,19 @@ final class BetterPhpDocParser extends PhpDocParser
|
|||
private $phpDocNodeDecorators;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\PackageBuilder\Reflection\PrivatesCaller
|
||||
* @var \Rector\Core\Util\Reflection\PrivatesAccessor
|
||||
*/
|
||||
private $privatesCaller;
|
||||
private $privatesAccessor;
|
||||
/**
|
||||
* @param PhpDocNodeDecoratorInterface[] $phpDocNodeDecorators
|
||||
*/
|
||||
public function __construct(TypeParser $typeParser, ConstExprParser $constExprParser, CurrentNodeProvider $currentNodeProvider, TokenIteratorFactory $tokenIteratorFactory, array $phpDocNodeDecorators, PrivatesCaller $privatesCaller = null)
|
||||
public function __construct(TypeParser $typeParser, ConstExprParser $constExprParser, CurrentNodeProvider $currentNodeProvider, TokenIteratorFactory $tokenIteratorFactory, array $phpDocNodeDecorators, PrivatesAccessor $privatesAccessor = null)
|
||||
{
|
||||
$privatesCaller = $privatesCaller ?? new PrivatesCaller();
|
||||
$privatesAccessor = $privatesAccessor ?? new PrivatesAccessor();
|
||||
$this->currentNodeProvider = $currentNodeProvider;
|
||||
$this->tokenIteratorFactory = $tokenIteratorFactory;
|
||||
$this->phpDocNodeDecorators = $phpDocNodeDecorators;
|
||||
$this->privatesCaller = $privatesCaller;
|
||||
$this->privatesAccessor = $privatesAccessor;
|
||||
parent::__construct($typeParser, $constExprParser);
|
||||
}
|
||||
public function parse(TokenIterator $tokenIterator) : PhpDocNode
|
||||
|
@ -113,7 +113,7 @@ final class BetterPhpDocParser extends PhpDocParser
|
|||
$betterTokenIterator = $this->tokenIteratorFactory->createFromTokenIterator($tokenIterator);
|
||||
$startPosition = $betterTokenIterator->currentPosition();
|
||||
/** @var PhpDocChildNode $phpDocNode */
|
||||
$phpDocNode = $this->privatesCaller->callPrivateMethod($this, 'parseChild', [$betterTokenIterator]);
|
||||
$phpDocNode = $this->privatesAccessor->callPrivateMethod($this, 'parseChild', [$betterTokenIterator]);
|
||||
$endPosition = $betterTokenIterator->currentPosition();
|
||||
$startAndEnd = new StartAndEnd($startPosition, $endPosition);
|
||||
$phpDocNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd);
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Rector\BetterPhpDocParser\ValueObject\Parser;
|
|||
|
||||
use PHPStan\PhpDocParser\Parser\TokenIterator;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
use Rector\Core\Util\Reflection\PrivatesAccessor;
|
||||
final class BetterTokenIterator extends TokenIterator
|
||||
{
|
||||
/**
|
||||
|
@ -18,7 +18,7 @@ final class BetterTokenIterator extends TokenIterator
|
|||
private const INDEX = 'index';
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\PackageBuilder\Reflection\PrivatesAccessor
|
||||
* @var \Rector\Core\Util\Reflection\PrivatesAccessor
|
||||
*/
|
||||
private $privatesAccessor;
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,7 @@ use PhpParser\Node\Stmt;
|
|||
use PHPStan\Analyser\MutatingScope;
|
||||
use PHPStan\Analyser\NodeScopeResolver;
|
||||
use PHPStan\Dependency\DependencyResolver as PHPStanDependencyResolver;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
use Rector\Core\Util\Reflection\PrivatesAccessor;
|
||||
final class DependencyResolver
|
||||
{
|
||||
/**
|
||||
|
@ -22,7 +22,7 @@ final class DependencyResolver
|
|||
private $phpStanDependencyResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\PackageBuilder\Reflection\PrivatesAccessor
|
||||
* @var \Rector\Core\Util\Reflection\PrivatesAccessor
|
||||
*/
|
||||
private $privatesAccessor;
|
||||
public function __construct(NodeScopeResolver $nodeScopeResolver, PHPStanDependencyResolver $phpStanDependencyResolver, PrivatesAccessor $privatesAccessor)
|
||||
|
|
|
@ -23,11 +23,11 @@ use PHPStan\Type\UnionType;
|
|||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\PhpParser\AstResolver;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Core\Util\Reflection\PrivatesAccessor;
|
||||
use Rector\FamilyTree\ValueObject\PropertyType;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
final class FamilyRelationsAnalyzer
|
||||
{
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ final class FamilyRelationsAnalyzer
|
|||
private $reflectionProvider;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\PackageBuilder\Reflection\PrivatesAccessor
|
||||
* @var \Rector\Core\Util\Reflection\PrivatesAccessor
|
||||
*/
|
||||
private $privatesAccessor;
|
||||
/**
|
||||
|
|
|
@ -4,6 +4,7 @@ declare (strict_types=1);
|
|||
namespace Rector\NodeTypeResolver\NodeTypeCorrector;
|
||||
|
||||
use PHPStan\Type\Accessory\AccessoryNonEmptyStringType;
|
||||
use PHPStan\Type\Accessory\AccessoryNonFalsyStringType;
|
||||
use PHPStan\Type\IntersectionType;
|
||||
use PHPStan\Type\Type;
|
||||
final class AccessoryNonEmptyStringTypeCorrector
|
||||
|
@ -16,7 +17,7 @@ final class AccessoryNonEmptyStringTypeCorrector
|
|||
if (!$mainType instanceof IntersectionType) {
|
||||
return $mainType;
|
||||
}
|
||||
if (!$mainType->isSubTypeOf(new AccessoryNonEmptyStringType())->yes()) {
|
||||
if (!$mainType->isSubTypeOf(new AccessoryNonEmptyStringType())->yes() && !$mainType->isSubTypeOf(new AccessoryNonFalsyStringType())->yes()) {
|
||||
return $mainType;
|
||||
}
|
||||
$clearIntersectionedTypes = [];
|
||||
|
@ -24,6 +25,9 @@ final class AccessoryNonEmptyStringTypeCorrector
|
|||
if ($intersectionedType instanceof AccessoryNonEmptyStringType) {
|
||||
continue;
|
||||
}
|
||||
if ($intersectionedType instanceof AccessoryNonFalsyStringType) {
|
||||
continue;
|
||||
}
|
||||
$clearIntersectionedTypes[] = $intersectionedType;
|
||||
}
|
||||
if (\count($clearIntersectionedTypes) === 1) {
|
||||
|
|
|
@ -46,11 +46,11 @@ use Rector\Caching\FileSystem\DependencyResolver;
|
|||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\StaticReflection\SourceLocator\ParentAttributeSourceLocator;
|
||||
use Rector\Core\StaticReflection\SourceLocator\RenamedClassesSourceLocator;
|
||||
use Rector\Core\Util\Reflection\PrivatesAccessor;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor\RemoveDeepChainMethodCallNodeVisitor;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
use RectorPrefix202209\Webmozart\Assert\Assert;
|
||||
/**
|
||||
* @inspired by https://github.com/silverstripe/silverstripe-upgrader/blob/532182b23e854d02e0b27e68ebc394f436de0682/src/UpgradeRule/PHP/Visitor/PHPStanScopeVisitor.php
|
||||
|
@ -99,7 +99,7 @@ final class PHPStanNodeScopeResolver
|
|||
private $scopeFactory;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\PackageBuilder\Reflection\PrivatesAccessor
|
||||
* @var \Rector\Core\Util\Reflection\PrivatesAccessor
|
||||
*/
|
||||
private $privatesAccessor;
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
||||
use PHPStan\Type\Accessory\AccessoryNonFalsyStringType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
/**
|
||||
* @implements TypeMapperInterface<AccessoryNonFalsyStringType>
|
||||
*/
|
||||
final class AccessoryNonFalsyStringTypeMapper implements TypeMapperInterface
|
||||
{
|
||||
/**
|
||||
* @return class-string<Type>
|
||||
*/
|
||||
public function getNodeClass() : string
|
||||
{
|
||||
return AccessoryNonFalsyStringType::class;
|
||||
}
|
||||
/**
|
||||
* @param AccessoryNonFalsyStringType $type
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode
|
||||
{
|
||||
return new IdentifierTypeNode('string');
|
||||
}
|
||||
/**
|
||||
* @param AccessoryNonFalsyStringType $type
|
||||
*/
|
||||
public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node
|
||||
{
|
||||
return new Name('string');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
use PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
||||
use PHPStan\Type\Accessory\HasOffsetValueType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
/**
|
||||
* @implements TypeMapperInterface<HasOffsetValueType>
|
||||
*/
|
||||
final class HasOffsetValueTypeTypeMapper implements TypeMapperInterface
|
||||
{
|
||||
/**
|
||||
* @return class-string<Type>
|
||||
*/
|
||||
public function getNodeClass() : string
|
||||
{
|
||||
return HasOffsetValueType::class;
|
||||
}
|
||||
/**
|
||||
* @param HasOffsetValueType $type
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode
|
||||
{
|
||||
return new ArrayTypeNode(new IdentifierTypeNode('mixed'));
|
||||
}
|
||||
/**
|
||||
* @param HasOffsetValueType $type
|
||||
*/
|
||||
public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node
|
||||
{
|
||||
return new Name('array');
|
||||
}
|
||||
}
|
|
@ -21,8 +21,8 @@ use PhpParser\Node\Stmt\While_;
|
|||
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Util\MultiInstanceofChecker;
|
||||
use Rector\DeadCode\NodeAnalyzer\ExprUsedInNodeAnalyzer;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Php\TypeChecker;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
|
@ -36,20 +36,20 @@ final class RemoveNonExistingVarAnnotationRector extends AbstractRector
|
|||
* @var array<class-string<Node>>
|
||||
*/
|
||||
private const NODES_TO_MATCH = [Assign::class, AssignRef::class, Foreach_::class, Static_::class, Echo_::class, Return_::class, Expression::class, Throw_::class, If_::class, While_::class, Switch_::class, Nop::class];
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\PackageBuilder\Php\TypeChecker
|
||||
*/
|
||||
private $typeChecker;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\DeadCode\NodeAnalyzer\ExprUsedInNodeAnalyzer
|
||||
*/
|
||||
private $exprUsedInNodeAnalyzer;
|
||||
public function __construct(TypeChecker $typeChecker, ExprUsedInNodeAnalyzer $exprUsedInNodeAnalyzer)
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\Util\MultiInstanceofChecker
|
||||
*/
|
||||
private $multiInstanceofChecker;
|
||||
public function __construct(ExprUsedInNodeAnalyzer $exprUsedInNodeAnalyzer, MultiInstanceofChecker $multiInstanceofChecker)
|
||||
{
|
||||
$this->typeChecker = $typeChecker;
|
||||
$this->exprUsedInNodeAnalyzer = $exprUsedInNodeAnalyzer;
|
||||
$this->multiInstanceofChecker = $multiInstanceofChecker;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
|
@ -128,10 +128,10 @@ CODE_SAMPLE
|
|||
private function shouldSkip(Node $node) : bool
|
||||
{
|
||||
if (!$node instanceof Nop) {
|
||||
return !$this->typeChecker->isInstanceOf($node, self::NODES_TO_MATCH);
|
||||
return !$this->multiInstanceofChecker->isInstanceOf($node, self::NODES_TO_MATCH);
|
||||
}
|
||||
if (\count($node->getComments()) <= 1) {
|
||||
return !$this->typeChecker->isInstanceOf($node, self::NODES_TO_MATCH);
|
||||
return !$this->multiInstanceofChecker->isInstanceOf($node, self::NODES_TO_MATCH);
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
|||
use Rector\Core\PhpParser\Node\NodeFactory;
|
||||
use Rector\Core\PhpParser\Parser\InlineCodeParser;
|
||||
use Rector\Core\PhpParser\Parser\SimplePhpParser;
|
||||
use Rector\Core\Util\Reflection\PrivatesAccessor;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\Php72\NodeManipulator\ClosureNestedUsesDecorator;
|
||||
|
@ -48,7 +49,6 @@ use Rector\PhpDocParser\NodeTraverser\SimpleCallableNodeTraverser;
|
|||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
use ReflectionParameter;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
final class AnonymousFunctionFactory
|
||||
{
|
||||
/**
|
||||
|
@ -98,7 +98,7 @@ final class AnonymousFunctionFactory
|
|||
private $astResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\PackageBuilder\Reflection\PrivatesAccessor
|
||||
* @var \Rector\Core\Util\Reflection\PrivatesAccessor
|
||||
*/
|
||||
private $privatesAccessor;
|
||||
/**
|
||||
|
|
|
@ -24,11 +24,11 @@ use PHPStan\Type\UnionType;
|
|||
use PHPStan\Type\VoidType;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\Core\Util\MultiInstanceofChecker;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\SelfObjectType;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Php\TypeChecker;
|
||||
final class NonInformativeReturnTagRemover
|
||||
{
|
||||
/**
|
||||
|
@ -42,13 +42,13 @@ final class NonInformativeReturnTagRemover
|
|||
private $phpDocInfoFactory;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\PackageBuilder\Php\TypeChecker
|
||||
* @var \Rector\Core\Util\MultiInstanceofChecker
|
||||
*/
|
||||
private $typeChecker;
|
||||
public function __construct(PhpDocInfoFactory $phpDocInfoFactory, TypeChecker $typeChecker)
|
||||
private $multiInstanceofChecker;
|
||||
public function __construct(PhpDocInfoFactory $phpDocInfoFactory, MultiInstanceofChecker $multiInstanceofChecker)
|
||||
{
|
||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||
$this->typeChecker = $typeChecker;
|
||||
$this->multiInstanceofChecker = $multiInstanceofChecker;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike
|
||||
|
@ -66,7 +66,7 @@ final class NonInformativeReturnTagRemover
|
|||
}
|
||||
$returnType = $phpDocInfo->getReturnType();
|
||||
// is bare type
|
||||
if ($this->typeChecker->isInstanceOf($returnType, [FloatType::class, StringType::class, IntegerType::class])) {
|
||||
if ($this->multiInstanceofChecker->isInstanceOf($returnType, [FloatType::class, StringType::class, IntegerType::class])) {
|
||||
$phpDocInfo->removeByType(ReturnTagValueNode::class);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,21 +4,25 @@ declare (strict_types=1);
|
|||
namespace Rector\TypeDeclaration\Rector\ClassMethod;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Type\ArrayType;
|
||||
use PHPStan\Type\Generic\GenericObjectType;
|
||||
use PHPStan\Type\IterableType;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\Type;
|
||||
use PHPStan\Type\VoidType;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Rector\AbstractScopeAwareRector;
|
||||
use Rector\DeadCode\PhpDoc\TagRemover\ReturnTagRemover;
|
||||
use Rector\Privatization\TypeManipulator\NormalizeTypeToRespectArrayScalarType;
|
||||
use Rector\Privatization\TypeManipulator\TypeNormalizer;
|
||||
|
@ -34,7 +38,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
|||
/**
|
||||
* @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector\AddArrayReturnDocTypeRectorTest
|
||||
*/
|
||||
final class AddArrayReturnDocTypeRector extends AbstractRector
|
||||
final class AddArrayReturnDocTypeRector extends AbstractScopeAwareRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
|
@ -144,9 +148,9 @@ CODE_SAMPLE
|
|||
/**
|
||||
* @param ClassMethod $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
public function refactorWithScope(Node $node, Scope $scope) : ?Node
|
||||
{
|
||||
if ($this->isDataProviderClassMethod($node)) {
|
||||
if ($this->isDataProviderClassMethod($node, $scope)) {
|
||||
return null;
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
|
@ -264,8 +268,11 @@ CODE_SAMPLE
|
|||
}
|
||||
return \false;
|
||||
}
|
||||
private function isDataProviderClassMethod(ClassMethod $classMethod) : bool
|
||||
private function isDataProviderClassMethod(ClassMethod $classMethod, Scope $scope) : bool
|
||||
{
|
||||
if ($this->isPublicMethodInTestCaseWithReturnIterator($scope, $classMethod)) {
|
||||
return \true;
|
||||
}
|
||||
// should skip data provider, because complex structures
|
||||
$class = $this->betterNodeFinder->findParentType($classMethod, Class_::class);
|
||||
if (!$class instanceof Class_) {
|
||||
|
@ -275,4 +282,21 @@ CODE_SAMPLE
|
|||
$classMethodName = $classMethod->name->toString();
|
||||
return \in_array($classMethodName, $dataProviderMethodNames, \true);
|
||||
}
|
||||
private function isPublicMethodInTestCaseWithReturnIterator(Scope $scope, ClassMethod $classMethod) : bool
|
||||
{
|
||||
$classReflection = $scope->getClassReflection();
|
||||
if (!$classReflection instanceof ClassReflection) {
|
||||
return \false;
|
||||
}
|
||||
if (!$classReflection->isSubclassOf(TestCase::class)) {
|
||||
return \false;
|
||||
}
|
||||
if (!$classMethod->returnType instanceof FullyQualified) {
|
||||
return \false;
|
||||
}
|
||||
if (!$this->isName($classMethod->returnType, 'Iterator')) {
|
||||
return \false;
|
||||
}
|
||||
return $classMethod->isPublic();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@ use PHPStan\Type\StringType;
|
|||
use PHPStan\Type\Type;
|
||||
use PHPStan\Type\TypeTraverser;
|
||||
use PHPStan\Type\UnionType;
|
||||
use Rector\Core\Util\Reflection\PrivatesAccessor;
|
||||
use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
|
||||
use Rector\TypeDeclaration\ValueObject\NestedArrayType;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
/**
|
||||
* @see \Rector\Tests\TypeDeclaration\TypeNormalizerTest
|
||||
*/
|
||||
|
@ -32,7 +32,7 @@ final class TypeNormalizer
|
|||
private $typeFactory;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\PackageBuilder\Reflection\PrivatesAccessor
|
||||
* @var \Rector\Core\Util\Reflection\PrivatesAccessor
|
||||
*/
|
||||
private $privatesAccessor;
|
||||
public function __construct(TypeFactory $typeFactory, PrivatesAccessor $privatesAccessor)
|
||||
|
|
|
@ -17,12 +17,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'c6c1026bbeb8312e0f1598eb0d57f466b076f420';
|
||||
public const PACKAGE_VERSION = '8961d20f56fa4b39bb21feec1f24422398f13dba';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-09-01 17:12:14';
|
||||
public const RELEASE_DATE = '2022-09-01 19:25:30';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
@ -3,28 +3,28 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\Core\Console\Style;
|
||||
|
||||
use Rector\Core\Util\Reflection\PrivatesAccessor;
|
||||
use RectorPrefix202209\Symfony\Component\Console\Application;
|
||||
use RectorPrefix202209\Symfony\Component\Console\Input\ArgvInput;
|
||||
use RectorPrefix202209\Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use RectorPrefix202209\Symfony\Component\Console\Output\OutputInterface;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
||||
final class RectorConsoleOutputStyleFactory
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\PackageBuilder\Reflection\PrivatesCaller
|
||||
* @var \Rector\Core\Util\Reflection\PrivatesAccessor
|
||||
*/
|
||||
private $privatesCaller;
|
||||
public function __construct(PrivatesCaller $privatesCaller)
|
||||
private $privatesAccessor;
|
||||
public function __construct(PrivatesAccessor $privatesAccessor)
|
||||
{
|
||||
$this->privatesCaller = $privatesCaller;
|
||||
$this->privatesAccessor = $privatesAccessor;
|
||||
}
|
||||
public function create() : \Rector\Core\Console\Style\RectorConsoleOutputStyle
|
||||
{
|
||||
$argvInput = new ArgvInput();
|
||||
$consoleOutput = new ConsoleOutput();
|
||||
// to configure all -v, -vv, -vvv options without memory-lock to Application run() arguments
|
||||
$this->privatesCaller->callPrivateMethod(new Application(), 'configureIO', [$argvInput, $consoleOutput]);
|
||||
$this->privatesAccessor->callPrivateMethod(new Application(), 'configureIO', [$argvInput, $consoleOutput]);
|
||||
// --debug is called
|
||||
if ($argvInput->hasParameterOption('--debug')) {
|
||||
$consoleOutput->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
|
||||
|
|
|
@ -21,9 +21,9 @@ use PhpParser\Node\Stmt\Expression;
|
|||
use Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer;
|
||||
use Rector\Core\PhpParser\Comparing\NodeComparator;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Core\Util\MultiInstanceofChecker;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Php\TypeChecker;
|
||||
final class AssignManipulator
|
||||
{
|
||||
/**
|
||||
|
@ -52,16 +52,16 @@ final class AssignManipulator
|
|||
private $propertyFetchAnalyzer;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\PackageBuilder\Php\TypeChecker
|
||||
* @var \Rector\Core\Util\MultiInstanceofChecker
|
||||
*/
|
||||
private $typeChecker;
|
||||
public function __construct(NodeNameResolver $nodeNameResolver, NodeComparator $nodeComparator, BetterNodeFinder $betterNodeFinder, PropertyFetchAnalyzer $propertyFetchAnalyzer, TypeChecker $typeChecker)
|
||||
private $multiInstanceofChecker;
|
||||
public function __construct(NodeNameResolver $nodeNameResolver, NodeComparator $nodeComparator, BetterNodeFinder $betterNodeFinder, PropertyFetchAnalyzer $propertyFetchAnalyzer, MultiInstanceofChecker $multiInstanceofChecker)
|
||||
{
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->nodeComparator = $nodeComparator;
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
$this->propertyFetchAnalyzer = $propertyFetchAnalyzer;
|
||||
$this->typeChecker = $typeChecker;
|
||||
$this->multiInstanceofChecker = $multiInstanceofChecker;
|
||||
}
|
||||
/**
|
||||
* Matches:
|
||||
|
@ -83,7 +83,7 @@ final class AssignManipulator
|
|||
if ($parentNode instanceof Assign && $this->nodeComparator->areNodesEqual($parentNode->var, $node)) {
|
||||
return \true;
|
||||
}
|
||||
if ($parentNode !== null && $this->typeChecker->isInstanceOf($parentNode, self::MODIFYING_NODE_TYPES)) {
|
||||
if ($parentNode !== null && $this->multiInstanceofChecker->isInstanceOf($parentNode, self::MODIFYING_NODE_TYPES)) {
|
||||
return \true;
|
||||
}
|
||||
// traverse up to array dim fetches
|
||||
|
|
|
@ -27,7 +27,6 @@ use PhpParser\Node\Stmt\Unset_;
|
|||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer;
|
||||
|
@ -35,6 +34,7 @@ use Rector\Core\PhpParser\AstResolver;
|
|||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Core\PhpParser\NodeFinder\PropertyFetchFinder;
|
||||
use Rector\Core\Reflection\ReflectionResolver;
|
||||
use Rector\Core\Util\MultiInstanceofChecker;
|
||||
use Rector\Core\ValueObject\MethodName;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
|
@ -45,7 +45,6 @@ use Rector\Php80\NodeAnalyzer\PromotedPropertyResolver;
|
|||
use Rector\ReadWrite\Guard\VariableToConstantGuard;
|
||||
use Rector\ReadWrite\NodeAnalyzer\ReadWritePropertyAnalyzer;
|
||||
use Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Php\TypeChecker;
|
||||
/**
|
||||
* For inspiration to improve this service,
|
||||
* @see examples of variable modifications in https://wiki.php.net/rfc/readonly_properties_v2#proposal
|
||||
|
@ -85,11 +84,6 @@ final class PropertyManipulator
|
|||
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
|
||||
*/
|
||||
private $phpDocInfoFactory;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\PackageBuilder\Php\TypeChecker
|
||||
*/
|
||||
private $typeChecker;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\NodeFinder\PropertyFetchFinder
|
||||
|
@ -135,14 +129,18 @@ final class PropertyManipulator
|
|||
* @var \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer
|
||||
*/
|
||||
private $propertyFetchAnalyzer;
|
||||
public function __construct(\Rector\Core\NodeManipulator\AssignManipulator $assignManipulator, BetterNodeFinder $betterNodeFinder, VariableToConstantGuard $variableToConstantGuard, ReadWritePropertyAnalyzer $readWritePropertyAnalyzer, PhpDocInfoFactory $phpDocInfoFactory, TypeChecker $typeChecker, PropertyFetchFinder $propertyFetchFinder, ReflectionResolver $reflectionResolver, NodeNameResolver $nodeNameResolver, PhpAttributeAnalyzer $phpAttributeAnalyzer, NodeTypeResolver $nodeTypeResolver, PromotedPropertyResolver $promotedPropertyResolver, ConstructorAssignDetector $constructorAssignDetector, AstResolver $astResolver, PropertyFetchAnalyzer $propertyFetchAnalyzer)
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\Util\MultiInstanceofChecker
|
||||
*/
|
||||
private $multiInstanceofChecker;
|
||||
public function __construct(\Rector\Core\NodeManipulator\AssignManipulator $assignManipulator, BetterNodeFinder $betterNodeFinder, VariableToConstantGuard $variableToConstantGuard, ReadWritePropertyAnalyzer $readWritePropertyAnalyzer, PhpDocInfoFactory $phpDocInfoFactory, PropertyFetchFinder $propertyFetchFinder, ReflectionResolver $reflectionResolver, NodeNameResolver $nodeNameResolver, PhpAttributeAnalyzer $phpAttributeAnalyzer, NodeTypeResolver $nodeTypeResolver, PromotedPropertyResolver $promotedPropertyResolver, ConstructorAssignDetector $constructorAssignDetector, AstResolver $astResolver, PropertyFetchAnalyzer $propertyFetchAnalyzer, MultiInstanceofChecker $multiInstanceofChecker)
|
||||
{
|
||||
$this->assignManipulator = $assignManipulator;
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
$this->variableToConstantGuard = $variableToConstantGuard;
|
||||
$this->readWritePropertyAnalyzer = $readWritePropertyAnalyzer;
|
||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||
$this->typeChecker = $typeChecker;
|
||||
$this->propertyFetchFinder = $propertyFetchFinder;
|
||||
$this->reflectionResolver = $reflectionResolver;
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
|
@ -152,6 +150,7 @@ final class PropertyManipulator
|
|||
$this->constructorAssignDetector = $constructorAssignDetector;
|
||||
$this->astResolver = $astResolver;
|
||||
$this->propertyFetchAnalyzer = $propertyFetchAnalyzer;
|
||||
$this->multiInstanceofChecker = $multiInstanceofChecker;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $propertyOrPromotedParam
|
||||
|
@ -296,7 +295,7 @@ final class PropertyManipulator
|
|||
if (!$parentNode instanceof Node) {
|
||||
return \false;
|
||||
}
|
||||
if ($this->typeChecker->isInstanceOf($parentNode, [PreInc::class, PreDec::class, PostInc::class, PostDec::class])) {
|
||||
if ($this->multiInstanceofChecker->isInstanceOf($parentNode, [PreInc::class, PreDec::class, PostInc::class, PostDec::class])) {
|
||||
$parentNode = $parentNode->getAttribute(AttributeKey::PARENT_NODE);
|
||||
}
|
||||
if (!$parentNode instanceof Node) {
|
||||
|
|
|
@ -23,9 +23,9 @@ use PhpParser\Node\Stmt\Return_;
|
|||
use PhpParser\NodeFinder;
|
||||
use Rector\Core\NodeAnalyzer\ClassAnalyzer;
|
||||
use Rector\Core\PhpParser\Comparing\NodeComparator;
|
||||
use Rector\Core\Util\MultiInstanceofChecker;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Php\TypeChecker;
|
||||
use RectorPrefix202209\Webmozart\Assert\Assert;
|
||||
/**
|
||||
* @see \Rector\Core\Tests\PhpParser\Node\BetterNodeFinder\BetterNodeFinderTest
|
||||
|
@ -42,11 +42,6 @@ final class BetterNodeFinder
|
|||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\PackageBuilder\Php\TypeChecker
|
||||
*/
|
||||
private $typeChecker;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Comparing\NodeComparator
|
||||
|
@ -57,13 +52,18 @@ final class BetterNodeFinder
|
|||
* @var \Rector\Core\NodeAnalyzer\ClassAnalyzer
|
||||
*/
|
||||
private $classAnalyzer;
|
||||
public function __construct(NodeFinder $nodeFinder, NodeNameResolver $nodeNameResolver, TypeChecker $typeChecker, NodeComparator $nodeComparator, ClassAnalyzer $classAnalyzer)
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\Util\MultiInstanceofChecker
|
||||
*/
|
||||
private $multiInstanceofChecker;
|
||||
public function __construct(NodeFinder $nodeFinder, NodeNameResolver $nodeNameResolver, NodeComparator $nodeComparator, ClassAnalyzer $classAnalyzer, MultiInstanceofChecker $multiInstanceofChecker)
|
||||
{
|
||||
$this->nodeFinder = $nodeFinder;
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->typeChecker = $typeChecker;
|
||||
$this->nodeComparator = $nodeComparator;
|
||||
$this->classAnalyzer = $classAnalyzer;
|
||||
$this->multiInstanceofChecker = $multiInstanceofChecker;
|
||||
}
|
||||
/**
|
||||
* @template TNode of \PhpParser\Node
|
||||
|
@ -294,7 +294,7 @@ final class BetterNodeFinder
|
|||
public function findFirstPreviousOfTypes(Node $mainNode, array $types) : ?Node
|
||||
{
|
||||
return $this->findFirstPrevious($mainNode, function (Node $node) use($types) : bool {
|
||||
return $this->typeChecker->isInstanceOf($node, $types);
|
||||
return $this->multiInstanceofChecker->isInstanceOf($node, $types);
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\Util;
|
||||
|
||||
final class MultiInstanceofChecker
|
||||
{
|
||||
/**
|
||||
* @param array<class-string> $types
|
||||
* @param object|string $object
|
||||
*/
|
||||
public function isInstanceOf($object, array $types) : bool
|
||||
{
|
||||
foreach ($types as $type) {
|
||||
if (\is_a($object, $type, \true)) {
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\Util\Reflection;
|
||||
|
||||
use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
use ReflectionProperty;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Exception\InvalidPrivatePropertyTypeException;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Exception\MissingPrivatePropertyException;
|
||||
/**
|
||||
* @see \Rector\Core\Tests\Util\Reflection\PrivatesAccessorTest
|
||||
*/
|
||||
final class PrivatesAccessor
|
||||
{
|
||||
/**
|
||||
* @param object|class-string $object
|
||||
* @param mixed[] $arguments
|
||||
* @api
|
||||
* @return mixed
|
||||
*/
|
||||
public function callPrivateMethod($object, string $methodName, array $arguments)
|
||||
{
|
||||
if (\is_string($object)) {
|
||||
$reflectionClass = new ReflectionClass($object);
|
||||
$object = $reflectionClass->newInstanceWithoutConstructor();
|
||||
}
|
||||
$methodReflection = $this->createAccessibleMethodReflection($object, $methodName);
|
||||
return $methodReflection->invokeArgs($object, $arguments);
|
||||
}
|
||||
/**
|
||||
* @param object|class-string $object
|
||||
* @param mixed $argument
|
||||
* @return mixed
|
||||
*/
|
||||
public function callPrivateMethodWithReference($object, string $methodName, $argument)
|
||||
{
|
||||
if (\is_string($object)) {
|
||||
$reflectionClass = new ReflectionClass($object);
|
||||
$object = $reflectionClass->newInstanceWithoutConstructor();
|
||||
}
|
||||
$methodReflection = $this->createAccessibleMethodReflection($object, $methodName);
|
||||
$methodReflection->invokeArgs($object, [&$argument]);
|
||||
return $argument;
|
||||
}
|
||||
/**
|
||||
* @template T of object
|
||||
*
|
||||
* @param class-string<T> $valueClassName
|
||||
* @return T
|
||||
*/
|
||||
public function getPrivatePropertyOfClass(object $object, string $propertyName, string $valueClassName) : object
|
||||
{
|
||||
$value = $this->getPrivateProperty($object, $propertyName);
|
||||
if ($value instanceof $valueClassName) {
|
||||
return $value;
|
||||
}
|
||||
$errorMessage = \sprintf('The type "%s" is required, but "%s" type given', $valueClassName, \get_class($value));
|
||||
throw new InvalidPrivatePropertyTypeException($errorMessage);
|
||||
}
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPrivateProperty(object $object, string $propertyName)
|
||||
{
|
||||
$propertyReflection = $this->resolvePropertyReflection($object, $propertyName);
|
||||
$propertyReflection->setAccessible(\true);
|
||||
return $propertyReflection->getValue($object);
|
||||
}
|
||||
/**
|
||||
* @template T of object
|
||||
*
|
||||
* @param class-string<T> $valueClassName
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setPrivatePropertyOfClass(object $object, string $propertyName, $value, string $valueClassName) : void
|
||||
{
|
||||
if ($value instanceof $valueClassName) {
|
||||
$this->setPrivateProperty($object, $propertyName, $value);
|
||||
return;
|
||||
}
|
||||
$errorMessage = \sprintf('The type "%s" is required, but "%s" type given', $valueClassName, \get_class($value));
|
||||
throw new InvalidPrivatePropertyTypeException($errorMessage);
|
||||
}
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setPrivateProperty(object $object, string $propertyName, $value) : void
|
||||
{
|
||||
$propertyReflection = $this->resolvePropertyReflection($object, $propertyName);
|
||||
$propertyReflection->setAccessible(\true);
|
||||
$propertyReflection->setValue($object, $value);
|
||||
}
|
||||
private function createAccessibleMethodReflection(object $object, string $methodName) : ReflectionMethod
|
||||
{
|
||||
$reflectionMethod = new ReflectionMethod(\get_class($object), $methodName);
|
||||
$reflectionMethod->setAccessible(\true);
|
||||
return $reflectionMethod;
|
||||
}
|
||||
private function resolvePropertyReflection(object $object, string $propertyName) : ReflectionProperty
|
||||
{
|
||||
if (\property_exists($object, $propertyName)) {
|
||||
return new ReflectionProperty($object, $propertyName);
|
||||
}
|
||||
$parentClass = \get_parent_class($object);
|
||||
if ($parentClass !== \false) {
|
||||
return new ReflectionProperty($parentClass, $propertyName);
|
||||
}
|
||||
$errorMessage = \sprintf('Property "$%s" was not found in "%s" class', $propertyName, \get_class($object));
|
||||
throw new MissingPrivatePropertyException($errorMessage);
|
||||
}
|
||||
}
|
|
@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit49c7847968b4d07e4659a00d91db5255::getLoader();
|
||||
return ComposerAutoloaderInitb981bffc907afb7807601aec8347a8ad::getLoader();
|
||||
|
|
|
@ -1063,26 +1063,6 @@ return array(
|
|||
'RectorPrefix202209\\Symplify\\PackageBuilder\\ValueObject\\MethodName' => $vendorDir . '/symplify/package-builder/src/ValueObject/MethodName.php',
|
||||
'RectorPrefix202209\\Symplify\\PackageBuilder\\ValueObject\\Option' => $vendorDir . '/symplify/package-builder/src/ValueObject/Option.php',
|
||||
'RectorPrefix202209\\Symplify\\PackageBuilder\\Yaml\\ParametersMerger' => $vendorDir . '/symplify/package-builder/src/Yaml/ParametersMerger.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\Exception\\DirectoryNotFoundException' => $vendorDir . '/symplify/smart-file-system/src/Exception/DirectoryNotFoundException.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\Exception\\FileNotFoundException' => $vendorDir . '/symplify/smart-file-system/src/Exception/FileNotFoundException.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\FileSystemFilter' => $vendorDir . '/symplify/smart-file-system/src/FileSystemFilter.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\FileSystemGuard' => $vendorDir . '/symplify/smart-file-system/src/FileSystemGuard.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\Finder\\FinderSanitizer' => $vendorDir . '/symplify/smart-file-system/src/Finder/FinderSanitizer.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\Finder\\SmartFinder' => $vendorDir . '/symplify/smart-file-system/src/Finder/SmartFinder.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\Json\\JsonFileSystem' => $vendorDir . '/symplify/smart-file-system/src/Json/JsonFileSystem.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\Normalizer\\PathNormalizer' => $vendorDir . '/symplify/smart-file-system/src/Normalizer/PathNormalizer.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\SmartFileInfo' => $vendorDir . '/symplify/smart-file-system/src/SmartFileInfo.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\SmartFileSystem' => $vendorDir . '/symplify/smart-file-system/src/SmartFileSystem.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\Config\\Loader\\ParameterMergingLoaderFactory' => $vendorDir . '/symplify/symplify-kernel/src/Config/Loader/ParameterMergingLoaderFactory.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\ContainerBuilderFactory' => $vendorDir . '/symplify/symplify-kernel/src/ContainerBuilderFactory.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\Contract\\Config\\LoaderFactoryInterface' => $vendorDir . '/symplify/symplify-kernel/src/Contract/Config/LoaderFactoryInterface.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\Contract\\LightKernelInterface' => $vendorDir . '/symplify/symplify-kernel/src/Contract/LightKernelInterface.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\DependencyInjection\\LoadExtensionConfigsCompilerPass' => $vendorDir . '/symplify/symplify-kernel/src/DependencyInjection/LoadExtensionConfigsCompilerPass.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\Exception\\BootException' => $vendorDir . '/symplify/symplify-kernel/src/Exception/BootException.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\Exception\\ShouldNotHappenException' => $vendorDir . '/symplify/symplify-kernel/src/Exception/ShouldNotHappenException.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\HttpKernel\\AbstractSymplifyKernel' => $vendorDir . '/symplify/symplify-kernel/src/HttpKernel/AbstractSymplifyKernel.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\ValueObject\\KernelBootAndApplicationRun' => $vendorDir . '/symplify/symplify-kernel/src/ValueObject/KernelBootAndApplicationRun.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\ValueObject\\SymplifyKernelConfig' => $vendorDir . '/symplify/symplify-kernel/src/ValueObject/SymplifyKernelConfig.php',
|
||||
'RectorPrefix202209\\Webmozart\\Assert\\Assert' => $vendorDir . '/webmozart/assert/src/Assert.php',
|
||||
'RectorPrefix202209\\Webmozart\\Assert\\InvalidArgumentException' => $vendorDir . '/webmozart/assert/src/InvalidArgumentException.php',
|
||||
'RectorPrefix202209\\Webmozart\\Assert\\Mixin' => $vendorDir . '/webmozart/assert/src/Mixin.php',
|
||||
|
@ -1502,7 +1482,9 @@ return array(
|
|||
'Rector\\Core\\StaticReflection\\SourceLocator\\ParentAttributeSourceLocator' => $baseDir . '/src/StaticReflection/SourceLocator/ParentAttributeSourceLocator.php',
|
||||
'Rector\\Core\\StaticReflection\\SourceLocator\\RenamedClassesSourceLocator' => $baseDir . '/src/StaticReflection/SourceLocator/RenamedClassesSourceLocator.php',
|
||||
'Rector\\Core\\Util\\MemoryLimiter' => $baseDir . '/src/Util/MemoryLimiter.php',
|
||||
'Rector\\Core\\Util\\MultiInstanceofChecker' => $baseDir . '/src/Util/MultiInstanceofChecker.php',
|
||||
'Rector\\Core\\Util\\PhpVersionFactory' => $baseDir . '/src/Util/PhpVersionFactory.php',
|
||||
'Rector\\Core\\Util\\Reflection\\PrivatesAccessor' => $baseDir . '/src/Util/Reflection/PrivatesAccessor.php',
|
||||
'Rector\\Core\\Util\\StringUtils' => $baseDir . '/src/Util/StringUtils.php',
|
||||
'Rector\\Core\\Validation\\Collector\\EmptyConfigurableRectorCollector' => $baseDir . '/src/Validation/Collector/EmptyConfigurableRectorCollector.php',
|
||||
'Rector\\Core\\Validation\\EmptyConfigurableRectorChecker' => $baseDir . '/src/Validation/EmptyConfigurableRectorChecker.php',
|
||||
|
@ -2039,6 +2021,7 @@ return array(
|
|||
'Rector\\PHPStanStaticTypeMapper\\TypeAnalyzer\\UnionTypeAnalyzer' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeAnalyzer/UnionTypeAnalyzer.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeAnalyzer\\UnionTypeCommonTypeNarrower' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeAnalyzer/UnionTypeCommonTypeNarrower.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\AccessoryNonEmptyStringTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/AccessoryNonEmptyStringTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\AccessoryNonFalsyStringTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/AccessoryNonFalsyStringTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\AccessoryNumericStringTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/AccessoryNumericStringTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\ArrayShapeTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/ArrayShapeTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\ArrayTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapper.php',
|
||||
|
@ -2049,6 +2032,7 @@ return array(
|
|||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\FloatTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/FloatTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\HasMethodTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/HasMethodTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\HasOffsetTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/HasOffsetTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\HasOffsetValueTypeTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/HasOffsetValueTypeTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\HasPropertyTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/HasPropertyTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\IntegerTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/IntegerTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\IntersectionTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/IntersectionTypeMapper.php',
|
||||
|
|
|
@ -20,8 +20,6 @@ return array(
|
|||
'Rector\\CakePHP\\' => array($vendorDir . '/rector/rector-cakephp/src'),
|
||||
'Rector\\' => array($baseDir . '/packages', $baseDir . '/rules', $vendorDir . '/rector/rector-downgrade-php/src', $vendorDir . '/rector/rector-downgrade-php/rules'),
|
||||
'RectorPrefix202209\\Webmozart\\Assert\\' => array($vendorDir . '/webmozart/assert/src'),
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\' => array($vendorDir . '/symplify/symplify-kernel/src'),
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\' => array($vendorDir . '/symplify/smart-file-system/src'),
|
||||
'RectorPrefix202209\\Symplify\\PackageBuilder\\' => array($vendorDir . '/symplify/package-builder/src'),
|
||||
'RectorPrefix202209\\Symplify\\EasyParallel\\' => array($vendorDir . '/symplify/easy-parallel/src'),
|
||||
'RectorPrefix202209\\Symplify\\AutowireArrayParameter\\' => array($vendorDir . '/symplify/autowire-array-parameter/src'),
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit49c7847968b4d07e4659a00d91db5255
|
||||
class ComposerAutoloaderInitb981bffc907afb7807601aec8347a8ad
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,19 +22,19 @@ class ComposerAutoloaderInit49c7847968b4d07e4659a00d91db5255
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit49c7847968b4d07e4659a00d91db5255', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitb981bffc907afb7807601aec8347a8ad', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit49c7847968b4d07e4659a00d91db5255', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitb981bffc907afb7807601aec8347a8ad', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit49c7847968b4d07e4659a00d91db5255::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitb981bffc907afb7807601aec8347a8ad::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit49c7847968b4d07e4659a00d91db5255::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInitb981bffc907afb7807601aec8347a8ad::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire49c7847968b4d07e4659a00d91db5255($fileIdentifier, $file);
|
||||
composerRequireb981bffc907afb7807601aec8347a8ad($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
@ -46,7 +46,7 @@ class ComposerAutoloaderInit49c7847968b4d07e4659a00d91db5255
|
|||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire49c7847968b4d07e4659a00d91db5255($fileIdentifier, $file)
|
||||
function composerRequireb981bffc907afb7807601aec8347a8ad($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit49c7847968b4d07e4659a00d91db5255
|
||||
class ComposerStaticInitb981bffc907afb7807601aec8347a8ad
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
|
@ -37,8 +37,6 @@ class ComposerStaticInit49c7847968b4d07e4659a00d91db5255
|
|||
'Rector\\CakePHP\\' => 15,
|
||||
'Rector\\' => 7,
|
||||
'RectorPrefix202209\\Webmozart\\Assert\\' => 36,
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\' => 43,
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\' => 44,
|
||||
'RectorPrefix202209\\Symplify\\PackageBuilder\\' => 43,
|
||||
'RectorPrefix202209\\Symplify\\EasyParallel\\' => 41,
|
||||
'RectorPrefix202209\\Symplify\\AutowireArrayParameter\\' => 51,
|
||||
|
@ -137,14 +135,6 @@ class ComposerStaticInit49c7847968b4d07e4659a00d91db5255
|
|||
array (
|
||||
0 => __DIR__ . '/..' . '/webmozart/assert/src',
|
||||
),
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symplify/symplify-kernel/src',
|
||||
),
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symplify/smart-file-system/src',
|
||||
),
|
||||
'RectorPrefix202209\\Symplify\\PackageBuilder\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symplify/package-builder/src',
|
||||
|
@ -1333,26 +1323,6 @@ class ComposerStaticInit49c7847968b4d07e4659a00d91db5255
|
|||
'RectorPrefix202209\\Symplify\\PackageBuilder\\ValueObject\\MethodName' => __DIR__ . '/..' . '/symplify/package-builder/src/ValueObject/MethodName.php',
|
||||
'RectorPrefix202209\\Symplify\\PackageBuilder\\ValueObject\\Option' => __DIR__ . '/..' . '/symplify/package-builder/src/ValueObject/Option.php',
|
||||
'RectorPrefix202209\\Symplify\\PackageBuilder\\Yaml\\ParametersMerger' => __DIR__ . '/..' . '/symplify/package-builder/src/Yaml/ParametersMerger.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\Exception\\DirectoryNotFoundException' => __DIR__ . '/..' . '/symplify/smart-file-system/src/Exception/DirectoryNotFoundException.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\Exception\\FileNotFoundException' => __DIR__ . '/..' . '/symplify/smart-file-system/src/Exception/FileNotFoundException.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\FileSystemFilter' => __DIR__ . '/..' . '/symplify/smart-file-system/src/FileSystemFilter.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\FileSystemGuard' => __DIR__ . '/..' . '/symplify/smart-file-system/src/FileSystemGuard.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\Finder\\FinderSanitizer' => __DIR__ . '/..' . '/symplify/smart-file-system/src/Finder/FinderSanitizer.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\Finder\\SmartFinder' => __DIR__ . '/..' . '/symplify/smart-file-system/src/Finder/SmartFinder.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\Json\\JsonFileSystem' => __DIR__ . '/..' . '/symplify/smart-file-system/src/Json/JsonFileSystem.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\Normalizer\\PathNormalizer' => __DIR__ . '/..' . '/symplify/smart-file-system/src/Normalizer/PathNormalizer.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\SmartFileInfo' => __DIR__ . '/..' . '/symplify/smart-file-system/src/SmartFileInfo.php',
|
||||
'RectorPrefix202209\\Symplify\\SmartFileSystem\\SmartFileSystem' => __DIR__ . '/..' . '/symplify/smart-file-system/src/SmartFileSystem.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\Config\\Loader\\ParameterMergingLoaderFactory' => __DIR__ . '/..' . '/symplify/symplify-kernel/src/Config/Loader/ParameterMergingLoaderFactory.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\ContainerBuilderFactory' => __DIR__ . '/..' . '/symplify/symplify-kernel/src/ContainerBuilderFactory.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\Contract\\Config\\LoaderFactoryInterface' => __DIR__ . '/..' . '/symplify/symplify-kernel/src/Contract/Config/LoaderFactoryInterface.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\Contract\\LightKernelInterface' => __DIR__ . '/..' . '/symplify/symplify-kernel/src/Contract/LightKernelInterface.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\DependencyInjection\\LoadExtensionConfigsCompilerPass' => __DIR__ . '/..' . '/symplify/symplify-kernel/src/DependencyInjection/LoadExtensionConfigsCompilerPass.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\Exception\\BootException' => __DIR__ . '/..' . '/symplify/symplify-kernel/src/Exception/BootException.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\Exception\\ShouldNotHappenException' => __DIR__ . '/..' . '/symplify/symplify-kernel/src/Exception/ShouldNotHappenException.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\HttpKernel\\AbstractSymplifyKernel' => __DIR__ . '/..' . '/symplify/symplify-kernel/src/HttpKernel/AbstractSymplifyKernel.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\ValueObject\\KernelBootAndApplicationRun' => __DIR__ . '/..' . '/symplify/symplify-kernel/src/ValueObject/KernelBootAndApplicationRun.php',
|
||||
'RectorPrefix202209\\Symplify\\SymplifyKernel\\ValueObject\\SymplifyKernelConfig' => __DIR__ . '/..' . '/symplify/symplify-kernel/src/ValueObject/SymplifyKernelConfig.php',
|
||||
'RectorPrefix202209\\Webmozart\\Assert\\Assert' => __DIR__ . '/..' . '/webmozart/assert/src/Assert.php',
|
||||
'RectorPrefix202209\\Webmozart\\Assert\\InvalidArgumentException' => __DIR__ . '/..' . '/webmozart/assert/src/InvalidArgumentException.php',
|
||||
'RectorPrefix202209\\Webmozart\\Assert\\Mixin' => __DIR__ . '/..' . '/webmozart/assert/src/Mixin.php',
|
||||
|
@ -1772,7 +1742,9 @@ class ComposerStaticInit49c7847968b4d07e4659a00d91db5255
|
|||
'Rector\\Core\\StaticReflection\\SourceLocator\\ParentAttributeSourceLocator' => __DIR__ . '/../..' . '/src/StaticReflection/SourceLocator/ParentAttributeSourceLocator.php',
|
||||
'Rector\\Core\\StaticReflection\\SourceLocator\\RenamedClassesSourceLocator' => __DIR__ . '/../..' . '/src/StaticReflection/SourceLocator/RenamedClassesSourceLocator.php',
|
||||
'Rector\\Core\\Util\\MemoryLimiter' => __DIR__ . '/../..' . '/src/Util/MemoryLimiter.php',
|
||||
'Rector\\Core\\Util\\MultiInstanceofChecker' => __DIR__ . '/../..' . '/src/Util/MultiInstanceofChecker.php',
|
||||
'Rector\\Core\\Util\\PhpVersionFactory' => __DIR__ . '/../..' . '/src/Util/PhpVersionFactory.php',
|
||||
'Rector\\Core\\Util\\Reflection\\PrivatesAccessor' => __DIR__ . '/../..' . '/src/Util/Reflection/PrivatesAccessor.php',
|
||||
'Rector\\Core\\Util\\StringUtils' => __DIR__ . '/../..' . '/src/Util/StringUtils.php',
|
||||
'Rector\\Core\\Validation\\Collector\\EmptyConfigurableRectorCollector' => __DIR__ . '/../..' . '/src/Validation/Collector/EmptyConfigurableRectorCollector.php',
|
||||
'Rector\\Core\\Validation\\EmptyConfigurableRectorChecker' => __DIR__ . '/../..' . '/src/Validation/EmptyConfigurableRectorChecker.php',
|
||||
|
@ -2309,6 +2281,7 @@ class ComposerStaticInit49c7847968b4d07e4659a00d91db5255
|
|||
'Rector\\PHPStanStaticTypeMapper\\TypeAnalyzer\\UnionTypeAnalyzer' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeAnalyzer/UnionTypeAnalyzer.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeAnalyzer\\UnionTypeCommonTypeNarrower' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeAnalyzer/UnionTypeCommonTypeNarrower.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\AccessoryNonEmptyStringTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/AccessoryNonEmptyStringTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\AccessoryNonFalsyStringTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/AccessoryNonFalsyStringTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\AccessoryNumericStringTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/AccessoryNumericStringTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\ArrayShapeTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/ArrayShapeTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\ArrayTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapper.php',
|
||||
|
@ -2319,6 +2292,7 @@ class ComposerStaticInit49c7847968b4d07e4659a00d91db5255
|
|||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\FloatTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/FloatTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\HasMethodTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/HasMethodTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\HasOffsetTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/HasOffsetTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\HasOffsetValueTypeTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/HasOffsetValueTypeTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\HasPropertyTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/HasPropertyTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\IntegerTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/IntegerTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\IntersectionTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/IntersectionTypeMapper.php',
|
||||
|
@ -3139,9 +3113,9 @@ class ComposerStaticInit49c7847968b4d07e4659a00d91db5255
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit49c7847968b4d07e4659a00d91db5255::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit49c7847968b4d07e4659a00d91db5255::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit49c7847968b4d07e4659a00d91db5255::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitb981bffc907afb7807601aec8347a8ad::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitb981bffc907afb7807601aec8347a8ad::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitb981bffc907afb7807601aec8347a8ad::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
|
@ -733,17 +733,17 @@
|
|||
},
|
||||
{
|
||||
"name": "phpstan\/phpstan",
|
||||
"version": "1.8.2",
|
||||
"version_normalized": "1.8.2.0",
|
||||
"version": "1.8.3",
|
||||
"version_normalized": "1.8.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/phpstan\/phpstan.git",
|
||||
"reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c"
|
||||
"reference": "5583623b61caafebd62bc78a99533aa9d769d097"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpstan\/zipball\/c53312ecc575caf07b0e90dee43883fdf90ca67c",
|
||||
"reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c",
|
||||
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpstan\/zipball\/5583623b61caafebd62bc78a99533aa9d769d097",
|
||||
"reference": "5583623b61caafebd62bc78a99533aa9d769d097",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -752,7 +752,7 @@
|
|||
"conflict": {
|
||||
"phpstan\/phpstan-shim": "*"
|
||||
},
|
||||
"time": "2022-07-20T09:57:31+00:00",
|
||||
"time": "2022-09-01T15:27:34+00:00",
|
||||
"bin": [
|
||||
"phpstan",
|
||||
"phpstan.phar"
|
||||
|
@ -769,9 +769,13 @@
|
|||
"MIT"
|
||||
],
|
||||
"description": "PHPStan - PHP Static Analysis Tool",
|
||||
"keywords": [
|
||||
"dev",
|
||||
"static analysis"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https:\/\/github.com\/phpstan\/phpstan\/issues",
|
||||
"source": "https:\/\/github.com\/phpstan\/phpstan\/tree\/1.8.2"
|
||||
"source": "https:\/\/github.com\/phpstan\/phpstan\/tree\/1.8.3"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -782,10 +786,6 @@
|
|||
"url": "https:\/\/github.com\/phpstan",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https:\/\/www.patreon.com\/phpstan",
|
||||
"type": "patreon"
|
||||
},
|
||||
{
|
||||
"url": "https:\/\/tidelift.com\/funding\/github\/packagist\/phpstan\/phpstan",
|
||||
"type": "tidelift"
|
||||
|
@ -1922,12 +1922,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
|
||||
"reference": "e91434a1c47d80b5f157188f841768c4c22da112"
|
||||
"reference": "f2439d57667adba44960e0d5d7afcff6dd6ad221"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/e91434a1c47d80b5f157188f841768c4c22da112",
|
||||
"reference": "e91434a1c47d80b5f157188f841768c4c22da112",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/f2439d57667adba44960e0d5d7afcff6dd6ad221",
|
||||
"reference": "f2439d57667adba44960e0d5d7afcff6dd6ad221",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1944,7 +1944,7 @@
|
|||
"phpunit\/phpunit": "^9.5",
|
||||
"rector\/phpstan-rules": "^0.6",
|
||||
"rector\/rector-debugging": "dev-main",
|
||||
"rector\/rector-src": "dev-main",
|
||||
"rector\/rector-src": "dev-main#7ad13da",
|
||||
"symplify\/easy-ci": "^11.1",
|
||||
"symplify\/easy-coding-standard": "^11.1",
|
||||
"symplify\/phpstan-extensions": "^11.1",
|
||||
|
@ -1952,7 +1952,7 @@
|
|||
"symplify\/rule-doc-generator": "^11.1",
|
||||
"symplify\/vendor-patches": "^11.1"
|
||||
},
|
||||
"time": "2022-09-01T09:35:16+00:00",
|
||||
"time": "2022-09-01T15:54:46+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
@ -1993,12 +1993,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-laravel.git",
|
||||
"reference": "435188d2295e32a8d3fb0352c522e362ed503bdf"
|
||||
"reference": "b5d0ad891f5df71df0bb52ea5b8455007de67239"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-laravel\/zipball\/435188d2295e32a8d3fb0352c522e362ed503bdf",
|
||||
"reference": "435188d2295e32a8d3fb0352c522e362ed503bdf",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-laravel\/zipball\/b5d0ad891f5df71df0bb52ea5b8455007de67239",
|
||||
"reference": "b5d0ad891f5df71df0bb52ea5b8455007de67239",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2015,7 +2015,7 @@
|
|||
"phpunit\/phpunit": "^9.5",
|
||||
"rector\/phpstan-rules": "^0.6",
|
||||
"rector\/rector-debugging": "dev-main",
|
||||
"rector\/rector-src": "dev-main",
|
||||
"rector\/rector-src": "dev-main#7ad13da",
|
||||
"symplify\/easy-coding-standard": "^11.0",
|
||||
"symplify\/monorepo-builder": "^11.0",
|
||||
"symplify\/phpstan-extensions": "^11.0",
|
||||
|
@ -2023,7 +2023,7 @@
|
|||
"symplify\/rule-doc-generator": "^11.0",
|
||||
"symplify\/vendor-patches": "^11.0"
|
||||
},
|
||||
"time": "2022-09-01T09:34:06+00:00",
|
||||
"time": "2022-09-01T15:53:21+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
@ -2197,12 +2197,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
|
||||
"reference": "3aaa1edf5b7ba887fa9a8d306d9d4aaa15918a30"
|
||||
"reference": "1a89172121f2a6a4cd010b727e6456ca49d1f8e1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/3aaa1edf5b7ba887fa9a8d306d9d4aaa15918a30",
|
||||
"reference": "3aaa1edf5b7ba887fa9a8d306d9d4aaa15918a30",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/1a89172121f2a6a4cd010b727e6456ca49d1f8e1",
|
||||
"reference": "1a89172121f2a6a4cd010b727e6456ca49d1f8e1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2222,7 +2222,7 @@
|
|||
"rector\/phpstan-rules": "^0.6",
|
||||
"rector\/rector-debugging": "dev-main",
|
||||
"rector\/rector-generator": "^0.6",
|
||||
"rector\/rector-src": "dev-main",
|
||||
"rector\/rector-src": "dev-main#7ad13da",
|
||||
"symfony\/routing": "^6.1",
|
||||
"symfony\/security-core": "^6.1",
|
||||
"symfony\/security-http": "^6.1",
|
||||
|
@ -2233,7 +2233,7 @@
|
|||
"symplify\/rule-doc-generator": "^11.1",
|
||||
"symplify\/vendor-patches": "^11.1"
|
||||
},
|
||||
"time": "2022-09-01T09:33:28+00:00",
|
||||
"time": "2022-09-01T15:56:27+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
@ -3108,24 +3108,24 @@
|
|||
},
|
||||
{
|
||||
"name": "symplify\/autowire-array-parameter",
|
||||
"version": "dev-main",
|
||||
"version_normalized": "dev-main",
|
||||
"version": "11.1.6",
|
||||
"version_normalized": "11.1.6.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/symplify\/autowire-array-parameter.git",
|
||||
"reference": "f4896e243ae465a278e254b0213fc50ef4f33b5a"
|
||||
"reference": "4bd09786fd6c8cad3fcf1824fc1f5f387d30e4b0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/symplify\/autowire-array-parameter\/zipball\/f4896e243ae465a278e254b0213fc50ef4f33b5a",
|
||||
"reference": "f4896e243ae465a278e254b0213fc50ef4f33b5a",
|
||||
"url": "https:\/\/api.github.com\/repos\/symplify\/autowire-array-parameter\/zipball\/4bd09786fd6c8cad3fcf1824fc1f5f387d30e4b0",
|
||||
"reference": "4bd09786fd6c8cad3fcf1824fc1f5f387d30e4b0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"nette\/utils": "^3.2",
|
||||
"php": ">=8.0",
|
||||
"symfony\/dependency-injection": "^6.0",
|
||||
"symplify\/package-builder": "^11.2"
|
||||
"symplify\/package-builder": "^11.1.6"
|
||||
},
|
||||
"conflict": {
|
||||
"symplify\/coding-standard": "<11.1.6",
|
||||
|
@ -3141,6 +3141,7 @@
|
|||
"symplify\/phpstan-rules": "<11.1.6",
|
||||
"symplify\/rule-doc-generator": "<11.1.6",
|
||||
"symplify\/rule-doc-generator-contracts": "<11.1.6",
|
||||
"symplify\/skipper": "<11.1.6",
|
||||
"symplify\/smart-file-system": "<11.1.6",
|
||||
"symplify\/symfony-static-dumper": "<11.1.6",
|
||||
"symplify\/symplify-kernel": "<11.1.6",
|
||||
|
@ -3149,8 +3150,7 @@
|
|||
"require-dev": {
|
||||
"phpunit\/phpunit": "^9.5.23"
|
||||
},
|
||||
"time": "2022-08-31T14:54:01+00:00",
|
||||
"default-branch": true,
|
||||
"time": "2022-08-31T08:17:59+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
|
@ -3169,7 +3169,7 @@
|
|||
],
|
||||
"description": "Autowire array parameters for your Symfony applications",
|
||||
"support": {
|
||||
"source": "https:\/\/github.com\/symplify\/autowire-array-parameter\/tree\/main"
|
||||
"source": "https:\/\/github.com\/symplify\/autowire-array-parameter\/tree\/11.1.6"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -3261,12 +3261,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/symplify\/package-builder.git",
|
||||
"reference": "63ad966820ad00573769b472ad6e0948c7fd8c78"
|
||||
"reference": "abb61fa4dc9b1d7c01df23993ecbebeafdb89592"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/symplify\/package-builder\/zipball\/63ad966820ad00573769b472ad6e0948c7fd8c78",
|
||||
"reference": "63ad966820ad00573769b472ad6e0948c7fd8c78",
|
||||
"url": "https:\/\/api.github.com\/repos\/symplify\/package-builder\/zipball\/abb61fa4dc9b1d7c01df23993ecbebeafdb89592",
|
||||
"reference": "abb61fa4dc9b1d7c01df23993ecbebeafdb89592",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3276,8 +3276,7 @@
|
|||
"symfony\/config": "^6.0",
|
||||
"symfony\/console": "^6.0",
|
||||
"symfony\/dependency-injection": "^6.0",
|
||||
"symfony\/finder": "^6.0",
|
||||
"symplify\/symplify-kernel": "^11.2"
|
||||
"symfony\/finder": "^6.0"
|
||||
},
|
||||
"conflict": {
|
||||
"symplify\/autowire-array-parameter": "<11.1.6",
|
||||
|
@ -3299,9 +3298,10 @@
|
|||
"symplify\/vendor-patches": "<11.1.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit\/phpunit": "^9.5.23"
|
||||
"phpunit\/phpunit": "^9.5.23",
|
||||
"symplify\/symplify-kernel": "^11.2"
|
||||
},
|
||||
"time": "2022-08-31T14:54:02+00:00",
|
||||
"time": "2022-09-01T15:48:20+00:00",
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"extra": {
|
||||
|
@ -3408,152 +3408,6 @@
|
|||
],
|
||||
"install-path": "..\/symplify\/rule-doc-generator-contracts"
|
||||
},
|
||||
{
|
||||
"name": "symplify\/smart-file-system",
|
||||
"version": "dev-main",
|
||||
"version_normalized": "dev-main",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/symplify\/smart-file-system.git",
|
||||
"reference": "1ca346104fae0e9a25a87af34afa8f27613bf924"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/symplify\/smart-file-system\/zipball\/1ca346104fae0e9a25a87af34afa8f27613bf924",
|
||||
"reference": "1ca346104fae0e9a25a87af34afa8f27613bf924",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"nette\/utils": "^3.2",
|
||||
"php": ">=8.0",
|
||||
"symfony\/filesystem": "^6.0",
|
||||
"symfony\/finder": "^6.0"
|
||||
},
|
||||
"conflict": {
|
||||
"symplify\/autowire-array-parameter": "<11.1.6",
|
||||
"symplify\/coding-standard": "<11.1.6",
|
||||
"symplify\/composer-json-manipulator": "<11.1.6",
|
||||
"symplify\/config-transformer": "<11.1.6",
|
||||
"symplify\/easy-ci": "<11.1.6",
|
||||
"symplify\/easy-coding-standard": "<11.1.6",
|
||||
"symplify\/easy-parallel": "<11.1.6",
|
||||
"symplify\/easy-testing": "<11.1.6",
|
||||
"symplify\/monorepo-builder": "<11.1.6",
|
||||
"symplify\/package-builder": "<11.1.6",
|
||||
"symplify\/php-config-printer": "<11.1.6",
|
||||
"symplify\/phpstan-extensions": "<11.1.6",
|
||||
"symplify\/phpstan-rules": "<11.1.6",
|
||||
"symplify\/rule-doc-generator": "<11.1.6",
|
||||
"symplify\/rule-doc-generator-contracts": "<11.1.6",
|
||||
"symplify\/symfony-static-dumper": "<11.1.6",
|
||||
"symplify\/symplify-kernel": "<11.1.6",
|
||||
"symplify\/vendor-patches": "<11.1.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"nette\/finder": "^2.5.3",
|
||||
"phpunit\/phpunit": "^9.5.23"
|
||||
},
|
||||
"time": "2022-08-31T14:54:16+00:00",
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "11.2-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"RectorPrefix202209\\Symplify\\SmartFileSystem\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Sanitized FileInfo with safe getRealPath() and other handy methods",
|
||||
"support": {
|
||||
"source": "https:\/\/github.com\/symplify\/smart-file-system\/tree\/main"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https:\/\/www.paypal.me\/rectorphp",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https:\/\/github.com\/tomasvotruba",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"install-path": "..\/symplify\/smart-file-system"
|
||||
},
|
||||
{
|
||||
"name": "symplify\/symplify-kernel",
|
||||
"version": "dev-main",
|
||||
"version_normalized": "dev-main",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/symplify\/symplify-kernel.git",
|
||||
"reference": "26b1e948bc1369859548b617640980d22ec62b20"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/symplify\/symplify-kernel\/zipball\/26b1e948bc1369859548b617640980d22ec62b20",
|
||||
"reference": "26b1e948bc1369859548b617640980d22ec62b20",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.0",
|
||||
"symfony\/console": "^6.0",
|
||||
"symfony\/dependency-injection": "^6.0",
|
||||
"symplify\/autowire-array-parameter": "^11.2",
|
||||
"symplify\/package-builder": "^11.2",
|
||||
"symplify\/smart-file-system": "^11.2",
|
||||
"webmozart\/assert": "^1.10"
|
||||
},
|
||||
"conflict": {
|
||||
"symplify\/coding-standard": "<11.1.6",
|
||||
"symplify\/config-transformer": "<11.1.6",
|
||||
"symplify\/easy-ci": "<11.1.6",
|
||||
"symplify\/easy-coding-standard": "<11.1.6",
|
||||
"symplify\/easy-parallel": "<11.1.6",
|
||||
"symplify\/easy-testing": "<11.1.6",
|
||||
"symplify\/monorepo-builder": "<11.1.6",
|
||||
"symplify\/php-config-printer": "<11.1.6",
|
||||
"symplify\/phpstan-extensions": "<11.1.6",
|
||||
"symplify\/phpstan-rules": "<11.1.6",
|
||||
"symplify\/rule-doc-generator": "<11.1.6",
|
||||
"symplify\/rule-doc-generator-contracts": "<11.1.6",
|
||||
"symplify\/symfony-static-dumper": "<11.1.6",
|
||||
"symplify\/vendor-patches": "<11.1.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit\/phpunit": "^9.5.23"
|
||||
},
|
||||
"time": "2022-08-31T14:54:06+00:00",
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "11.2-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"RectorPrefix202209\\Symplify\\SymplifyKernel\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Internal Kernel for Symplify packages",
|
||||
"support": {
|
||||
"source": "https:\/\/github.com\/symplify\/symplify-kernel\/tree\/main"
|
||||
},
|
||||
"install-path": "..\/symplify\/symplify-kernel"
|
||||
},
|
||||
{
|
||||
"name": "webmozart\/assert",
|
||||
"version": "1.11.0",
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -18,9 +18,9 @@ PHPStan focuses on finding errors in your code without actually running it. It c
|
|||
even before you write tests for the code. It moves PHP closer to compiled languages in the sense that the correctness of each line of the code
|
||||
can be checked before you run the actual line.
|
||||
|
||||
**[Read more about PHPStan in an introductory article »](https://phpstan.org/blog/find-bugs-in-your-code-without-writing-tests)**
|
||||
**[Read more about PHPStan »](https://phpstan.org/)**
|
||||
|
||||
**[Try out PHPStan on the on-line playground! »](https://phpstan.org/)**
|
||||
**[Try out PHPStan on the on-line playground! »](https://phpstan.org/try)**
|
||||
|
||||
## Sponsors
|
||||
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"keywords": [
|
||||
"dev",
|
||||
"static analysis"
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2|^8.0"
|
||||
},
|
||||
|
|
Binary file not shown.
|
@ -1,16 +1,16 @@
|
|||
-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
iQIzBAABCgAdFiEE0yaA1ZV9xxFr4pwUzxoQjQ565yAFAmLX0XwACgkQzxoQjQ56
|
||||
5yAmDw/+KPoaY+vsYXrYjbNcYmXyH+9ca8Yl1WkgqMOAAiojQBAdN+PIeXqdM4P1
|
||||
ODJq7SGPqhR5j9dK3k4wxvTkmAVlFHWCbOQS0eCueoV2s0w0Sg9xkut7zTMwwBTp
|
||||
I+0TbU9W7DdnDk6k6xoNCNhT8OYpMElmwhS9nChoY2+cwdWJNZ0Lr5JeXwvb5R7W
|
||||
YnHUqO/zTIAjwJNdKwb27J9szwL3GQ4nB9gSoKXCFQTIONszfMYNwboy3VlD8m/F
|
||||
irh9ZZeZsMlCpEO9Rsqx4QyOvbLy0D2jEOKNYzXPQea9dx9gQvDiWJrVETsQBwkc
|
||||
iWJ/HJVhs3ng7iyUfMr8VAPn7rf+3fSqYeQUs5Z5/ubqABF2ZI9/4DIPGsXtqH7q
|
||||
b5OTOvSucvRpsxudnJElKWhkCjZUyjYzBqGdZ6erCh+GTiM4uFNB/en/QObfHmP2
|
||||
z4D41Dk9peLxstqlrwoLL0sJCHR4fQZFvPKrQ6sKlTKliu1zBc0HcEqq3BFalKF+
|
||||
XO2PT1QVNXx/9IqOruKm+M5siY63VKDwE/DXJZZTUPz7GN/Cr9j5Jz3pjq8jL0CR
|
||||
e4D+sEu7xXzlJa7MFqg2odZhLTRYuM/DHZCj3cOyQGlYUQ+tZMGsAiix9JyO7XhB
|
||||
1jzEMugtAglPAsmHr0HR/+oz+YDgwQEmQA4VO4l0swCNmjzLITA=
|
||||
=LM6h
|
||||
iQIzBAABCgAdFiEE0yaA1ZV9xxFr4pwUzxoQjQ565yAFAmMQz1kACgkQzxoQjQ56
|
||||
5yC1Vg/8D2IVVjPtejDaIb19jO/g8MfwK/utEW1q12k4yKNeLRYh44gLh72s05ib
|
||||
NhlxVcWjRF3B5i/cDF6m/rIEKX8zwHiN2zi7t6GueU/h5/wU822IMTM8MoVmSN/L
|
||||
43vtIcOJIoWu5I/IMm2hu55GORNtFcDk6r7KVkq0wqa78QcykSqjWAHTEUOwLEMy
|
||||
EE/1j2cRxfD25YpR/zlQA7WidG1UD0mARn+50pGqtZMYUKy/avkZGBA2XijM4SQn
|
||||
Bqf3XORyhxNUePP1k7KdnCg2pQDmc4u3JW/cKY4IGNlLwhwpIE2iRrj1K7uz+d7l
|
||||
71lM2fBNBNP+f21flGiYW3L+TYbaObi98qOtmAs/7OYM5lMDG1rEBCiVIkYaYjSv
|
||||
9offoxUAVOgsKQO/Lhn4dDvImeXibkX0c0jWzYnoO9hxMMJABEovmHAWTeSVzkZF
|
||||
kXQoSLQokn9MdyFtiAgNjLhkpAUyqxMkp6jsdyzsS2D7ALssVt3Ym3VWHMibqMNJ
|
||||
nzDfjrcr75lc8+vNQEEbeSnH81yPMQ3J+3UJL4rrXDsbID7croqnZ5QaRdRqWBYZ
|
||||
DmWhEg6hwUjHgzyQSMFgvH49uI0ufWBOKNYZfCkGHEK+DmJbcfd0+m78d3PaUGYa
|
||||
nysLQYtS1hlQVLBYaZuvRfGtd0HgO9V8c5uvjZKuJ5WQSuAazNA=
|
||||
=3o8/
|
||||
-----END PGP SIGNATURE-----
|
||||
|
|
|
@ -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 bfaf952'), '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 3ef7085'), '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 e91434a'), '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 435188d'), '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 e5a1d4c'), '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 087730e'), '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 3aaa1ed'));
|
||||
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 bfaf952'), '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 3ef7085'), '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 f2439d5'), '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 b5d0ad8'), '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 e5a1d4c'), '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 087730e'), '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 1a89172'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"phpunit\/phpunit": "^9.5",
|
||||
"rector\/phpstan-rules": "^0.6",
|
||||
"rector\/rector-debugging": "dev-main",
|
||||
"rector\/rector-src": "dev-main",
|
||||
"rector\/rector-src": "dev-main#7ad13da",
|
||||
"symplify\/easy-ci": "^11.1",
|
||||
"symplify\/easy-coding-standard": "^11.1",
|
||||
"symplify\/phpstan-extensions": "^11.1",
|
||||
|
|
|
@ -20,11 +20,11 @@ use PHPStan\Type\Type;
|
|||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Reflection\ReflectionResolver;
|
||||
use Rector\Core\Util\Reflection\PrivatesAccessor;
|
||||
use Rector\DeadCode\PhpDoc\TagRemover\ReturnTagRemover;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
|
@ -39,11 +39,6 @@ final class DowngradeCovariantReturnTypeRector extends AbstractRector
|
|||
* @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger
|
||||
*/
|
||||
private $phpDocTypeChanger;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\PackageBuilder\Reflection\PrivatesCaller
|
||||
*/
|
||||
private $privatesCaller;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\DeadCode\PhpDoc\TagRemover\ReturnTagRemover
|
||||
|
@ -54,12 +49,17 @@ final class DowngradeCovariantReturnTypeRector extends AbstractRector
|
|||
* @var \Rector\Core\Reflection\ReflectionResolver
|
||||
*/
|
||||
private $reflectionResolver;
|
||||
public function __construct(PhpDocTypeChanger $phpDocTypeChanger, PrivatesCaller $privatesCaller, ReturnTagRemover $returnTagRemover, ReflectionResolver $reflectionResolver)
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\Util\Reflection\PrivatesAccessor
|
||||
*/
|
||||
private $privatesAccessor;
|
||||
public function __construct(PhpDocTypeChanger $phpDocTypeChanger, ReturnTagRemover $returnTagRemover, ReflectionResolver $reflectionResolver, PrivatesAccessor $privatesAccessor)
|
||||
{
|
||||
$this->phpDocTypeChanger = $phpDocTypeChanger;
|
||||
$this->privatesCaller = $privatesCaller;
|
||||
$this->returnTagRemover = $returnTagRemover;
|
||||
$this->reflectionResolver = $reflectionResolver;
|
||||
$this->privatesAccessor = $privatesAccessor;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
|
@ -195,7 +195,7 @@ CODE_SAMPLE
|
|||
continue;
|
||||
}
|
||||
/** @var Type $parentReturnType */
|
||||
$parentReturnType = $this->privatesCaller->callPrivateMethod($parameterMethodReflection, 'getReturnType', []);
|
||||
$parentReturnType = $this->privatesAccessor->callPrivateMethod($parameterMethodReflection, 'getReturnType', []);
|
||||
// skip "parent" reference if correct
|
||||
if ($returnType instanceof ParentStaticType && $parentReturnType->accepts($returnType, \true)->yes()) {
|
||||
continue;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"php": ">=8.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"rector\/rector-src": "dev-main",
|
||||
"rector\/rector-src": "dev-main#7ad13da",
|
||||
"phpunit\/phpunit": "^9.5",
|
||||
"phpstan\/phpstan": "^1.8.2",
|
||||
"symplify\/phpstan-rules": "^11.0",
|
||||
|
|
|
@ -18,9 +18,9 @@ use PhpParser\Node\Scalar;
|
|||
use Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface;
|
||||
use Rector\Core\NodeAnalyzer\ArgsAnalyzer;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Util\MultiInstanceofChecker;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Php\TypeChecker;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
use RectorPrefix202209\Webmozart\Assert\Assert;
|
||||
|
@ -46,18 +46,17 @@ final class OptionalToNullsafeOperatorRector extends AbstractRector implements M
|
|||
*/
|
||||
private $excludeMethods = [];
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\PackageBuilder\Php\TypeChecker
|
||||
* @var \Rector\Core\Util\MultiInstanceofChecker
|
||||
*/
|
||||
private $typeChecker;
|
||||
private $multiInstanceofChecker;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer
|
||||
*/
|
||||
private $argsAnalyzer;
|
||||
public function __construct(TypeChecker $typeChecker, ArgsAnalyzer $argsAnalyzer)
|
||||
public function __construct(MultiInstanceofChecker $multiInstanceofChecker, ArgsAnalyzer $argsAnalyzer)
|
||||
{
|
||||
$this->typeChecker = $typeChecker;
|
||||
$this->multiInstanceofChecker = $multiInstanceofChecker;
|
||||
$this->argsAnalyzer = $argsAnalyzer;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
|
@ -108,7 +107,7 @@ CODE_SAMPLE
|
|||
/** @var Arg $firstArg */
|
||||
$firstArg = $node->var->args[0];
|
||||
// skip if the first arg cannot be used as variable directly
|
||||
if ($this->typeChecker->isInstanceOf($firstArg->value, self::SKIP_VALUE_TYPES)) {
|
||||
if ($this->multiInstanceofChecker->isInstanceOf($firstArg->value, self::SKIP_VALUE_TYPES)) {
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof PropertyFetch) {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
"rector\/rector-debugging": "dev-main",
|
||||
"rector\/phpstan-rules": "^0.6",
|
||||
"rector\/rector-generator": "^0.6",
|
||||
"rector\/rector-src": "dev-main",
|
||||
"rector\/rector-src": "dev-main#7ad13da",
|
||||
"symfony\/routing": "^6.1",
|
||||
"symfony\/security-core": "^6.1",
|
||||
"symfony\/security-http": "^6.1",
|
||||
|
|
|
@ -16,10 +16,10 @@ use PHPStan\Type\ObjectWithoutClassType;
|
|||
use PHPStan\Type\StringType;
|
||||
use PHPStan\Type\UnionType;
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Core\Util\Reflection\PrivatesAccessor;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\SimpleStaticType;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
|
||||
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
// https://github.com/symfony/symfony/blob/6.1/UPGRADE-6.0.md
|
||||
// @see https://github.com/symfony/symfony/blob/6.1/.github/expected-missing-return-types.diff
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
|
|
|
@ -4,12 +4,6 @@
|
|||
|
||||
$loader = require_once __DIR__.'/autoload.php';
|
||||
|
||||
// Exposed classes. For more information see:
|
||||
// https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#exposing-classes
|
||||
if (!class_exists('Symplify\SmartFileSystem\SmartFileInfo', false) && !interface_exists('Symplify\SmartFileSystem\SmartFileInfo', false) && !trait_exists('Symplify\SmartFileSystem\SmartFileInfo', false)) {
|
||||
spl_autoload_call('RectorPrefix202209\Symplify\SmartFileSystem\SmartFileInfo');
|
||||
}
|
||||
|
||||
// Exposed functions. For more information see:
|
||||
// https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#exposing-functions
|
||||
if (!function_exists('trigger_deprecation')) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"php": ">=8.0",
|
||||
"nette\/utils": "^3.2",
|
||||
"symfony\/dependency-injection": "^6.0",
|
||||
"symplify\/package-builder": "^11.2"
|
||||
"symplify\/package-builder": "^11.1.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit\/phpunit": "^9.5.23"
|
||||
|
@ -36,6 +36,7 @@
|
|||
"symplify\/phpstan-extensions": "<11.1.6",
|
||||
"symplify\/rule-doc-generator": "<11.1.6",
|
||||
"symplify\/vendor-patches": "<11.1.6",
|
||||
"symplify\/skipper": "<11.1.6",
|
||||
"symplify\/smart-file-system": "<11.1.6",
|
||||
"symplify\/symfony-static-dumper": "<11.1.6",
|
||||
"symplify\/symplify-kernel": "<11.1.6",
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
"symfony\/config": "^6.0",
|
||||
"symfony\/console": "^6.0",
|
||||
"symfony\/dependency-injection": "^6.0",
|
||||
"symfony\/finder": "^6.0",
|
||||
"symplify\/symplify-kernel": "^11.2"
|
||||
"symfony\/finder": "^6.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symplify\/symplify-kernel": "^11.2",
|
||||
"phpunit\/phpunit": "^9.5.23"
|
||||
},
|
||||
"autoload": {
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
The MIT License
|
||||
---------------
|
||||
|
||||
Copyright (c) 2019 Tomas Votruba (https://tomasvotruba.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,52 +0,0 @@
|
|||
{
|
||||
"name": "symplify\/smart-file-system",
|
||||
"description": "Sanitized FileInfo with safe getRealPath() and other handy methods",
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=8.0",
|
||||
"nette\/utils": "^3.2",
|
||||
"symfony\/finder": "^6.0",
|
||||
"symfony\/filesystem": "^6.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"nette\/finder": "^2.5.3",
|
||||
"phpunit\/phpunit": "^9.5.23"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"RectorPrefix202209\\Symplify\\SmartFileSystem\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"RectorPrefix202209\\Symplify\\SmartFileSystem\\Tests\\": "tests"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "11.2-dev"
|
||||
}
|
||||
},
|
||||
"conflict": {
|
||||
"symplify\/composer-json-manipulator": "<11.1.6",
|
||||
"symplify\/easy-coding-standard": "<11.1.6",
|
||||
"symplify\/phpstan-rules": "<11.1.6",
|
||||
"symplify\/easy-testing": "<11.1.6",
|
||||
"symplify\/rule-doc-generator-contracts": "<11.1.6",
|
||||
"symplify\/php-config-printer": "<11.1.6",
|
||||
"symplify\/autowire-array-parameter": "<11.1.6",
|
||||
"symplify\/package-builder": "<11.1.6",
|
||||
"symplify\/phpstan-extensions": "<11.1.6",
|
||||
"symplify\/rule-doc-generator": "<11.1.6",
|
||||
"symplify\/vendor-patches": "<11.1.6",
|
||||
"symplify\/symfony-static-dumper": "<11.1.6",
|
||||
"symplify\/symplify-kernel": "<11.1.6",
|
||||
"symplify\/monorepo-builder": "<11.1.6",
|
||||
"symplify\/config-transformer": "<11.1.6",
|
||||
"symplify\/easy-ci": "<11.1.6",
|
||||
"symplify\/coding-standard": "<11.1.6",
|
||||
"symplify\/easy-parallel": "<11.1.6"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SmartFileSystem\Exception;
|
||||
|
||||
use Exception;
|
||||
final class DirectoryNotFoundException extends Exception
|
||||
{
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SmartFileSystem\Exception;
|
||||
|
||||
use Exception;
|
||||
final class FileNotFoundException extends Exception
|
||||
{
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SmartFileSystem;
|
||||
|
||||
/**
|
||||
* @see \Symplify\SmartFileSystem\Tests\FileSystemFilter\FileSystemFilterTest
|
||||
*/
|
||||
final class FileSystemFilter
|
||||
{
|
||||
/**
|
||||
* @param string[] $filesAndDirectories
|
||||
* @return string[]
|
||||
*/
|
||||
public function filterDirectories(array $filesAndDirectories) : array
|
||||
{
|
||||
$directories = \array_filter($filesAndDirectories, static function (string $path) : bool {
|
||||
return !\is_file($path);
|
||||
});
|
||||
return \array_values($directories);
|
||||
}
|
||||
/**
|
||||
* @param string[] $filesAndDirectories
|
||||
* @return string[]
|
||||
*/
|
||||
public function filterFiles(array $filesAndDirectories) : array
|
||||
{
|
||||
$files = \array_filter($filesAndDirectories, static function (string $path) : bool {
|
||||
return \is_file($path);
|
||||
});
|
||||
return \array_values($files);
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SmartFileSystem;
|
||||
|
||||
use RectorPrefix202209\Symplify\SmartFileSystem\Exception\DirectoryNotFoundException;
|
||||
use RectorPrefix202209\Symplify\SmartFileSystem\Exception\FileNotFoundException;
|
||||
final class FileSystemGuard
|
||||
{
|
||||
public function ensureFileExists(string $file, string $location) : void
|
||||
{
|
||||
if (\file_exists($file)) {
|
||||
return;
|
||||
}
|
||||
throw new FileNotFoundException(\sprintf('File "%s" not found in "%s".', $file, $location));
|
||||
}
|
||||
public function ensureDirectoryExists(string $directory, string $extraMessage) : void
|
||||
{
|
||||
if (\is_dir($directory) && \file_exists($directory)) {
|
||||
return;
|
||||
}
|
||||
$message = \sprintf('Directory "%s" was not found.', $directory);
|
||||
if ($extraMessage !== '') {
|
||||
$message .= ' ' . $extraMessage;
|
||||
}
|
||||
throw new DirectoryNotFoundException($message);
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SmartFileSystem\Finder;
|
||||
|
||||
use RectorPrefix202209\Nette\Utils\Finder as NetteFinder;
|
||||
use SplFileInfo;
|
||||
use RectorPrefix202209\Symfony\Component\Finder\Finder as SymfonyFinder;
|
||||
use RectorPrefix202209\Symfony\Component\Finder\SplFileInfo as SymfonySplFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
/**
|
||||
* @see \Symplify\SmartFileSystem\Tests\Finder\FinderSanitizer\FinderSanitizerTest
|
||||
*/
|
||||
final class FinderSanitizer
|
||||
{
|
||||
/**
|
||||
* @param NetteFinder|SymfonyFinder|mixed[] $files
|
||||
* @return SmartFileInfo[]
|
||||
*/
|
||||
public function sanitize($files) : array
|
||||
{
|
||||
$smartFileInfos = [];
|
||||
foreach ($files as $file) {
|
||||
$fileInfo = \is_string($file) ? new SplFileInfo($file) : $file;
|
||||
if (!$this->isFileInfoValid($fileInfo)) {
|
||||
continue;
|
||||
}
|
||||
/** @var string $realPath */
|
||||
$realPath = $fileInfo->getRealPath();
|
||||
$smartFileInfos[] = new SmartFileInfo($realPath);
|
||||
}
|
||||
return $smartFileInfos;
|
||||
}
|
||||
private function isFileInfoValid(SplFileInfo $fileInfo) : bool
|
||||
{
|
||||
return (bool) $fileInfo->getRealPath();
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SmartFileSystem\Finder;
|
||||
|
||||
use RectorPrefix202209\Symfony\Component\Finder\Finder;
|
||||
use RectorPrefix202209\Symplify\SmartFileSystem\FileSystemFilter;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
/**
|
||||
* @api
|
||||
* @see \Symplify\SmartFileSystem\Tests\Finder\SmartFinder\SmartFinderTest
|
||||
*/
|
||||
final class SmartFinder
|
||||
{
|
||||
/**
|
||||
* @var \Symplify\SmartFileSystem\Finder\FinderSanitizer
|
||||
*/
|
||||
private $finderSanitizer;
|
||||
/**
|
||||
* @var \Symplify\SmartFileSystem\FileSystemFilter
|
||||
*/
|
||||
private $fileSystemFilter;
|
||||
public function __construct(FinderSanitizer $finderSanitizer, FileSystemFilter $fileSystemFilter)
|
||||
{
|
||||
$this->finderSanitizer = $finderSanitizer;
|
||||
$this->fileSystemFilter = $fileSystemFilter;
|
||||
}
|
||||
/**
|
||||
* @param string[] $directoriesOrFiles
|
||||
* @return SmartFileInfo[]
|
||||
*/
|
||||
public function findPaths(array $directoriesOrFiles, string $path) : array
|
||||
{
|
||||
$directories = $this->fileSystemFilter->filterDirectories($directoriesOrFiles);
|
||||
$fileInfos = [];
|
||||
if ($directories !== []) {
|
||||
$finder = new Finder();
|
||||
$finder->name('*')->in($directories)->path($path)->files()->sortByName();
|
||||
$fileInfos = $this->finderSanitizer->sanitize($finder);
|
||||
}
|
||||
return $fileInfos;
|
||||
}
|
||||
/**
|
||||
* @param string[] $directoriesOrFiles
|
||||
* @param string[] $excludedDirectories
|
||||
* @return SmartFileInfo[]
|
||||
*/
|
||||
public function find(array $directoriesOrFiles, string $name, array $excludedDirectories = []) : array
|
||||
{
|
||||
$directories = $this->fileSystemFilter->filterDirectories($directoriesOrFiles);
|
||||
$fileInfos = [];
|
||||
if ($directories !== []) {
|
||||
$finder = new Finder();
|
||||
$finder->name($name)->in($directories)->files()->sortByName();
|
||||
if ($excludedDirectories !== []) {
|
||||
$finder->exclude($excludedDirectories);
|
||||
}
|
||||
$fileInfos = $this->finderSanitizer->sanitize($finder);
|
||||
}
|
||||
$files = $this->fileSystemFilter->filterFiles($directoriesOrFiles);
|
||||
foreach ($files as $file) {
|
||||
$fileInfos[] = new SmartFileInfo($file);
|
||||
}
|
||||
return $fileInfos;
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SmartFileSystem\Json;
|
||||
|
||||
use RectorPrefix202209\Nette\Utils\Arrays;
|
||||
use RectorPrefix202209\Nette\Utils\Json;
|
||||
use RectorPrefix202209\Symplify\SmartFileSystem\FileSystemGuard;
|
||||
use RectorPrefix202209\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
/**
|
||||
* @api
|
||||
* @see \Symplify\SmartFileSystem\Tests\Json\JsonFileSystem\JsonFileSystemTest
|
||||
*/
|
||||
final class JsonFileSystem
|
||||
{
|
||||
/**
|
||||
* @var \Symplify\SmartFileSystem\FileSystemGuard
|
||||
*/
|
||||
private $fileSystemGuard;
|
||||
/**
|
||||
* @var \Symplify\SmartFileSystem\SmartFileSystem
|
||||
*/
|
||||
private $smartFileSystem;
|
||||
public function __construct(FileSystemGuard $fileSystemGuard, SmartFileSystem $smartFileSystem)
|
||||
{
|
||||
$this->fileSystemGuard = $fileSystemGuard;
|
||||
$this->smartFileSystem = $smartFileSystem;
|
||||
}
|
||||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function loadFilePathToJson(string $filePath) : array
|
||||
{
|
||||
$this->fileSystemGuard->ensureFileExists($filePath, __METHOD__);
|
||||
$fileContent = $this->smartFileSystem->readFile($filePath);
|
||||
return Json::decode($fileContent, Json::FORCE_ARRAY);
|
||||
}
|
||||
/**
|
||||
* @param array<string, mixed> $jsonArray
|
||||
*/
|
||||
public function writeJsonToFilePath(array $jsonArray, string $filePath) : void
|
||||
{
|
||||
$jsonContent = Json::encode($jsonArray, Json::PRETTY) . \PHP_EOL;
|
||||
$this->smartFileSystem->dumpFile($filePath, $jsonContent);
|
||||
}
|
||||
/**
|
||||
* @param array<string, mixed> $newJsonArray
|
||||
*/
|
||||
public function mergeArrayToJsonFile(string $filePath, array $newJsonArray) : void
|
||||
{
|
||||
$jsonArray = $this->loadFilePathToJson($filePath);
|
||||
$newComposerJsonArray = Arrays::mergeTree($jsonArray, $newJsonArray);
|
||||
$this->writeJsonToFilePath($newComposerJsonArray, $filePath);
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SmartFileSystem\Normalizer;
|
||||
|
||||
use RectorPrefix202209\Nette\Utils\Strings;
|
||||
/**
|
||||
* @api
|
||||
*
|
||||
* Used from
|
||||
* https://github.com/phpstan/phpstan-src/blob/02425e61aa48f0668b4efb3e73d52ad544048f65/src/File/FileHelper.php#L40,
|
||||
* with custom modifications
|
||||
*
|
||||
* @see \Symplify\SmartFileSystem\Tests\Normalizer\PathNormalizerTest
|
||||
*/
|
||||
final class PathNormalizer
|
||||
{
|
||||
/**
|
||||
* @see https://regex101.com/r/d4F5Fm/1
|
||||
* @var string
|
||||
*/
|
||||
private const SCHEME_PATH_REGEX = '#^([a-z]+)\\:\\/\\/(.+)#';
|
||||
/**
|
||||
* @see https://regex101.com/r/no28vw/1
|
||||
* @var string
|
||||
*/
|
||||
private const TWO_AND_MORE_SLASHES_REGEX = '#/{2,}#';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const SCHEME_UNDEFINED = 'undefined';
|
||||
public function normalizePath(string $originalPath) : string
|
||||
{
|
||||
$directorySeparator = \DIRECTORY_SEPARATOR;
|
||||
$matches = Strings::match($originalPath, self::SCHEME_PATH_REGEX);
|
||||
if ($matches !== null) {
|
||||
[, $scheme, $path] = $matches;
|
||||
} else {
|
||||
$scheme = self::SCHEME_UNDEFINED;
|
||||
$path = $originalPath;
|
||||
}
|
||||
$normalizedPath = \str_replace('\\', '/', $path);
|
||||
$path = Strings::replace($normalizedPath, self::TWO_AND_MORE_SLASHES_REGEX, '/');
|
||||
$pathRoot = \strncmp($path, '/', \strlen('/')) === 0 ? $directorySeparator : '';
|
||||
$pathParts = \explode('/', \trim($path, '/'));
|
||||
$normalizedPathParts = $this->normalizePathParts($pathParts, $scheme);
|
||||
$pathStart = $scheme !== self::SCHEME_UNDEFINED ? $scheme . '://' : '';
|
||||
return $pathStart . $pathRoot . \implode($directorySeparator, $normalizedPathParts);
|
||||
}
|
||||
/**
|
||||
* @param string[] $pathParts
|
||||
* @return string[]
|
||||
*/
|
||||
private function normalizePathParts(array $pathParts, string $scheme) : array
|
||||
{
|
||||
$normalizedPathParts = [];
|
||||
foreach ($pathParts as $pathPart) {
|
||||
if ($pathPart === '.') {
|
||||
continue;
|
||||
}
|
||||
if ($pathPart !== '..') {
|
||||
$normalizedPathParts[] = $pathPart;
|
||||
continue;
|
||||
}
|
||||
/** @var string $removedPart */
|
||||
$removedPart = \array_pop($normalizedPathParts);
|
||||
if ($scheme !== 'phar') {
|
||||
continue;
|
||||
}
|
||||
if (\substr_compare($removedPart, '.phar', -\strlen('.phar')) !== 0) {
|
||||
continue;
|
||||
}
|
||||
$scheme = self::SCHEME_UNDEFINED;
|
||||
}
|
||||
return $normalizedPathParts;
|
||||
}
|
||||
}
|
|
@ -1,131 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SmartFileSystem;
|
||||
|
||||
use RectorPrefix202209\Nette\Utils\Strings;
|
||||
use RectorPrefix202209\Symfony\Component\Finder\SplFileInfo;
|
||||
use RectorPrefix202209\Symplify\EasyTesting\PHPUnit\StaticPHPUnitEnvironment;
|
||||
use RectorPrefix202209\Symplify\EasyTesting\StaticFixtureSplitter;
|
||||
use RectorPrefix202209\Symplify\SmartFileSystem\Exception\DirectoryNotFoundException;
|
||||
use RectorPrefix202209\Symplify\SmartFileSystem\Exception\FileNotFoundException;
|
||||
/**
|
||||
* @api
|
||||
* @see \Symplify\SmartFileSystem\Tests\SmartFileInfo\SmartFileInfoTest
|
||||
*/
|
||||
final class SmartFileInfo extends SplFileInfo
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
* @see https://regex101.com/r/SYP00O/1
|
||||
*/
|
||||
private const LAST_SUFFIX_REGEX = '#\\.[^.]+$#';
|
||||
/**
|
||||
* @var \Symplify\SmartFileSystem\SmartFileSystem
|
||||
*/
|
||||
private $smartFileSystem;
|
||||
public function __construct(string $filePath)
|
||||
{
|
||||
$this->smartFileSystem = new SmartFileSystem();
|
||||
// accepts also dirs
|
||||
if (!\file_exists($filePath)) {
|
||||
throw new FileNotFoundException(\sprintf('File path "%s" was not found while creating "%s" object.', $filePath, self::class));
|
||||
}
|
||||
// real path doesn't work in PHAR: https://www.php.net/manual/en/function.realpath.php
|
||||
if (\strncmp($filePath, 'phar://', \strlen('phar://')) === 0) {
|
||||
$relativeFilePath = $filePath;
|
||||
$relativeDirectoryPath = \dirname($filePath);
|
||||
} else {
|
||||
$realPath = \realpath($filePath);
|
||||
$relativeFilePath = \rtrim($this->smartFileSystem->makePathRelative($realPath, \getcwd()), '/');
|
||||
$relativeDirectoryPath = \dirname($relativeFilePath);
|
||||
}
|
||||
parent::__construct($filePath, $relativeDirectoryPath, $relativeFilePath);
|
||||
}
|
||||
public function getBasenameWithoutSuffix() : string
|
||||
{
|
||||
return \pathinfo($this->getFilename())['filename'];
|
||||
}
|
||||
public function getSuffix() : string
|
||||
{
|
||||
return \pathinfo($this->getFilename(), \PATHINFO_EXTENSION);
|
||||
}
|
||||
/**
|
||||
* @param string[] $suffixes
|
||||
*/
|
||||
public function hasSuffixes(array $suffixes) : bool
|
||||
{
|
||||
return \in_array($this->getSuffix(), $suffixes, \true);
|
||||
}
|
||||
public function getRealPathWithoutSuffix() : string
|
||||
{
|
||||
return Strings::replace($this->getRealPath(), self::LAST_SUFFIX_REGEX, '');
|
||||
}
|
||||
public function getRelativeFilePath() : string
|
||||
{
|
||||
return $this->getRelativePathname();
|
||||
}
|
||||
public function getRelativeDirectoryPath() : string
|
||||
{
|
||||
return $this->getRelativePath();
|
||||
}
|
||||
public function getRelativeFilePathFromDirectory(string $directory) : string
|
||||
{
|
||||
if (!\file_exists($directory)) {
|
||||
throw new DirectoryNotFoundException(\sprintf('Directory "%s" was not found in %s.', $directory, self::class));
|
||||
}
|
||||
$relativeFilePath = $this->smartFileSystem->makePathRelative($this->getNormalizedRealPath(), (string) \realpath($directory));
|
||||
return \rtrim($relativeFilePath, '/');
|
||||
}
|
||||
public function getRelativeFilePathFromCwdInTests() : string
|
||||
{
|
||||
// special case for tests
|
||||
if (StaticPHPUnitEnvironment::isPHPUnitRun()) {
|
||||
return $this->getRelativeFilePathFromDirectory(StaticFixtureSplitter::getTemporaryPath());
|
||||
}
|
||||
return $this->getRelativeFilePathFromDirectory(\getcwd());
|
||||
}
|
||||
public function getRelativeFilePathFromCwd() : string
|
||||
{
|
||||
return $this->getRelativeFilePathFromDirectory(\getcwd());
|
||||
}
|
||||
public function endsWith(string $string) : bool
|
||||
{
|
||||
return \substr_compare($this->getNormalizedRealPath(), $string, -\strlen($string)) === 0;
|
||||
}
|
||||
public function doesFnmatch(string $string) : bool
|
||||
{
|
||||
$normalizedPath = $this->normalizePath($string);
|
||||
if (\fnmatch($normalizedPath, $this->getNormalizedRealPath())) {
|
||||
return \true;
|
||||
}
|
||||
// in case of relative compare
|
||||
return \fnmatch('*/' . $normalizedPath, $this->getNormalizedRealPath());
|
||||
}
|
||||
public function getRealPath() : string
|
||||
{
|
||||
// for phar compatibility @see https://github.com/rectorphp/rector/commit/e5d7cee69558f7e6b35d995a5ca03fa481b0407c
|
||||
return parent::getRealPath() ?: $this->getPathname();
|
||||
}
|
||||
public function getRealPathDirectory() : string
|
||||
{
|
||||
return \dirname($this->getRealPath());
|
||||
}
|
||||
public function startsWith(string $partialPath) : bool
|
||||
{
|
||||
return \strncmp($this->getNormalizedRealPath(), $partialPath, \strlen($partialPath)) === 0;
|
||||
}
|
||||
private function getNormalizedRealPath() : string
|
||||
{
|
||||
return $this->normalizePath($this->getRealPath());
|
||||
}
|
||||
private function normalizePath(string $path) : string
|
||||
{
|
||||
return \str_replace('\\', '/', $path);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @api
|
||||
* @see \Symplify\SmartFileSystem\Tests\SmartFileInfo\SmartFileInfoTest
|
||||
*/
|
||||
\class_alias('RectorPrefix202209\\Symplify\\SmartFileSystem\\SmartFileInfo', 'Symplify\\SmartFileSystem\\SmartFileInfo', \false);
|
|
@ -1,56 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SmartFileSystem;
|
||||
|
||||
use RectorPrefix202209\Nette\Utils\Strings;
|
||||
use RectorPrefix202209\Symfony\Component\Filesystem\Exception\IOException;
|
||||
use RectorPrefix202209\Symfony\Component\Filesystem\Filesystem;
|
||||
/**
|
||||
* @see \Symplify\SmartFileSystem\Tests\SmartFileSystem\SmartFileSystemTest
|
||||
*/
|
||||
final class SmartFileSystem extends Filesystem
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
* @see https://regex101.com/r/tx6eyw/1
|
||||
*/
|
||||
private const BEFORE_COLLON_REGEX = '#^\\w+\\(.*?\\): #';
|
||||
/**
|
||||
* @see https://github.com/symfony/filesystem/pull/4/files
|
||||
*/
|
||||
public function readFile(string $fileName) : string
|
||||
{
|
||||
$source = @\file_get_contents($fileName);
|
||||
if (!$source) {
|
||||
$message = \sprintf('Failed to read "%s" file: "%s"', $fileName, $this->getLastError());
|
||||
throw new IOException($message, 0, null, $fileName);
|
||||
}
|
||||
return $source;
|
||||
}
|
||||
public function readFileToSmartFileInfo(string $fileName) : SmartFileInfo
|
||||
{
|
||||
return new SmartFileInfo($fileName);
|
||||
}
|
||||
/**
|
||||
* Converts given HTML code to plain text
|
||||
*
|
||||
* @source https://github.com/nette/utils/blob/e7bd59f1dd860d25dbbb1ac720dddd0fa1388f4c/src/Utils/Html.php#L325-L331
|
||||
*/
|
||||
private function htmlToText(string $html) : string
|
||||
{
|
||||
$content = \strip_tags($html);
|
||||
return \html_entity_decode($content, \ENT_QUOTES | \ENT_HTML5, 'UTF-8');
|
||||
}
|
||||
/**
|
||||
* Returns the last PHP error as plain string.
|
||||
*
|
||||
* @source https://github.com/nette/utils/blob/ab8eea12b8aacc7ea5bdafa49b711c2988447994/src/Utils/Helpers.php#L31-L40
|
||||
*/
|
||||
private function getLastError() : string
|
||||
{
|
||||
$message = \error_get_last()['message'] ?? '';
|
||||
$htmlMessage = \ini_get('html_errors') ? $this->htmlToText($message) : $message;
|
||||
return Strings::replace($htmlMessage, self::BEFORE_COLLON_REGEX, '');
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
# Symplify Kernel
|
||||
|
||||
[![Downloads total](https://img.shields.io/packagist/dt/symplify/symplify-kernel.svg?style=flat-square)](https://packagist.org/packages/symplify/symplify-kernel/stats)
|
||||
|
||||
Do you use Symfony Kernel, but not for PHP projects?
|
||||
|
||||
Use Symfony Kernel for:
|
||||
|
||||
* light [Symfony Console Apps](https://tomasvotruba.com/blog/introducing-light-kernel-for-symfony-console-apps/) without Http
|
||||
* faster and easy-to-setup tests
|
||||
* merging of array parameters in 2 configs
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
composer require symplify/symplify-kernel --dev
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### 1. Light Kernel for Symfony CLI Apps
|
||||
|
||||
```php
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symplify\SymplifyKernel\ContainerBuilderFactory;
|
||||
|
||||
final class MonorepoBuilderKernel
|
||||
{
|
||||
/**
|
||||
* @param string[] $configFiles
|
||||
*/
|
||||
public function createFromConfigs(array $configFiles): ContainerInterface
|
||||
{
|
||||
// local config here
|
||||
$configFiles[] = __DIR__ . '/../../config/config.php';
|
||||
|
||||
$containerBuilderFactory = new ContainerBuilderFactory();
|
||||
$containerBuilder = $containerBuilderFactory->create($configFiles, [], []);
|
||||
|
||||
// build the container
|
||||
$containerBuilder->compile();
|
||||
|
||||
return $containerBuilder;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then use in your `bin/app.php` file:
|
||||
|
||||
```php
|
||||
$easyCIKernel = new MonorepoBuilderKernel();
|
||||
$easyCIKernel->createFromConfigs([__DIR__ . '/config/config.php']);
|
||||
|
||||
$container = $easyCIKernel->getContainer();
|
||||
|
||||
/** @var Application $application */
|
||||
$application = $container->get(Application::class);
|
||||
exit($application->run());
|
||||
```
|
||||
|
||||
That's it!
|
||||
|
||||
<br>
|
||||
|
||||
## Report Issues
|
||||
|
||||
In case you are experiencing a bug or want to request a new feature head over to the [Symplify monorepo issue tracker](https://github.com/symplify/symplify/issues)
|
||||
|
||||
## Contribute
|
||||
|
||||
The sources of this package are contained in the Symplify monorepo. We welcome contributions for this package on [symplify/symplify](https://github.com/symplify/symplify).
|
|
@ -1,50 +0,0 @@
|
|||
{
|
||||
"name": "symplify\/symplify-kernel",
|
||||
"description": "Internal Kernel for Symplify packages",
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=8.0",
|
||||
"symfony\/console": "^6.0",
|
||||
"symfony\/dependency-injection": "^6.0",
|
||||
"symplify\/smart-file-system": "^11.2",
|
||||
"symplify\/autowire-array-parameter": "^11.2",
|
||||
"symplify\/package-builder": "^11.2",
|
||||
"webmozart\/assert": "^1.10"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit\/phpunit": "^9.5.23"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"RectorPrefix202209\\Symplify\\SymplifyKernel\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"RectorPrefix202209\\Symplify\\SymplifyKernel\\Tests\\": "tests"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "11.2-dev"
|
||||
}
|
||||
},
|
||||
"conflict": {
|
||||
"symplify\/easy-coding-standard": "<11.1.6",
|
||||
"symplify\/phpstan-rules": "<11.1.6",
|
||||
"symplify\/easy-testing": "<11.1.6",
|
||||
"symplify\/rule-doc-generator-contracts": "<11.1.6",
|
||||
"symplify\/php-config-printer": "<11.1.6",
|
||||
"symplify\/phpstan-extensions": "<11.1.6",
|
||||
"symplify\/rule-doc-generator": "<11.1.6",
|
||||
"symplify\/vendor-patches": "<11.1.6",
|
||||
"symplify\/symfony-static-dumper": "<11.1.6",
|
||||
"symplify\/monorepo-builder": "<11.1.6",
|
||||
"symplify\/config-transformer": "<11.1.6",
|
||||
"symplify\/easy-ci": "<11.1.6",
|
||||
"symplify\/coding-standard": "<11.1.6",
|
||||
"symplify\/easy-parallel": "<11.1.6"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209;
|
||||
|
||||
use RectorPrefix202209\Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use RectorPrefix202209\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
use RectorPrefix202209\Symplify\SmartFileSystem\FileSystemFilter;
|
||||
use RectorPrefix202209\Symplify\SmartFileSystem\FileSystemGuard;
|
||||
use RectorPrefix202209\Symplify\SmartFileSystem\Finder\FinderSanitizer;
|
||||
use RectorPrefix202209\Symplify\SmartFileSystem\Finder\SmartFinder;
|
||||
use RectorPrefix202209\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
use function RectorPrefix202209\Symfony\Component\DependencyInjection\Loader\Configurator\service;
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->defaults()->public()->autowire();
|
||||
// symfony style
|
||||
$services->set(SymfonyStyleFactory::class);
|
||||
$services->set(SymfonyStyle::class)->factory([service(SymfonyStyleFactory::class), 'create']);
|
||||
// filesystem
|
||||
$services->set(FinderSanitizer::class);
|
||||
$services->set(SmartFileSystem::class);
|
||||
$services->set(SmartFinder::class);
|
||||
$services->set(FileSystemGuard::class);
|
||||
$services->set(FileSystemFilter::class);
|
||||
$services->set(ParameterProvider::class)->args([service('service_container')]);
|
||||
$services->set(PrivatesAccessor::class);
|
||||
};
|
|
@ -1,9 +0,0 @@
|
|||
<phpunit
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
verbose="true"
|
||||
>
|
||||
<testsuite name="all">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</phpunit>
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SymplifyKernel\Config\Loader;
|
||||
|
||||
use RectorPrefix202209\Symfony\Component\Config\FileLocator;
|
||||
use RectorPrefix202209\Symfony\Component\Config\Loader\DelegatingLoader;
|
||||
use RectorPrefix202209\Symfony\Component\Config\Loader\GlobFileLoader;
|
||||
use RectorPrefix202209\Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use RectorPrefix202209\Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\DependencyInjection\FileLoader\ParameterMergingPhpFileLoader;
|
||||
use RectorPrefix202209\Symplify\SymplifyKernel\Contract\Config\LoaderFactoryInterface;
|
||||
final class ParameterMergingLoaderFactory implements LoaderFactoryInterface
|
||||
{
|
||||
public function create(ContainerBuilder $containerBuilder, string $currentWorkingDirectory) : \RectorPrefix202209\Symfony\Component\Config\Loader\LoaderInterface
|
||||
{
|
||||
$fileLocator = new FileLocator([$currentWorkingDirectory]);
|
||||
$loaders = [new GlobFileLoader($fileLocator), new ParameterMergingPhpFileLoader($containerBuilder, $fileLocator)];
|
||||
$loaderResolver = new LoaderResolver($loaders);
|
||||
return new DelegatingLoader($loaderResolver);
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SymplifyKernel;
|
||||
|
||||
use RectorPrefix202209\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use RectorPrefix202209\Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use RectorPrefix202209\Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
||||
use RectorPrefix202209\Symplify\SymplifyKernel\Contract\Config\LoaderFactoryInterface;
|
||||
use RectorPrefix202209\Symplify\SymplifyKernel\DependencyInjection\LoadExtensionConfigsCompilerPass;
|
||||
use RectorPrefix202209\Webmozart\Assert\Assert;
|
||||
/**
|
||||
* @see \Symplify\SymplifyKernel\Tests\ContainerBuilderFactory\ContainerBuilderFactoryTest
|
||||
*/
|
||||
final class ContainerBuilderFactory
|
||||
{
|
||||
/**
|
||||
* @var \Symplify\SymplifyKernel\Contract\Config\LoaderFactoryInterface
|
||||
*/
|
||||
private $loaderFactory;
|
||||
public function __construct(LoaderFactoryInterface $loaderFactory)
|
||||
{
|
||||
$this->loaderFactory = $loaderFactory;
|
||||
}
|
||||
/**
|
||||
* @param string[] $configFiles
|
||||
* @param CompilerPassInterface[] $compilerPasses
|
||||
* @param ExtensionInterface[] $extensions
|
||||
*/
|
||||
public function create(array $configFiles, array $compilerPasses, array $extensions) : ContainerBuilder
|
||||
{
|
||||
Assert::allIsAOf($extensions, ExtensionInterface::class);
|
||||
Assert::allIsAOf($compilerPasses, CompilerPassInterface::class);
|
||||
Assert::allString($configFiles);
|
||||
Assert::allFile($configFiles);
|
||||
$containerBuilder = new ContainerBuilder();
|
||||
$this->registerExtensions($containerBuilder, $extensions);
|
||||
$this->registerConfigFiles($containerBuilder, $configFiles);
|
||||
$this->registerCompilerPasses($containerBuilder, $compilerPasses);
|
||||
// this calls load() method in every extensions
|
||||
// ensure these extensions are implicitly loaded
|
||||
$compilerPassConfig = $containerBuilder->getCompilerPassConfig();
|
||||
$compilerPassConfig->setMergePass(new LoadExtensionConfigsCompilerPass());
|
||||
return $containerBuilder;
|
||||
}
|
||||
/**
|
||||
* @param ExtensionInterface[] $extensions
|
||||
*/
|
||||
private function registerExtensions(ContainerBuilder $containerBuilder, array $extensions) : void
|
||||
{
|
||||
foreach ($extensions as $extension) {
|
||||
$containerBuilder->registerExtension($extension);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param CompilerPassInterface[] $compilerPasses
|
||||
*/
|
||||
private function registerCompilerPasses(ContainerBuilder $containerBuilder, array $compilerPasses) : void
|
||||
{
|
||||
foreach ($compilerPasses as $compilerPass) {
|
||||
$containerBuilder->addCompilerPass($compilerPass);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param string[] $configFiles
|
||||
*/
|
||||
private function registerConfigFiles(ContainerBuilder $containerBuilder, array $configFiles) : void
|
||||
{
|
||||
$delegatingLoader = $this->loaderFactory->create($containerBuilder, \getcwd());
|
||||
foreach ($configFiles as $configFile) {
|
||||
$delegatingLoader->load($configFile);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SymplifyKernel\Contract\Config;
|
||||
|
||||
use RectorPrefix202209\Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use RectorPrefix202209\Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
interface LoaderFactoryInterface
|
||||
{
|
||||
public function create(ContainerBuilder $containerBuilder, string $currentWorkingDirectory) : LoaderInterface;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SymplifyKernel\Contract;
|
||||
|
||||
use RectorPrefix202209\Psr\Container\ContainerInterface;
|
||||
/**
|
||||
* @api
|
||||
*/
|
||||
interface LightKernelInterface
|
||||
{
|
||||
/**
|
||||
* @param string[] $configFiles
|
||||
*/
|
||||
public function createFromConfigs(array $configFiles) : ContainerInterface;
|
||||
public function getContainer() : ContainerInterface;
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SymplifyKernel\DependencyInjection;
|
||||
|
||||
use RectorPrefix202209\Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass;
|
||||
use RectorPrefix202209\Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
/**
|
||||
* Mimics @see \Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass without dependency on
|
||||
* symfony/http-kernel
|
||||
*/
|
||||
final class LoadExtensionConfigsCompilerPass extends MergeExtensionConfigurationPass
|
||||
{
|
||||
public function process(ContainerBuilder $containerBuilder) : void
|
||||
{
|
||||
$extensionNames = \array_keys($containerBuilder->getExtensions());
|
||||
foreach ($extensionNames as $extensionName) {
|
||||
$containerBuilder->loadFromExtension($extensionName, []);
|
||||
}
|
||||
parent::process($containerBuilder);
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SymplifyKernel\Exception;
|
||||
|
||||
use Exception;
|
||||
final class BootException extends Exception
|
||||
{
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SymplifyKernel\Exception;
|
||||
|
||||
use Exception;
|
||||
/**
|
||||
* @api
|
||||
*/
|
||||
final class ShouldNotHappenException extends Exception
|
||||
{
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SymplifyKernel\HttpKernel;
|
||||
|
||||
use RectorPrefix202209\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use RectorPrefix202209\Symfony\Component\DependencyInjection\Container;
|
||||
use RectorPrefix202209\Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use RectorPrefix202209\Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
||||
use RectorPrefix202209\Symplify\AutowireArrayParameter\DependencyInjection\CompilerPass\AutowireArrayParameterCompilerPass;
|
||||
use RectorPrefix202209\Symplify\SymplifyKernel\Config\Loader\ParameterMergingLoaderFactory;
|
||||
use RectorPrefix202209\Symplify\SymplifyKernel\ContainerBuilderFactory;
|
||||
use RectorPrefix202209\Symplify\SymplifyKernel\Contract\LightKernelInterface;
|
||||
use RectorPrefix202209\Symplify\SymplifyKernel\Exception\ShouldNotHappenException;
|
||||
use RectorPrefix202209\Symplify\SymplifyKernel\ValueObject\SymplifyKernelConfig;
|
||||
/**
|
||||
* @api
|
||||
*/
|
||||
abstract class AbstractSymplifyKernel implements LightKernelInterface
|
||||
{
|
||||
/**
|
||||
* @var \Symfony\Component\DependencyInjection\Container|null
|
||||
*/
|
||||
private $container = null;
|
||||
/**
|
||||
* @param string[] $configFiles
|
||||
* @param CompilerPassInterface[] $compilerPasses
|
||||
* @param ExtensionInterface[] $extensions
|
||||
*/
|
||||
public function create(array $configFiles, array $compilerPasses = [], array $extensions = []) : ContainerInterface
|
||||
{
|
||||
$containerBuilderFactory = new ContainerBuilderFactory(new ParameterMergingLoaderFactory());
|
||||
$compilerPasses[] = new AutowireArrayParameterCompilerPass();
|
||||
$configFiles[] = SymplifyKernelConfig::FILE_PATH;
|
||||
$containerBuilder = $containerBuilderFactory->create($configFiles, $compilerPasses, $extensions);
|
||||
$containerBuilder->compile();
|
||||
$this->container = $containerBuilder;
|
||||
return $containerBuilder;
|
||||
}
|
||||
public function getContainer() : \RectorPrefix202209\Psr\Container\ContainerInterface
|
||||
{
|
||||
if (!$this->container instanceof Container) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
return $this->container;
|
||||
}
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SymplifyKernel\ValueObject;
|
||||
|
||||
use RectorPrefix202209\Symfony\Component\Console\Application;
|
||||
use RectorPrefix202209\Symfony\Component\Console\Command\Command;
|
||||
use RectorPrefix202209\Symfony\Component\HttpKernel\KernelInterface;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Console\Input\StaticInputDetector;
|
||||
use RectorPrefix202209\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory;
|
||||
use RectorPrefix202209\Symplify\SymplifyKernel\Contract\LightKernelInterface;
|
||||
use RectorPrefix202209\Symplify\SymplifyKernel\Exception\BootException;
|
||||
use Throwable;
|
||||
/**
|
||||
* @api
|
||||
*/
|
||||
final class KernelBootAndApplicationRun
|
||||
{
|
||||
/**
|
||||
* @var class-string<(KernelInterface | LightKernelInterface)>
|
||||
*/
|
||||
private $kernelClass;
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $extraConfigs = [];
|
||||
/**
|
||||
* @param class-string<KernelInterface|LightKernelInterface> $kernelClass
|
||||
* @param string[] $extraConfigs
|
||||
*/
|
||||
public function __construct(string $kernelClass, array $extraConfigs = [])
|
||||
{
|
||||
$this->kernelClass = $kernelClass;
|
||||
$this->extraConfigs = $extraConfigs;
|
||||
$this->validateKernelClass($this->kernelClass);
|
||||
}
|
||||
public function run() : void
|
||||
{
|
||||
try {
|
||||
$this->booKernelAndRunApplication();
|
||||
} catch (Throwable $throwable) {
|
||||
$symfonyStyleFactory = new SymfonyStyleFactory();
|
||||
$symfonyStyle = $symfonyStyleFactory->create();
|
||||
$symfonyStyle->error($throwable->getMessage());
|
||||
exit(Command::FAILURE);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @return \Symfony\Component\HttpKernel\KernelInterface|\Symplify\SymplifyKernel\Contract\LightKernelInterface
|
||||
*/
|
||||
private function createKernel()
|
||||
{
|
||||
// random has is needed, so cache is invalidated and changes from config are loaded
|
||||
$kernelClass = $this->kernelClass;
|
||||
if (\is_a($kernelClass, LightKernelInterface::class, \true)) {
|
||||
return new $kernelClass();
|
||||
}
|
||||
$environment = 'prod' . \random_int(1, 100000);
|
||||
return new $kernelClass($environment, StaticInputDetector::isDebug());
|
||||
}
|
||||
private function booKernelAndRunApplication() : void
|
||||
{
|
||||
$kernel = $this->createKernel();
|
||||
if ($kernel instanceof LightKernelInterface) {
|
||||
$container = $kernel->createFromConfigs($this->extraConfigs);
|
||||
} else {
|
||||
$kernel->boot();
|
||||
$container = $kernel->getContainer();
|
||||
}
|
||||
/** @var Application $application */
|
||||
$application = $container->get(Application::class);
|
||||
// remove --no-interaction (with -n shortcut) option from Application
|
||||
// because we need to create option with -n shortcuts too
|
||||
// for example: --dry-run with shortcut -n
|
||||
$inputDefinition = $application->getDefinition();
|
||||
$options = $inputDefinition->getOptions();
|
||||
$options = \array_filter($options, static function ($option) {
|
||||
return $option->getName() !== 'no-interaction';
|
||||
});
|
||||
$inputDefinition->setOptions($options);
|
||||
exit($application->run());
|
||||
}
|
||||
/**
|
||||
* @param class-string $kernelClass
|
||||
*/
|
||||
private function validateKernelClass(string $kernelClass) : void
|
||||
{
|
||||
if (\is_a($kernelClass, KernelInterface::class, \true)) {
|
||||
return;
|
||||
}
|
||||
if (\is_a($kernelClass, LightKernelInterface::class, \true)) {
|
||||
return;
|
||||
}
|
||||
$currentValueType = \get_debug_type($kernelClass);
|
||||
$errorMessage = \sprintf('Class "%s" must by type of "%s" or "%s". "%s" given', $kernelClass, KernelInterface::class, LightKernelInterface::class, $currentValueType);
|
||||
throw new BootException($errorMessage);
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SymplifyKernel\ValueObject;
|
||||
|
||||
/**
|
||||
* @api
|
||||
*/
|
||||
final class SymplifyKernelConfig
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const FILE_PATH = __DIR__ . '/../../config/common-config.php';
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209\Symplify\SymplifyKernel\Tests\ContainerBuilderFactory;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use RectorPrefix202209\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
use RectorPrefix202209\Symplify\SymplifyKernel\Config\Loader\ParameterMergingLoaderFactory;
|
||||
use RectorPrefix202209\Symplify\SymplifyKernel\ContainerBuilderFactory;
|
||||
final class ContainerBuilderFactoryTest extends TestCase
|
||||
{
|
||||
public function test() : void
|
||||
{
|
||||
$containerBuilderFactory = new ContainerBuilderFactory(new ParameterMergingLoaderFactory());
|
||||
$containerBuilder = $containerBuilderFactory->create([__DIR__ . '/config/some_services.php'], [], []);
|
||||
$hasSmartFileSystemService = $containerBuilder->has(SmartFileSystem::class);
|
||||
$this->assertTrue($hasSmartFileSystemService);
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202209;
|
||||
|
||||
use RectorPrefix202209\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use RectorPrefix202209\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(SmartFileSystem::class);
|
||||
};
|
Loading…
Reference in New Issue