Skip to content

Commit

Permalink
Updated Rector to commit 00a51146a06566467292db72c8e231330c7e41d9
Browse files Browse the repository at this point in the history
rectorphp/rector-src@00a5114 [PHPStanStaticTypeMapper] Allow standalone null type on NullTypeMapper on php 8.2 (#4783)
  • Loading branch information
TomasVotruba committed Aug 14, 2023
1 parent 867dc44 commit 46d23a1
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Rector\Core\Php\PhpVersionProvider;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
/**
* @implements TypeMapperInterface<BooleanType>
*/
Expand Down Expand Up @@ -48,6 +49,9 @@ public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node
if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::SCALAR_TYPES)) {
return null;
}
if ($typeKind !== TypeKind::RETURN) {
return new Identifier('bool');
}
if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::NULL_FALSE_TRUE_STANDALONE_TYPE)) {
return new Identifier('bool');
}
Expand Down
19 changes: 13 additions & 6 deletions packages/PHPStanStaticTypeMapper/TypeMapper/NullTypeMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\NullType;
use PHPStan\Type\Type;
use Rector\Core\Php\PhpVersionProvider;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
/**
* @implements TypeMapperInterface<NullType>
*/
final class NullTypeMapper implements TypeMapperInterface
{
/**
* @readonly
* @var \Rector\Core\Php\PhpVersionProvider
*/
private $phpVersionProvider;
public function __construct(PhpVersionProvider $phpVersionProvider)
{
$this->phpVersionProvider = $phpVersionProvider;
}
/**
* @return class-string<Type>
*/
Expand All @@ -35,14 +46,10 @@ public function mapToPHPStanPhpDocTypeNode(Type $type) : TypeNode
*/
public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node
{
if ($typeKind === TypeKind::PROPERTY) {
return null;
}
if ($typeKind === TypeKind::PARAM) {
if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::NULL_FALSE_TRUE_STANDALONE_TYPE)) {
return null;
}
// return type cannot be only null
if ($typeKind === TypeKind::RETURN) {
if ($typeKind !== TypeKind::RETURN) {
return null;
}
return new Identifier('null');
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 = '6b7aac835934de48c034aa8b2bad886616566e06';
public const PACKAGE_VERSION = '00a51146a06566467292db72c8e231330c7e41d9';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-08-14 07:36:48';
public const RELEASE_DATE = '2023-08-14 10:15:22';
/**
* @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 ComposerAutoloaderInitd0491821a1f961d1d51360ac6370685e::getLoader();
return ComposerAutoloaderInit21b54534f5fb8cd8d9c2ac7277d89990::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 ComposerAutoloaderInitd0491821a1f961d1d51360ac6370685e
class ComposerAutoloaderInit21b54534f5fb8cd8d9c2ac7277d89990
{
private static $loader;

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

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

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

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

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

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

0 comments on commit 46d23a1

Please sign in to comment.