diff --git a/config/drupal-9/drupal-9.3-deprecations.php b/config/drupal-9/drupal-9.3-deprecations.php index 5289e421..45ee406b 100644 --- a/config/drupal-9/drupal-9.3-deprecations.php +++ b/config/drupal-9/drupal-9.3-deprecations.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use DrupalRector\Drupal8\Rector\ValueObject\ConstantToClassConfiguration; use DrupalRector\Drupal9\Rector\Deprecation\ExtensionPathRector; use DrupalRector\Drupal9\Rector\Deprecation\FileBuildUriRector; use DrupalRector\Drupal9\Rector\Deprecation\FunctionToEntityTypeStorageMethod; @@ -66,4 +67,11 @@ new FunctionToFirstArgMethodConfiguration('taxonomy_term_uri', 'toUrl'), new FunctionToFirstArgMethodConfiguration('taxonomy_term_title', 'label'), ]); + + // Change record: https://www.drupal.org/node/3022147 + new ConstantToClassConfiguration( + 'FILE_STATUS_PERMANENT', + 'Drupal\file\FileInterface', + 'STATUS_PERMANENT', + ); }; diff --git a/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/config/configured_rule.php b/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/config/configured_rule.php index c43f965a..aeec0664 100644 --- a/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/config/configured_rule.php +++ b/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/config/configured_rule.php @@ -15,4 +15,11 @@ 'STORAGE_TIMEZONE', ), ]); + DeprecationBase::addClass(ConstantToClassConstantRector::class, $rectorConfig, false, [ + new ConstantToClassConfiguration( + 'FILE_STATUS_PERMANENT', + 'Drupal\file\FileInterface', + 'STATUS_PERMANENT', + ), + ]); }; diff --git a/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc b/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc index d10ece7c..c49f064a 100644 --- a/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc +++ b/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc @@ -2,20 +2,42 @@ function simple_example() { $timezone = DATETIME_STORAGE_TIMEZONE; + + $file_status = FILE_STATUS_PERMANENT; } function as_an_argument() { $timezone = new \DateTimeZone(DATETIME_STORAGE_TIMEZONE); + + $class = new \TestClass(FILE_STATUS_PERMANENT); } + +class ClassDefault { + public function test($status = FILE_STATUS_PERMANENT) { + return true; + } +} + ?> -----