Skip to content

Commit

Permalink
use stubs for Then and When
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Dec 11, 2024
1 parent 33d12b7 commit 1c27344
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Fixture\Behat;

final class WithNextLine
{
/**
* @Then then :value should \
* continue here
*/
public function someStep(): void
{
}
}

?>
-----
<?php

namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Fixture\Behat;

final class WithNextLine
{
#[\Behat\Step\Then('then :value should continue here')]
public function someStep(): void
{
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Fixture\Behat;

final class WithValueEdgeCases
{
/**
* @Then then :value should be have been finished
*/
public function someStep(): void
{
}
}

?>
-----
<?php

namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Fixture\Behat;

final class WithValueEdgeCases
{
#[\Behat\Step\Then('then :value should be have been finished')]
public function someStep(): void
{
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Fixture;

final class WithValueAsArgument
{
#[\Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\Attribute\Behat\When('this is a simple annotation with a value')]
#[\Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\Attribute\Behat\When]
#[\Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\Attribute\Behat\When('"this value is within quotes"')]
#[\Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\Attribute\Behat\When('this value has a \' character')]
#[\Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\Attribute\Behat\When(key: 'value')] // this annotation has parameters so won't use this option
#[\Behat\Step\When('this is a simple annotation with a value')]
#[\Behat\Step\When]
#[\Behat\Step\When('"this value is within quotes"')]
#[\Behat\Step\When('this value has a \' character')]
#[\Behat\Step\When(key: 'value')] // this annotation has parameters so won't use this option
public function someStep(): void
{
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Rector\Php80\ValueObject\AnnotationToAttribute;
use Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\Annotation\OpenApi\Annotation\NestedPastAnnotation;
use Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\Annotation\OpenApi\PastAnnotation;
use Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\Attribute\Behat\When;
use Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\Attribute\OpenApi\Attribute\NestedFutureAttribute;
use Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\Attribute\OpenApi\FutureAttribute;
use Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\GenericAnnotation;
Expand Down Expand Up @@ -48,6 +47,9 @@
'Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\UseAlias\TestOther'
),
new AnnotationToAttribute('Sensio\Bundle\FrameworkExtraBundle\Configuration\Security'),
new AnnotationToAttribute('When', When::class, useValueAsAttributeArgument: true),

// special case with following comment becoming a inner value
new AnnotationToAttribute('When', \Behat\Step\When::class, useValueAsAttributeArgument: true),
new AnnotationToAttribute('Then', \Behat\Step\Then::class, useValueAsAttributeArgument: true),
]);
};
12 changes: 12 additions & 0 deletions stubs/Behat/Step/Then.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Behat\Step;

if (class_exists('Behat\Step\Then')) {
return;
}

class Then
{

}
12 changes: 12 additions & 0 deletions stubs/Behat/Step/When.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Behat\Step;

if (class_exists('Behat\Step\When')) {
return;
}

class When
{

}

0 comments on commit 1c27344

Please sign in to comment.