Skip to content

Commit

Permalink
Merge pull request #278 from palantirnet/feature/9.3-FILE_STATUS_PERM…
Browse files Browse the repository at this point in the history
…ANENT

New rector (9.3): Support FILE_STATUS_PERMANENT deprecation
  • Loading branch information
agentrickard authored Dec 27, 2023
2 parents 8910e6d + c13c401 commit f12360f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
8 changes: 8 additions & 0 deletions config/drupal-9/drupal-9.3-deprecations.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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',
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@
'STORAGE_TIMEZONE',
),
]);
DeprecationBase::addClass(ConstantToClassConstantRector::class, $rectorConfig, false, [
new ConstantToClassConfiguration(
'FILE_STATUS_PERMANENT',
'Drupal\file\FileInterface',
'STATUS_PERMANENT',
),
]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

?>
-----
<?php

function simple_example() {
$timezone = \Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface::STORAGE_TIMEZONE;

$file_status = \Drupal\file\FileInterface::STATUS_PERMANENT;
}

function as_an_argument() {
$timezone = new \DateTimeZone(\Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface::STORAGE_TIMEZONE);

$class = new \TestClass(\Drupal\file\FileInterface::STATUS_PERMANENT);
}

class ClassDefault {
public function test($status = \Drupal\file\FileInterface::STATUS_PERMANENT) {
return true;
}
}

?>

0 comments on commit f12360f

Please sign in to comment.