Skip to content

Commit

Permalink
Updated Rector to commit 3ff83e52db13fd98dcde85b1d2d53f7db80b875b
Browse files Browse the repository at this point in the history
rectorphp/rector-src@3ff83e5 Make use of toPhpDocNode() - take #9 (#4572)
  • Loading branch information
TomasVotruba committed Jul 21, 2023
1 parent 06ce8e9 commit ddde48c
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use PHPStan\Type\ObjectType;
use PHPStan\Type\ObjectWithoutClassType;
use PHPStan\Type\Type;
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareIntersectionTypeNode;
use Rector\Core\Php\PhpVersionProvider;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
Expand Down Expand Up @@ -61,15 +60,7 @@ public function getNodeClass() : string
*/
public function mapToPHPStanPhpDocTypeNode(Type $type) : TypeNode
{
$intersectionTypesNodes = [];
foreach ($type->getTypes() as $intersectionedType) {
$intersectionTypesNodes[] = $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($intersectionedType);
}
$intersectionTypesNodes = \array_unique($intersectionTypesNodes);
if (\count($intersectionTypesNodes) === 1) {
return $intersectionTypesNodes[0];
}
return new BracketsAwareIntersectionTypeNode($intersectionTypesNodes);
return $type->toPhpDocNode();
}
/**
* @param IntersectionType $type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,15 @@

use PhpParser\Node;
use PhpParser\Node\Identifier;
use PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
use PHPStan\Type\IterableType;
use PHPStan\Type\Type;
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode;
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode;
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
use Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper;
use RectorPrefix202307\Symfony\Contracts\Service\Attribute\Required;
/**
* @implements TypeMapperInterface<IterableType>
*/
final class IterableTypeMapper implements TypeMapperInterface
{
/**
* @var \Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper
*/
private $phpStanStaticTypeMapper;
/**
* @required
*/
public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper) : void
{
$this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper;
}
/**
* @return class-string<Type>
*/
Expand All @@ -43,11 +26,7 @@ public function getNodeClass() : string
*/
public function mapToPHPStanPhpDocTypeNode(Type $type) : TypeNode
{
$itemTypeNode = $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($type->getItemType());
if ($itemTypeNode instanceof UnionTypeNode) {
return $this->convertUnionArrayTypeNodesToArrayTypeOfUnionTypeNodes($itemTypeNode);
}
return new SpacingAwareArrayTypeNode($itemTypeNode);
return $type->toPhpDocNode();
}
/**
* @param IterableType $type
Expand All @@ -56,19 +35,4 @@ public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node
{
return new Identifier('iterable');
}
private function convertUnionArrayTypeNodesToArrayTypeOfUnionTypeNodes(UnionTypeNode $unionTypeNode) : BracketsAwareUnionTypeNode
{
$unionedArrayType = [];
foreach ($unionTypeNode->types as $unionedType) {
if ($unionedType instanceof UnionTypeNode) {
foreach ($unionedType->types as $key => $subUnionedType) {
$unionedType->types[$key] = new ArrayTypeNode($subUnionedType);
}
$unionedArrayType[] = $unionedType;
continue;
}
$unionedArrayType[] = new ArrayTypeNode($unionedType);
}
return new BracketsAwareUnionTypeNode($unionedArrayType);
}
}
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '6cd3eecc07d3321f76235c7a07a765e510157af6';
public const PACKAGE_VERSION = '3ff83e52db13fd98dcde85b1d2d53f7db80b875b';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-07-21 15:12:06';
public const RELEASE_DATE = '2023-07-21 15:20:13';
/**
* @var int
*/
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInitb29d4c290aa7898e1fde7e5adbfc60b1::getLoader();
return ComposerAutoloaderInit978a84f91f7d9c390e02e0746cd635ac::getLoader();
10 changes: 5 additions & 5 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInitb29d4c290aa7898e1fde7e5adbfc60b1
class ComposerAutoloaderInit978a84f91f7d9c390e02e0746cd635ac
{
private static $loader;

Expand All @@ -22,17 +22,17 @@ public static function getLoader()
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInitb29d4c290aa7898e1fde7e5adbfc60b1', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit978a84f91f7d9c390e02e0746cd635ac', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitb29d4c290aa7898e1fde7e5adbfc60b1', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit978a84f91f7d9c390e02e0746cd635ac', 'loadClassLoader'));

