Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/set/behat-annotations-to-attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
new AnnotationToAttribute('AfterScenario', 'Behat\Hook\AfterScenario', useValueAsAttributeArgument: true),
new AnnotationToAttribute('BeforeStep', 'Behat\Hook\BeforeStep', useValueAsAttributeArgument: true),
new AnnotationToAttribute('AfterStep', 'Behat\Hook\AfterStep', useValueAsAttributeArgument: true),
new AnnotationToAttribute('Transform', 'Behat\Transformation\Transform', useValueAsAttributeArgument: true),
]);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

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

final class TransformMethod
{
/**
* @Transform :user
*/
public function transformUser($user)
{
return $user;
}
}

?>
-----
<?php

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

final class TransformMethod
{
#[\Behat\Transformation\Transform(':user')]
public function transformUser($user)
{
return $user;
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Behat\Step\Then;
use Behat\Step\When;
use Behat\Transformation\Transform;
use Rector\Config\RectorConfig;
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
use Rector\Php80\ValueObject\AnnotationToAttribute;
Expand Down Expand Up @@ -62,6 +63,7 @@
// special case with following comment becoming a inner value
new AnnotationToAttribute('When', When::class, useValueAsAttributeArgument: true),
new AnnotationToAttribute('Then', Then::class, useValueAsAttributeArgument: true),
new AnnotationToAttribute('Transform', Transform::class, useValueAsAttributeArgument: true),

// simple tag to attribute
new AnnotationToAttribute('OldName1', NewName1::class),
Expand Down
16 changes: 16 additions & 0 deletions stubs/Behat/Transformation/Transform.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace Behat\Transformation;

use Attribute;

#[Attribute(Attribute::TARGET_METHOD)]
final class Transform
{
public function __construct(
public string $value
) {
}
}