diff --git a/packages/better-php-doc-parser/src/PhpDocNode/Doctrine/Property_/ColumnTagValueNode.php b/packages/better-php-doc-parser/src/PhpDocNode/Doctrine/Property_/ColumnTagValueNode.php index ed1891351492..a7a026222f8d 100644 --- a/packages/better-php-doc-parser/src/PhpDocNode/Doctrine/Property_/ColumnTagValueNode.php +++ b/packages/better-php-doc-parser/src/PhpDocNode/Doctrine/Property_/ColumnTagValueNode.php @@ -4,6 +4,7 @@ namespace Rector\BetterPhpDocParser\PhpDocNode\Doctrine\Property_; +use Nette\Utils\Strings; use Rector\BetterPhpDocParser\PhpDocNode\Doctrine\AbstractDoctrineTagValueNode; final class ColumnTagValueNode extends AbstractDoctrineTagValueNode @@ -58,6 +59,11 @@ final class ColumnTagValueNode extends AbstractDoctrineTagValueNode */ private $options; + /** + * @var bool + */ + private $isNullableUppercase = false; + /** * @param mixed[] $options * @param mixed|null $length @@ -86,6 +92,11 @@ public function __construct( if ($originalContent !== null) { $this->resolveOriginalContentSpacingAndOrder($originalContent); + + $matchIsNullable = Strings::match($originalContent, '#nullable(\s+)?=(\s+)?(?false|true)#si'); + if ($matchIsNullable) { + $this->isNullableUppercase = ctype_upper($matchIsNullable['value']); + } } } @@ -126,7 +137,12 @@ public function __toString(): string } if ($this->nullable !== null) { - $contentItems['nullable'] = sprintf('nullable=%s', $this->nullable ? 'true' : 'false'); + $nullableValue = $this->nullable ? 'true' : 'false'; + if ($this->isNullableUppercase) { + $nullableValue = strtoupper($nullableValue); + } + + $contentItems['nullable'] = sprintf('nullable=%s', $nullableValue); } return $this->printContentItems($contentItems); diff --git a/src/PhpParser/Printer/BetterStandardPrinter.php b/src/PhpParser/Printer/BetterStandardPrinter.php index f2ee7167d014..0ad420a4bfb7 100644 --- a/src/PhpParser/Printer/BetterStandardPrinter.php +++ b/src/PhpParser/Printer/BetterStandardPrinter.php @@ -362,12 +362,9 @@ private function detectTabOrSpaceIndentCharacter(array $stmts): void continue; } - $whitespacesChars = Strings::matchAll($fileInfo->getContents(), '#^( |\t)#m'); - foreach ($whitespacesChars as $whitespacesChar) { - // let the first win - $this->tabOrSpaceIndentCharacter = $whitespacesChar[0]; - break; - } + // tab vs space + $tabIndentChars = Strings::match($fileInfo->getContents(), '#^\t#m'); + $this->tabOrSpaceIndentCharacter = $tabIndentChars[0] ?? ' '; } }