Skip to content

Commit

Permalink
Updated Rector to commit cf69407e2ff3402abb8a939d79f326f59121b2b4
Browse files Browse the repository at this point in the history
rectorphp/rector-src@cf69407 Fix missing default string in TypedPropertyFromStrictGetterMethodReturnTypeRector (#4885)
  • Loading branch information
TomasVotruba committed Aug 31, 2023
1 parent 92fc179 commit 25e5fba
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
declare (strict_types=1);
namespace Rector\TypeDeclaration\Rector\Property;

use PhpParser\Node\Scalar\String_;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Property;
use PHPStan\Type\MixedType;
use PHPStan\Type\StringType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeCombinator;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
Expand Down Expand Up @@ -116,7 +118,7 @@ public function refactor(Node $node) : ?\PhpParser\Node\Stmt\Class_
continue;
}
$property->type = $propertyTypeNode;
$this->decorateDefaultNull($getterReturnType, $property);
$this->decorateDefaultExpr($getterReturnType, $property);
$this->refactorPhpDoc($property);
$hasChanged = \true;
}
Expand All @@ -129,16 +131,21 @@ public function provideMinPhpVersion() : int
{
return PhpVersionFeature::TYPED_PROPERTIES;
}
private function decorateDefaultNull(Type $propertyType, Property $property) : void
private function decorateDefaultExpr(Type $propertyType, Property $property) : void
{
if (!TypeCombinator::containsNull($propertyType)) {
return;
}
$propertyProperty = $property->props[0];
// already has a default value
if ($propertyProperty->default instanceof Expr) {
return;
}
$propertyProperty->default = $this->nodeFactory->createNull();
if (TypeCombinator::containsNull($propertyType)) {
$propertyProperty->default = $this->nodeFactory->createNull();
return;
}
// set default for string
if ($propertyType instanceof StringType) {
$propertyProperty->default = new String_('');
}
}
private function isConflictingDefaultExprType(Property $property, Type $getterReturnType) : bool
{
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 = '5f52c69ae04c708be50552b165104b4a919a3ff0';
public const PACKAGE_VERSION = 'cf69407e2ff3402abb8a939d79f326f59121b2b4';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-08-30 13:37:21';
public const RELEASE_DATE = '2023-08-31 10:38:28';
/**
* @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 ComposerAutoloaderInita6fbb707638c10e3494096986dd7bd8f::getLoader();
return ComposerAutoloaderInite46103f18a52fefd2d73731998ce322c::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 ComposerAutoloaderInita6fbb707638c10e3494096986dd7bd8f
class ComposerAutoloaderInite46103f18a52fefd2d73731998ce322c
{
private static $loader;

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

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

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

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

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

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

0 comments on commit 25e5fba

Please sign in to comment.