require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitb29d4c290aa7898e1fde7e5adbfc60b1::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit978a84f91f7d9c390e02e0746cd635ac::getInitializer($loader));

$loader->setClassMapAuthoritative(true);
$loader->register(true);

$filesToLoad = \Composer\Autoload\ComposerStaticInitb29d4c290aa7898e1fde7e5adbfc60b1::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit978a84f91f7d9c390e02e0746cd635ac::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInitb29d4c290aa7898e1fde7e5adbfc60b1
class ComposerStaticInit978a84f91f7d9c390e02e0746cd635ac
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
Expand Down Expand Up @@ -3021,9 +3021,9 @@ class ComposerStaticInitb29d4c290aa7898e1fde7e5adbfc60b1
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitb29d4c290aa7898e1fde7e5adbfc60b1::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitb29d4c290aa7898e1fde7e5adbfc60b1::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitb29d4c290aa7898e1fde7e5adbfc60b1::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit978a84f91f7d9c390e02e0746cd635ac::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit978a84f91f7d9c390e02e0746cd635ac::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit978a84f91f7d9c390e02e0746cd635ac::$classMap;

}, null, ClassLoader::class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class ResourceCheckerConfigCacheFactory implements ConfigCacheFactoryInterface
{
/**
* @var mixed[]
* @var iterable
*/
private $resourceCheckers = [];
/**
Expand Down
2 changes: 1 addition & 1 deletion vendor/symfony/console/Output/ConsoleSectionOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function clear(int $lines = null)
* Overwrites the previous output with a new message.
*
* @return void
* @param string|mixed[] $message
* @param string|iterable $message
*/
public function overwrite($message)
{
Expand Down
4 changes: 2 additions & 2 deletions vendor/symfony/console/Output/NullOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ public function isDebug() : bool
}
/**
* @return void
* @param string|mixed[] $messages
* @param string|iterable $messages
*/
public function writeln($messages, int $options = self::OUTPUT_NORMAL)
{
// do nothing
}
/**
* @return void
* @param string|mixed[] $messages
* @param string|iterable $messages
*/
public function write($messages, bool $newline = \false, int $options = self::OUTPUT_NORMAL)
{
Expand Down
4 changes: 2 additions & 2 deletions vendor/symfony/console/Output/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ public function isDebug() : bool
}
/**
* @return void
* @param string|mixed[] $messages
* @param string|iterable $messages
*/
public function writeln($messages, int $options = self::OUTPUT_NORMAL)
{
$this->write($messages, \true, $options);
}
/**
* @return void
* @param string|mixed[] $messages
* @param string|iterable $messages
*/
public function write($messages, bool $newline = \false, int $options = self::OUTPUT_NORMAL)
{
Expand Down
4 changes: 2 additions & 2 deletions vendor/symfony/console/Output/OutputInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface OutputInterface
* 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL
*
* @return void
* @param string|mixed[] $messages
* @param string|iterable $messages
*/
public function write($messages, bool $newline = \false, int $options = 0);
/**
Expand All @@ -44,7 +44,7 @@ public function write($messages, bool $newline = \false, int $options = 0);
* 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL
*
* @return void
* @param string|mixed[] $messages
* @param string|iterable $messages
*/
public function writeln($messages, int $options = 0);
/**
Expand Down
4 changes: 2 additions & 2 deletions vendor/symfony/console/Style/OutputStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ public function createProgressBar(int $max = 0) : ProgressBar
}
/**
* @return void
* @param string|mixed[] $messages
* @param string|iterable $messages
*/
public function write($messages, bool $newline = \false, int $type = self::OUTPUT_NORMAL)
{
$this->output->write($messages, $newline, $type);
}
/**
* @return void
* @param string|mixed[] $messages
* @param string|iterable $messages
*/
public function writeln($messages, int $type = self::OUTPUT_NORMAL)
{
Expand Down
4 changes: 2 additions & 2 deletions vendor/symfony/console/Style/SymfonyStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public function askQuestion(Question $question)
}
/**
* @return void
* @param string|mixed[] $messages
* @param string|iterable $messages
*/
public function writeln($messages, int $type = self::OUTPUT_NORMAL)
{
Expand All @@ -355,7 +355,7 @@ public function writeln($messages, int $type = self::OUTPUT_NORMAL)
}
/**
* @return void
* @param string|mixed[] $messages
* @param string|iterable $messages
*/
public function write($messages, bool $newline = \false, int $type = self::OUTPUT_NORMAL)
{
Expand Down
16 changes: 8 additions & 8 deletions vendor/symfony/filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function copy(string $originFile, string $targetFile, bool $overwriteNewe
* @return void
*
* @throws IOException On any directory creation failure
* @param string|mixed[] $dirs
* @param string|iterable $dirs
*/
public function mkdir($dirs, int $mode = 0777)
{
Expand All @@ -90,7 +90,7 @@ public function mkdir($dirs, int $mode = 0777)
}
/**
* Checks the existence of files or directories.
* @param string|mixed[] $files
* @param string|iterable $files
*/
public function exists($files) : bool
{
Expand All @@ -114,7 +114,7 @@ public function exists($files) : bool
* @return void
*
* @throws IOException When touch fails
* @param string|mixed[] $files
* @param string|iterable $files
*/
public function touch($files, int $time = null, int $atime = null)
{
Expand All @@ -130,7 +130,7 @@ public function touch($files, int $time = null, int $atime = null)
* @return void
*
* @throws IOException When removal fails
* @param string|mixed[] $files
* @param string|iterable $files
*/
public function remove($files)
{
Expand Down Expand Up @@ -190,7 +190,7 @@ private static function doRemove(array $files, bool $isRecursive) : void
* @return void
*
* @throws IOException When the change fails
* @param string|mixed[] $files
* @param string|iterable $files
*/
public function chmod($files, int $mode, int $umask = 00, bool $recursive = \false)
{
Expand All @@ -212,7 +212,7 @@ public function chmod($files, int $mode, int $umask = 00, bool $recursive = \fal
* @return void
*
* @throws IOException When the change fails
* @param string|mixed[] $files
* @param string|iterable $files
*/
public function chown($files, $user, bool $recursive = \false)
{
Expand Down Expand Up @@ -240,7 +240,7 @@ public function chown($files, $user, bool $recursive = \false)
* @return void
*
* @throws IOException When the change fails
* @param string|mixed[] $files
* @param string|iterable $files
*/
public function chgrp($files, $group, bool $recursive = \false)
{
Expand Down Expand Up @@ -622,7 +622,7 @@ public function appendToFile(string $filename, $content)
}
}
/**
* @param string|mixed[] $files
* @param string|iterable $files
*/
private function toIterable($files) : iterable
{
Expand Down
10 changes: 5 additions & 5 deletions vendor/symfony/string/ByteString.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function chunk(int $length = 1) : array
return $chunks;
}
/**
* @param string|mixed[]|\Symfony\Component\String\AbstractString $suffix
* @param string|iterable|\Symfony\Component\String\AbstractString $suffix
*/
public function endsWith($suffix) : bool
{
Expand All @@ -129,7 +129,7 @@ public function endsWith($suffix) : bool
return '' !== $suffix && \strlen($this->string) >= \strlen($suffix) && 0 === \substr_compare($this->string, $suffix, -\strlen($suffix), null, $this->ignoreCase);
}
/**
* @param string|mixed[]|\Symfony\Component\String\AbstractString $string
* @param string|iterable|\Symfony\Component\String\AbstractString $string
*/
public function equalsTo($string) : bool
{
Expand All @@ -153,7 +153,7 @@ public function folded()
return $str;
}
/**
* @param string|mixed[]|\Symfony\Component\String\AbstractString $needle
* @param string|iterable|\Symfony\Component\String\AbstractString $needle
*/
public function indexOf($needle, int $offset = 0) : ?int
{
Expand All @@ -169,7 +169,7 @@ public function indexOf($needle, int $offset = 0) : ?int
return \false === $i ? null : $i;
}
/**
* @param string|mixed[]|\Symfony\Component\String\AbstractString $needle
* @param string|iterable|\Symfony\Component\String\AbstractString $needle
*/
public function indexOfLast($needle, int $offset = 0) : ?int
{
Expand Down Expand Up @@ -362,7 +362,7 @@ public function split(string $delimiter, int $limit = null, int $flags = null) :
return $chunks;
}
/**
* @param string|mixed[]|\Symfony\Component\String\AbstractString $prefix
* @param string|iterable|\Symfony\Component\String\AbstractString $prefix
*/
public function startsWith($prefix) : bool
{
Expand Down
Loading

0 comments on commit ddde48c

Please sign in to comment.