Updated Rector to commit c2c6558cde8138d5509b306bd499e013ac5da2e9

c2c6558cde [TypeDeclaration] Allow add void return type on magic __invoke() method on AddVoidReturnTypeWhereNoReturnRector (#5376)
This commit is contained in:
Tomas Votruba 2023-12-22 17:39:40 +00:00
parent 4e82e891c9
commit 1ce9a4da5a
10 changed files with 179 additions and 28 deletions

View File

@ -9,6 +9,7 @@ use PhpParser\Node\Identifier;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
use PHPStan\Reflection\ClassReflection;
use Rector\Core\NodeAnalyzer\MagicClassMethodAnalyzer;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\Reflection\ReflectionResolver;
use Rector\Core\ValueObject\PhpVersionFeature;
@ -37,11 +38,17 @@ final class AddVoidReturnTypeWhereNoReturnRector extends AbstractRector implemen
* @var \Rector\Core\Reflection\ReflectionResolver
*/
private $reflectionResolver;
public function __construct(SilentVoidResolver $silentVoidResolver, ClassMethodReturnVendorLockResolver $classMethodReturnVendorLockResolver, ReflectionResolver $reflectionResolver)
/**
* @readonly
* @var \Rector\Core\NodeAnalyzer\MagicClassMethodAnalyzer
*/
private $magicClassMethodAnalyzer;
public function __construct(SilentVoidResolver $silentVoidResolver, ClassMethodReturnVendorLockResolver $classMethodReturnVendorLockResolver, ReflectionResolver $reflectionResolver, MagicClassMethodAnalyzer $magicClassMethodAnalyzer)
{
$this->silentVoidResolver = $silentVoidResolver;
$this->classMethodReturnVendorLockResolver = $classMethodReturnVendorLockResolver;
$this->reflectionResolver = $reflectionResolver;
$this->magicClassMethodAnalyzer = $magicClassMethodAnalyzer;
}
public function getRuleDefinition() : RuleDefinition
{
@ -106,7 +113,7 @@ CODE_SAMPLE
if (!$functionLike instanceof ClassMethod) {
return \false;
}
if ($functionLike->isMagic()) {
if ($this->magicClassMethodAnalyzer->isUnsafeOverridden($functionLike)) {
return \true;
}
if ($functionLike->isAbstract()) {

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '7ca4de097ed6b2f0f2b20a8f2b55ea2121120173';
public const PACKAGE_VERSION = 'c2c6558cde8138d5509b306bd499e013ac5da2e9';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-12-21 22:20:06';
public const RELEASE_DATE = '2023-12-23 00:37:23';
/**
* @var int
*/

View File

@ -504,8 +504,8 @@
},
{
"name": "illuminate\/container",
"version": "v10.38.1",
"version_normalized": "10.38.1.0",
"version": "v10.38.2",
"version_normalized": "10.38.2.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/illuminate\/container.git",
@ -561,8 +561,8 @@
},
{
"name": "illuminate\/contracts",
"version": "v10.38.1",
"version_normalized": "10.38.1.0",
"version": "v10.38.2",
"version_normalized": "10.38.2.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/illuminate\/contracts.git",
@ -1945,17 +1945,17 @@
},
{
"name": "sebastian\/diff",
"version": "5.0.3",
"version_normalized": "5.0.3.0",
"version": "5.1.0",
"version_normalized": "5.1.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/sebastianbergmann\/diff.git",
"reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b"
"reference": "fbf413a49e54f6b9b17e12d900ac7f6101591b7f"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/sebastianbergmann\/diff\/zipball\/912dc2fbe3e3c1e7873313cc801b100b6c68c87b",
"reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b",
"url": "https:\/\/api.github.com\/repos\/sebastianbergmann\/diff\/zipball\/fbf413a49e54f6b9b17e12d900ac7f6101591b7f",
"reference": "fbf413a49e54f6b9b17e12d900ac7f6101591b7f",
"shasum": ""
},
"require": {
@ -1965,11 +1965,11 @@
"phpunit\/phpunit": "^10.0",
"symfony\/process": "^4.2 || ^5"
},
"time": "2023-05-01T07:48:21+00:00",
"time": "2023-12-22T10:55:06+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "5.0-dev"
"dev-main": "5.1-dev"
}
},
"installation-source": "dist",
@ -2003,7 +2003,7 @@
"support": {
"issues": "https:\/\/github.com\/sebastianbergmann\/diff\/issues",
"security": "https:\/\/github.com\/sebastianbergmann\/diff\/security\/policy",
"source": "https:\/\/github.com\/sebastianbergmann\/diff\/tree\/5.0.3"
"source": "https:\/\/github.com\/sebastianbergmann\/diff\/tree\/5.1.0"
},
"funding": [
{

File diff suppressed because one or more lines are too long

View File

@ -2,6 +2,26 @@
All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [5.1.0] - 2023-12-22
### Added
* `SebastianBergmann\Diff\Chunk::start()`, `SebastianBergmann\Diff\Chunk::startRange()`, `SebastianBergmann\Diff\Chunk::end()`, `SebastianBergmann\Diff\Chunk::endRange()`, and `SebastianBergmann\Diff\Chunk::lines()`
* `SebastianBergmann\Diff\Diff::from()`, `SebastianBergmann\Diff\Diff::to()`, and `SebastianBergmann\Diff\Diff::chunks()`
* `SebastianBergmann\Diff\Line::content()` and `SebastianBergmann\Diff\Diff::type()`
* `SebastianBergmann\Diff\Line::isAdded()`,`SebastianBergmann\Diff\Line::isRemoved()`, and `SebastianBergmann\Diff\Line::isUnchanged()`
### Changed
* `SebastianBergmann\Diff\Diff` now implements `IteratorAggregate`, iterating over it yields the aggregated `SebastianBergmann\Diff\Chunk` objects
* `SebastianBergmann\Diff\Chunk` now implements `IteratorAggregate`, iterating over it yields the aggregated `SebastianBergmann\Diff\Line` objects
### Deprecated
* `SebastianBergmann\Diff\Chunk::getStart()`, `SebastianBergmann\Diff\Chunk::getStartRange()`, `SebastianBergmann\Diff\Chunk::getEnd()`, `SebastianBergmann\Diff\Chunk::getEndRange()`, and `SebastianBergmann\Diff\Chunk::getLines()`
* `SebastianBergmann\Diff\Diff::getFrom()`, `SebastianBergmann\Diff\Diff::getTo()`, and `SebastianBergmann\Diff\Diff::getChunks()`
* `SebastianBergmann\Diff\Line::getContent()` and `SebastianBergmann\Diff\Diff::getType()`
## [5.0.3] - 2023-05-01
### Changed
@ -104,6 +124,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
* This component is no longer supported on PHP 5.6
[5.1.0]: https://github.com/sebastianbergmann/diff/compare/5.0.3...5.1.0
[5.0.3]: https://github.com/sebastianbergmann/diff/compare/5.0.2...5.0.3
[5.0.2]: https://github.com/sebastianbergmann/diff/compare/5.0.1...5.0.2
[5.0.1]: https://github.com/sebastianbergmann/diff/compare/5.0.0...5.0.1

View File

@ -50,7 +50,7 @@
},
"extra": {
"branch-alias": {
"dev-main": "5.0-dev"
"dev-main": "5.1-dev"
}
}
}

View File

@ -11,7 +11,13 @@ declare (strict_types=1);
*/
namespace RectorPrefix202312\SebastianBergmann\Diff;
final class Chunk
use ArrayIterator;
use IteratorAggregate;
use Traversable;
/**
* @template-implements IteratorAggregate<int, Line>
*/
final class Chunk implements IteratorAggregate
{
/**
* @var int
@ -41,26 +47,26 @@ final class Chunk
$this->endRange = $endRange;
$this->lines = $lines;
}
public function getStart() : int
public function start() : int
{
return $this->start;
}
public function getStartRange() : int
public function startRange() : int
{
return $this->startRange;
}
public function getEnd() : int
public function end() : int
{
return $this->end;
}
public function getEndRange() : int
public function endRange() : int
{
return $this->endRange;
}
/**
* @psalm-return list<Line>
*/
public function getLines() : array
public function lines() : array
{
return $this->lines;
}
@ -76,4 +82,45 @@ final class Chunk
}
$this->lines = $lines;
}
/**
* @deprecated Use start() instead
*/
public function getStart() : int
{
return $this->start;
}
/**
* @deprecated Use startRange() instead
*/
public function getStartRange() : int
{
return $this->startRange;
}
/**
* @deprecated Use end() instead
*/
public function getEnd() : int
{
return $this->end;
}
/**
* @deprecated Use endRange() instead
*/
public function getEndRange() : int
{
return $this->endRange;
}
/**
* @psalm-return list<Line>
*
* @deprecated Use lines() instead
*/
public function getLines() : array
{
return $this->lines;
}
public function getIterator() : Traversable
{
return new ArrayIterator($this->lines);
}
}

