Skip to content

Commit

Permalink
[DX] Accept Y/y for confirmation of init config (#5616)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Feb 14, 2024
1 parent 82d1e1b commit d62be32
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Expand Up @@ -26,18 +26,18 @@

final readonly class DoctrineAnnotationDecorator implements PhpDocNodeDecoratorInterface
{
/**
* Special short annotations, that are resolved as FQN by Doctrine annotation parser
* @var string[]
*/
private const ALLOWED_SHORT_ANNOTATIONS = ['Target'];

/**
* @see https://regex101.com/r/bGp2V0/2
* @var string
*/
public const LONG_ANNOTATION_REGEX = '#@\\\\(?<class_name>.*?)(?<annotation_content>\(.*?\)|,|\r?\n|$)#';

/**
* Special short annotations, that are resolved as FQN by Doctrine annotation parser
* @var string[]
*/
private const ALLOWED_SHORT_ANNOTATIONS = ['Target'];

/**
* @see https://regex101.com/r/xWaLOz/1
* @var string
Expand Down
3 changes: 2 additions & 1 deletion src/Configuration/ConfigInitializer.php
Expand Up @@ -35,7 +35,8 @@ public function createConfig(string $projectDirectory): void
}

$response = $this->symfonyStyle->ask('No "rector.php" config found. Should we generate it for you?', 'yes');
if ($response !== 'yes') {
// be tolerant about input
if (! in_array($response, ['yes', 'YES', 'y', 'Y'], true)) {
// okay, nothing we can do
return;
}
Expand Down
Expand Up @@ -225,7 +225,10 @@ private function createFromExplicitProperties(
if (! $nestedDoctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
Assert::string($nestedDoctrineAnnotationTagValueNode);

$match = Strings::match($nestedDoctrineAnnotationTagValueNode, DoctrineAnnotationDecorator::LONG_ANNOTATION_REGEX);
$match = Strings::match(
$nestedDoctrineAnnotationTagValueNode,
DoctrineAnnotationDecorator::LONG_ANNOTATION_REGEX
);

if (! isset($match['class_name'])) {
throw new ShouldNotHappenException();
Expand Down

0 comments on commit d62be32

Please sign in to comment.