Skip to content

Commit

Permalink
Updated Rector to commit 055ab62e3fa14a1aaccd2a5e7f2a9fd354fbd600
Browse files Browse the repository at this point in the history
rectorphp/rector-src@055ab62 Fix annotation to attribute parsing string (#5317)
  • Loading branch information
TomasVotruba committed Dec 3, 2023
1 parent e7fa7d1 commit 7124cd0
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 15 deletions.
4 changes: 2 additions & 2 deletions config/set/php83.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare (strict_types=1);
namespace RectorPrefix202312;

use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
use Rector\Php83\Rector\ClassConst\AddTypeToConstRector;
use Rector\Config\RectorConfig;
use Rector\Php83\Rector\ClassConst\AddTypeToConstRector;
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rules([AddOverrideAttributeToOverriddenMethodsRector::class, AddTypeToConstRector::class]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ public function parseValue(BetterTokenIterator $tokenIterator, Node $currentPhpN
if ($constExprNode instanceof ConstExprNode) {
return $constExprNode;
}
while ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_DOUBLE_COLON) || $tokenIterator->isCurrentTokenType(Lexer::TOKEN_IDENTIFIER)) {
$currentTokenValue .= $tokenIterator->currentTokenValue();
$tokenIterator->next();
}
$currentTokenValue = $this->parseStringValue($tokenIterator, $currentTokenValue);
// nested entity!, supported in attribute since PHP 8.1
if ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_OPEN_PARENTHESES)) {
return $this->parseNestedDoctrineAnnotationTagValueNode($currentTokenValue, $tokenIterator, $currentPhpNode);
Expand All @@ -82,6 +79,38 @@ public function parseValue(BetterTokenIterator $tokenIterator, Node $currentPhpN
}
return $currentTokenValue;
}
private function parseStringValue(BetterTokenIterator $tokenIterator, string $currentTokenValue) : string
{
if (\strncmp($currentTokenValue, '"', \strlen('"')) === 0 && \substr_compare($currentTokenValue, '"', -\strlen('"')) !== 0) {
$currentTokenValue = $this->parseMultilineOrWhiteSpacedString($tokenIterator, $currentTokenValue);
} else {
while ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_DOUBLE_COLON) || $tokenIterator->isCurrentTokenType(Lexer::TOKEN_IDENTIFIER)) {
$currentTokenValue .= $tokenIterator->currentTokenValue();
$tokenIterator->next();
}
}
return $currentTokenValue;
}
private function parseMultilineOrWhiteSpacedString(BetterTokenIterator $tokenIterator, string $currentTokenValue) : string
{
while (\strncmp($currentTokenValue, '"', \strlen('"')) === 0 && \substr_compare($currentTokenValue, '"', -\strlen('"')) !== 0) {
if (!$tokenIterator->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL)) {
$currentTokenValue .= ' ';
}
if (\strncmp($currentTokenValue, '"', \strlen('"')) === 0 && \strpos($tokenIterator->currentTokenValue(), '"') !== \false && $currentTokenValue !== $tokenIterator->currentTokenValue()) {
//starts with '"' and current token contains '"', should be the end
$currentTokenValue .= \substr($tokenIterator->currentTokenValue(), 0, (int) \strpos($tokenIterator->currentTokenValue(), '"') + 1);
$tokenIterator->next();
break;
}
$currentTokenValue .= $tokenIterator->currentTokenValue();
$tokenIterator->next();
}
if (\strncmp($currentTokenValue, '"', \strlen('"')) === 0 && \substr_compare($currentTokenValue, '"', -\strlen('"')) === 0) {
return \trim(\str_replace('"', '', $currentTokenValue));
}
return $currentTokenValue;
}
private function parseNestedDoctrineAnnotationTagValueNode(string $currentTokenValue, BetterTokenIterator $tokenIterator, Node $currentPhpNode) : DoctrineAnnotationTagValueNode
{
// @todo
Expand Down
14 changes: 7 additions & 7 deletions rules/Php83/Rector/ClassConst/AddTypeToConstRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
declare (strict_types=1);
namespace Rector\Php83\Rector\ClassConst;

use PhpParser\Node\Stmt\ClassConst;
use PhpParser\Node\Identifier;
use PhpParser\Node;
use PhpParser\Node\Const_;
use PhpParser\Node\Expr;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\DNumber;
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Scalar\DNumber;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassConst;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\MissingConstantFromReflectionException;
use PHPStan\Reflection\ReflectionProvider;
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 = '18617f9880d098bceae210512c190c8d44aa7811';
public const PACKAGE_VERSION = '055ab62e3fa14a1aaccd2a5e7f2a9fd354fbd600';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-12-03 17:54:43';
public const RELEASE_DATE = '2023-12-03 17:38:20';
/**
* @var int
*/
Expand Down

0 comments on commit 7124cd0

Please sign in to comment.