Skip to content

Commit

Permalink
Updated Rector to commit 1ed4cf9c87b9898148161af76fec9274083d9a27
Browse files Browse the repository at this point in the history
rectorphp/rector-src@1ed4cf9 Make use of toPhpDocNode() - take #3 (#4557)
  • Loading branch information
TomasVotruba committed Jul 20, 2023
1 parent a40539c commit b74932f
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,17 @@

use PhpParser\Node;
use PhpParser\Node\Identifier;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\CallableType;
use PHPStan\Type\ClosureType;
use PHPStan\Type\Type;
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode;
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
use Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper;
use RectorPrefix202307\Symfony\Contracts\Service\Attribute\Required;
/**
* @implements TypeMapperInterface<CallableType>
*/
final class CallableTypeMapper 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,8 +28,7 @@ public function getNodeClass() : string
*/
public function mapToPHPStanPhpDocTypeNode(Type $type) : TypeNode
{
$returnTypeNode = $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($type->getReturnType());
return new SpacingAwareCallableTypeNode(new IdentifierTypeNode('callable'), [], $returnTypeNode);
return $type->toPhpDocNode();
}
/**
* @param TypeKind::* $typeKind
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

use PhpParser\Node;
use PhpParser\Node\Identifier;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\MixedType;
use PHPStan\Type\Type;
Expand Down Expand Up @@ -38,7 +37,7 @@ public function getNodeClass() : string
*/
public function mapToPHPStanPhpDocTypeNode(Type $type) : TypeNode
{
return new IdentifierTypeNode('mixed');
return $type->toPhpDocNode();
}
/**
* @param MixedType $type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;

use PhpParser\Node;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\NeverType;
use PHPStan\Type\Type;
Expand All @@ -26,7 +25,7 @@ public function getNodeClass() : string
*/
public function mapToPHPStanPhpDocTypeNode(Type $type) : TypeNode
{
return new IdentifierTypeNode('never');
return $type->toPhpDocNode();
}
/**
* @param NeverType $type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@

use PhpParser\Node;
use PhpParser\Node\Identifier;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\Accessory\NonEmptyArrayType;
use PHPStan\Type\Type;
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode;
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
/**
* @implements TypeMapperInterface<NonEmptyArrayType>
Expand All @@ -28,7 +26,7 @@ public function getNodeClass() : string
*/
public function mapToPHPStanPhpDocTypeNode(Type $type) : TypeNode
{
return new SpacingAwareArrayTypeNode(new IdentifierTypeNode('mixed'));
return $type->toPhpDocNode();
}
/**
* @param NonEmptyArrayType $type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

use PhpParser\Node;
use PhpParser\Node\Identifier;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\NullType;
use PHPStan\Type\Type;
Expand All @@ -28,7 +27,7 @@ public function getNodeClass() : string
*/
public function mapToPHPStanPhpDocTypeNode(Type $type) : TypeNode
{
return new IdentifierTypeNode('null');
return $type->toPhpDocNode();
}
/**
* @param TypeKind::* $typeKind
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

use PhpParser\Node;
use PhpParser\Node\Identifier;
use PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\Accessory\OversizedArrayType;
use PHPStan\Type\Type;
Expand All @@ -29,7 +27,7 @@ public function getNodeClass() : string
*/
public function mapToPHPStanPhpDocTypeNode(Type $type) : TypeNode
{
return new ArrayTypeNode(new IdentifierTypeNode('mixed'));
return $type->toPhpDocNode();
}
/**
* @param TypeKind::* $typeKind
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

use PhpParser\Node;
use PhpParser\Node\Name;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\Type;
use Rector\Core\Enum\ObjectReference;
Expand All @@ -28,7 +27,7 @@ public function getNodeClass() : string
*/
public function mapToPHPStanPhpDocTypeNode(Type $type) : TypeNode
{
return new IdentifierTypeNode(ObjectReference::PARENT);
return $type->toPhpDocNode();
}
/**
* @param ParentStaticType $type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;

use PhpParser\Node;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\ResourceType;
use PHPStan\Type\Type;
Expand All @@ -26,7 +25,7 @@ public function getNodeClass() : string
*/
public function mapToPHPStanPhpDocTypeNode(Type $type) : TypeNode
{
return new IdentifierTypeNode('resource');
return $type->toPhpDocNode();
}
/**
* @param ResourceType $type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

use PhpParser\Node;
use PhpParser\Node\Name;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\Type;
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
Expand All @@ -27,7 +26,7 @@ public function getNodeClass() : string
*/
public function mapToPHPStanPhpDocTypeNode(Type $type) : TypeNode
{
return new IdentifierTypeNode('self');
return $type->toPhpDocNode();
}
/**
* @param SelfObjectType $type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

use PhpParser\Node;
use PhpParser\Node\Identifier;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\StrictMixedType;
use PHPStan\Type\Type;
Expand All @@ -31,7 +30,7 @@ public function getNodeClass() : string
*/
public function mapToPHPStanPhpDocTypeNode(Type $type) : TypeNode
{
return new IdentifierTypeNode(self::MIXED);
return $type->toPhpDocNode();
}
/**
* @param StrictMixedType $type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

use PhpParser\Node;
use PhpParser\Node\Identifier;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\Type;
use PHPStan\Type\TypeWithClassName;
Expand Down Expand Up @@ -38,7 +37,7 @@ public function getNodeClass() : string
*/
public function mapToPHPStanPhpDocTypeNode(Type $type) : TypeNode
{
return new IdentifierTypeNode('string-class');
return $type->toPhpDocNode();
}
/**
* @param TypeWithClassName $type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

use PhpParser\Node;
use PhpParser\Node\Identifier;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\Type;
use PHPStan\Type\VoidType;
Expand Down Expand Up @@ -43,7 +42,7 @@ public function getNodeClass() : string
*/
public function mapToPHPStanPhpDocTypeNode(Type $type) : TypeNode
{
return new IdentifierTypeNode(self::VOID);
return $type->toPhpDocNode();
}
/**
* @param TypeKind::* $typeKind
Expand Down
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 = 'f403ca026144fc810918f6eb6178ea88f16c0641';
public const PACKAGE_VERSION = '1ed4cf9c87b9898148161af76fec9274083d9a27';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-07-21 04:05:33';
public const RELEASE_DATE = '2023-07-20 22:52:16';
/**
* @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 ComposerAutoloaderInitcecd0c80d627eae86703ca38e6153385::getLoader();
return ComposerAutoloaderInit35df304764cc0d55582e1cf57cf66250::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 ComposerAutoloaderInitcecd0c80d627eae86703ca38e6153385
class ComposerAutoloaderInit35df304764cc0d55582e1cf57cf66250
{
private static $loader;

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

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

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

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

$filesToLoad = \Composer\Autoload\ComposerStaticInitcecd0c80d627eae86703ca38e6153385::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit35df304764cc0d55582e1cf57cf66250::$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 ComposerStaticInitcecd0c80d627eae86703ca38e6153385
class ComposerStaticInit35df304764cc0d55582e1cf57cf66250
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
Expand Down Expand Up @@ -3023,9 +3023,9 @@ class ComposerStaticInitcecd0c80d627eae86703ca38e6153385
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitcecd0c80d627eae86703ca38e6153385::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitcecd0c80d627eae86703ca38e6153385::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitcecd0c80d627eae86703ca38e6153385::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit35df304764cc0d55582e1cf57cf66250::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit35df304764cc0d55582e1cf57cf66250::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit35df304764cc0d55582e1cf57cf66250::$classMap;

}, null, ClassLoader::class);
}
Expand Down

0 comments on commit b74932f

Please sign in to comment.