-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from bluehorndigital/3225019-bump-rector-min
Issue #3225019: Could not process due to Class 'ReflectionUnionType' not found
- Loading branch information
Showing
12 changed files
with
176 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
tests/src/Rector/Deprecation/DrupalSetMessageRector/DrupalSetMessageRectorTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace DrupalRector\Tests\Rector\Deprecation\DrupalSetMessageRector; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
use Symplify\SmartFileSystem\SmartFileInfo; | ||
|
||
class DrupalSetMessageRectorTest extends AbstractRectorTestCase { | ||
|
||
/** | ||
* @covers ::refactor | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(SmartFileInfo $fileInfo): void | ||
{ | ||
$this->doTestFileInfo($fileInfo); | ||
} | ||
|
||
/** | ||
* @return Iterator<SmartFileInfo> | ||
*/ | ||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/fixture'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
// must be implemented | ||
return __DIR__ . '/config/configured_rule.php'; | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
tests/src/Rector/Deprecation/DrupalSetMessageRector/config/configured_rule.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php declare(strict_types=1); | ||
|
||
use DrupalRector\Rector\Deprecation\DrupalSetMessageRector; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$services = $containerConfigurator->services(); | ||
|
||
$services->set(DrupalSetMessageRector::class); | ||
|
||
$parameters = $containerConfigurator->parameters(); | ||
$parameters->set('drupal_rector_notices_as_comments', true); | ||
}; |
19 changes: 19 additions & 0 deletions
19
tests/src/Rector/Deprecation/DrupalSetMessageRector/fixture/all_arguments.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
/** | ||
* An example using all of the arguments. | ||
*/ | ||
function using_all_arguments() { | ||
drupal_set_message('example warning', 'status', TRUE); | ||
} | ||
?> | ||
----- | ||
<?php | ||
|
||
/** | ||
* An example using all of the arguments. | ||
*/ | ||
function using_all_arguments() { | ||
\Drupal::messenger()->addStatus('example warning', TRUE); | ||
} | ||
?> |
19 changes: 19 additions & 0 deletions
19
tests/src/Rector/Deprecation/DrupalSetMessageRector/fixture/basic.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
/** | ||
* A simple example using the minimum number of arguments. | ||
*/ | ||
function simple_example() { | ||
drupal_set_message('example message'); | ||
} | ||
?> | ||
----- | ||
<?php | ||
|
||
/** | ||
* A simple example using the minimum number of arguments. | ||
*/ | ||
function simple_example() { | ||
\Drupal::messenger()->addStatus('example message'); | ||
} | ||
?> |
27 changes: 27 additions & 0 deletions
27
tests/src/Rector/Deprecation/DrupalSetMessageRector/fixture/message_types.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
/** | ||
* Examples that show situations where we define the type of message. | ||
*/ | ||
function message_types() { | ||
drupal_set_message('example error', 'error'); | ||
|
||
drupal_set_message('example status', 'status'); | ||
|
||
drupal_set_message('example warning', 'warning'); | ||
} | ||
?> | ||
----- | ||
<?php | ||
|
||
/** | ||
* Examples that show situations where we define the type of message. | ||
*/ | ||
function message_types() { | ||
\Drupal::messenger()->addError('example error'); | ||
|
||
\Drupal::messenger()->addStatus('example status'); | ||
|
||
\Drupal::messenger()->addWarning('example warning'); | ||
} | ||
?> |
34 changes: 34 additions & 0 deletions
34
tests/src/Rector/Deprecation/DrupalSetMessageRector/fixture/type_as_variable.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/** | ||
* This shows using a variable as the message type. | ||
* | ||
* This is rare, but used in Devel. | ||
*/ | ||
function message_type_as_variable() { | ||
$message = 'example message from variable'; | ||
|
||
$type = 'warning'; | ||
|
||
drupal_set_message($message, $type); | ||
} | ||
?> | ||
----- | ||
<?php | ||
|
||
/** | ||
* This shows using a variable as the message type. | ||
* | ||
* This is rare, but used in Devel. | ||
*/ | ||
function message_type_as_variable() { | ||
$message = 'example message from variable'; | ||
|
||
$type = 'warning'; | ||
|
||
// TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes. | ||
// This needs to be replaced, but Rector was not yet able to replace this because the type of message was set with a variable. If you need to continue to use a variable, you might consider using a switch statement. | ||
// @noRector | ||
drupal_set_message($message, $type); | ||
} | ||
?> |