View File

@ -11,13 +11,21 @@ declare (strict_types=1);
*/
namespace RectorPrefix202312\SebastianBergmann\Diff;
final class Diff
use ArrayIterator;
use IteratorAggregate;
use Traversable;
/**
* @template-implements IteratorAggregate<int, Chunk>
*/
final class Diff implements IteratorAggregate
{
/**
* @psalm-var non-empty-string
* @var string
*/
private $from;
/**
* @psalm-var non-empty-string
* @var string
*/
private $to;
@ -27,6 +35,8 @@ final class Diff
*/
private $chunks;
/**
* @psalm-param non-empty-string $from
* @psalm-param non-empty-string $to
* @psalm-param list<Chunk> $chunks
*/
public function __construct(string $from, string $to, array $chunks = [])
@ -35,18 +45,24 @@ final class Diff
$this->to = $to;
$this->chunks = $chunks;
}
public function getFrom() : string
/**
* @psalm-return non-empty-string
*/
public function from() : string
{
return $this->from;
}
public function getTo() : string
/**
* @psalm-return non-empty-string
*/
public function to() : string
{
return $this->to;
}
/**
* @psalm-return list<Chunk>
*/
public function getChunks() : array
public function chunks() : array
{
return $this->chunks;
}
@ -57,4 +73,35 @@ final class Diff
{
$this->chunks = $chunks;
}
/**
* @psalm-return non-empty-string
*
* @deprecated
*/
public function getFrom() : string
{
return $this->from;
}
/**
* @psalm-return non-empty-string
*
* @deprecated
*/
public function getTo() : string
{
return $this->to;
}
/**
* @psalm-return list<Chunk>
*
* @deprecated
*/
public function getChunks() : array
{
return $this->chunks;
}
public function getIterator() : Traversable
{
return new ArrayIterator($this->chunks);
}
}

View File

@ -29,10 +29,36 @@ final class Line
$this->type = $type;
$this->content = $content;
}
public function content() : string
{
return $this->content;
}
public function type() : int
{
return $this->type;
}
public function isAdded() : bool
{
return $this->type === self::ADDED;
}
public function isRemoved() : bool
{
return $this->type === self::REMOVED;
}
public function isUnchanged() : bool
{
return $this->type === self::UNCHANGED;
}
/**
* @deprecated
*/
public function getContent() : string
{
return $this->content;
}
/**
* @deprecated
*/
public function getType() : int
{
return $this->type;

View File

@ -12,6 +12,7 @@ declare (strict_types=1);
namespace RectorPrefix202312\SebastianBergmann\Diff;
use function array_pop;
use function assert;
use function count;
use function max;
use function preg_match;
@ -41,6 +42,8 @@ final class Parser
$diffs[] = $diff;
$collected = [];
}
assert(!empty($fromMatch['file']));
assert(!empty($toMatch['file']));
$diff = new Diff($fromMatch['file'], $toMatch['file']);
$i++;
} else {