Find the best Rector rule to solve your problem. Searching through 793 rules.
Found 140 rules:
Remove parentheses on new method call with parentheses
-(new Request())->withMethod('GET')->withUri('/hello-world');
+new Request()->withMethod('GET')->withUri('/hello-world');
Add escape argument on CSV function calls
-str_getcsv($string, separator: ',', enclosure: '"');
+str_getcsv($string, separator: ',', enclosure: '"', escape: '\\');
Replace rounding mode constant to RoundMode enum in round()
-round(1.5, 0, PHP_ROUND_HALF_UP);
+round(1.5, 0, RoundingMode::HalfAwayFromZero);
Make implicit nullable param to explicit
-function foo(string $param = null) {}
+function foo(?string $param = null) {}
Replace foreach with boolean assignment + break OR foreach with early return with array_any
-$found = false;
-foreach ($animals as $animal) {
- if (str_starts_with($animal, 'c')) {
- $found = true;
- break;
- }
-}
+$found = array_any($animals, fn($animal) => str_starts_with($animal, 'c'));
Replace foreach with assignment and break with array_find_key
$animals = ['dog', 'cat', 'cow', 'duck', 'goose'];
-$found = null;
-foreach ($animals as $idx => $animal) {
- if (str_starts_with($animal, 'c')) {
- $found = $idx;
- break;
- }
-}
+$found = array_find_key($animals, fn($animal) => str_starts_with($animal, 'c'));
Replace foreach with boolean assignment and break OR foreach with early return with array_all
-$found = true;
-foreach ($animals as $animal) {
- if (!str_starts_with($animal, 'c')) {
- $found = false;
- break;
- }
-}
+$found = array_all($animals, fn($animal) => str_starts_with($animal, 'c'));
Replace foreach with assignment and break with array_find
-$found = null;
-foreach ($animals as $animal) {
- if (str_starts_with($animal, 'c')) {
- $found = $animal;
- break;
- }
-}
+$found = array_find($animals, fn($animal) => str_starts_with($animal, 'c'));
Replace getter/setter with property hook
final class Product
{
- private string $name;
-
- public function getName(): string
+ public string $name
{
- return $this->name;
- }
-
- public function setName(string $name): void
- {
- $this->name = ucfirst($name);
+ get => $this->name;
+ set($value) => $this->name = ucfirst($value);
}
}
Change @deprecated annotation to Deprecated attribute
-/**
- * @deprecated 1.0.0 Use SomeOtherFunction instead
- */
+#[\Deprecated(message: 'Use SomeOtherFunction instead', since: '1.0.0')]
function someFunction()
{
}
Convert setcookie argument to PHP7.3 option array
-setcookie('name', $value, 360);
+setcookie('name', $value, ['expires' => 360]);
Make needles explicit strings
$needle = 5;
-$fivePosition = strpos('725', $needle);
+$fivePosition = strpos('725', (string) $needle);
Escape - in some cases
-preg_match("#[\w-()]#", 'some text');
+preg_match("#[\w\-()]#", 'some text');
Adds JSON_THROW_ON_ERROR to json_encode() and json_decode() to throw JsonException on error
-json_encode($content);
-json_decode($json);
+json_encode($content, JSON_THROW_ON_ERROR);
+json_decode($json, null, 512, JSON_THROW_ON_ERROR);
Change case insensitive constant definition to sensitive one
-define('FOO', 42, true);
+define('FOO', 42);
Change case insensitive constants to sensitive ones
define('FOO', 42, true);
var_dump(FOO);
-var_dump(foo);
+var_dump(FOO);
Changes heredoc/nowdoc that contains closing word to safe wrapper name
-$value = <<<A
+$value = <<<A_WRAP
A
-A
+A_WRAP
Refactor MyCLabs enum fetch to Enum const
-$name = SomeEnum::VALUE()->getKey();
+$name = SomeEnum::VALUE->name;
Refactor Spatie enum method calls
-$value1 = SomeEnum::SOME_CONSTANT()->getValue();
-$value2 = SomeEnum::SOME_CONSTANT()->value;
-$name1 = SomeEnum::SOME_CONSTANT()->getName();
-$name2 = SomeEnum::SOME_CONSTANT()->name;
+$value1 = SomeEnum::SOME_CONSTANT->value;
+$value2 = SomeEnum::SOME_CONSTANT->value;
+$name1 = SomeEnum::SOME_CONSTANT->name;
+$name2 = SomeEnum::SOME_CONSTANT->name;
Remove Reflection::setAccessible() calls
$reflectionProperty = new ReflectionProperty($object, 'property');
-$reflectionProperty->setAccessible(true);
$value = $reflectionProperty->getValue($object);
$reflectionMethod = new ReflectionMethod($object, 'method');
-$reflectionMethod->setAccessible(false);
$reflectionMethod->invoke($object);
Change null to strict string defined function call args
class SomeClass
{
public function run()
{
- preg_split("#a#", null);
+ preg_split("#a#", '');
}
}
Change null to strict int defined preg_split limit arg function call argument
class SomeClass
{
public function run()
{
- preg_split('/\s/', $output, NULL, PREG_SPLIT_NO_EMPTY)
+ preg_split('/\s/', $output, 0, PREG_SPLIT_NO_EMPTY)
}
}
Decorate read-only property with readonly attribute
class SomeClass
{
public function __construct(
- private string $name
+ private readonly string $name
) {
}
public function getName()
{
return $this->name;
}
}
Refactor MyCLabs Enum using constructor for instantiation
-$enum = new Enum($args);
+$enum = Enum::from($args);
Upgrade array callable to first class callable
final class SomeClass
{
public function run()
{
- $name = [$this, 'name'];
+ $name = $this->name(...);
}
public function name()
{
}
}
Refactor Spatie enum class to native Enum
-use \Spatie\Enum\Enum;
-
-/**
- * @method static self draft()
- * @method static self published()
- * @method static self archived()
- */
-class StatusEnum extends Enum
+enum StatusEnum : string
{
+ case DRAFT = 'draft';
+ case PUBLISHED = 'published';
+ case ARCHIVED = 'archived';
}
Refactor MyCLabs enum class to native Enum
-use MyCLabs\Enum\Enum;
-
-final class Action extends Enum
+enum Action : string
{
- private const VIEW = 'view';
- private const EDIT = 'edit';
+ case VIEW = 'view';
+ case EDIT = 'edit';
}
Replace property declaration of new state with direct new
class SomeClass
{
- private Logger $logger;
-
public function __construct(
- ?Logger $logger = null,
+ private ?Logger $logger = new NullLogger,
) {
- $this->logger = $logger ?? new NullLogger;
}
}
constant(Example::class . '::' . $constName) to dynamic class const fetch Example::{$constName}
-constant(Example::class . '::' . $constName);
+Example::{$constName};
Combine separated host and port on ldap_connect() args
-ldap_connect('ldap://ldap.example.com', 389);
+ldap_connect('ldap://ldap.example.com:389');
Replace calls to get_class() and get_parent_class() without arguments with self::class and parent::class
class Example extends StdClass {
public function whoAreYou() {
- return get_class() . ' daughter of ' . get_parent_class();
+ return self::class . ' daughter of ' . parent::class;
}
}
Replace json_decode($json, true) !== null && json_last_error() === JSON_ERROR_NONE with json_validate()
-if (json_decode($json, true) !== null && json_last_error() === JSON_ERROR_NONE) {
+if (json_validate($json)) {
}
Add type to constants based on their value
final class SomeClass
{
- public const TYPE = 'some_type';
+ public const string TYPE = 'some_type';
}
Decorate read-only anonymous class with readonly attribute
-new class
+new readonly class
{
public function __construct(
- private readonly string $name
+ private string $name
) {
}
};
Add override attribute to overridden methods
class ParentClass
{
public function foo()
{
echo 'default';
}
}
final class ChildClass extends ParentClass
{
+ #[\Override]
public function foo()
{
echo 'override default';
}
}
Use foreach() instead of deprecated each()
-while (list($key, $callback) = each($callbacks)) {
+foreach ($callbacks as $key => $callback) {
// ...
}
String asserts must be passed directly to assert()
function nakedAssert()
{
- assert('true === true');
- assert("true === true");
+ assert(true === true);
+ assert(true === true);
}
Make first argument of define() string
class SomeClass
{
public function run(int $a)
{
- define(CONSTANT_2, 'value');
+ define('CONSTANT_2', 'value');
define('CONSTANT', 'value');
}
}
Use $result argument in parse_str() function
-parse_str($this->query);
-$data = get_defined_vars();
+parse_str($this->query, $result);
+$data = $result;
Use anonymous functions instead of deprecated create_function()
class ClassWithCreateFunction
{
public function run()
{
- $callable = create_function('$matches', "return '$delimiter' . strtolower(\$matches[1]);");
+ $callable = function($matches) use ($delimiter) {
+ return $delimiter . strtolower($matches[1]);
+ };
}
}
Null is no more allowed in get_class()
final class SomeClass
{
public function getItem()
{
$value = null;
- return get_class($value);
+ return $value !== null ? get_class($value) : self::class;
}
}
Replace each() assign outside loop
$array = ['b' => 1, 'a' => 2];
-$eachedArray = each($array);
+$eachedArray[1] = current($array);
+$eachedArray['value'] = current($array);
+$eachedArray[0] = key($array);
+$eachedArray['key'] = key($array);
+
+next($array);
each() function is deprecated, use key() and current() instead
-list($key, $callback) = each($callbacks);
+$key = key($callbacks);
+$callback = current($callbacks);
+next($callbacks);
Remove (unset) cast
-$different = (unset) $value;
+$different = null;
-$value = (unset) $value;
+unset($value);
Replace null key in array_key_exists with empty string
-array_key_exists(null, $array);
+array_key_exists('', $array);
Wrap chr() argument with % 256 to avoid deprecated out-of-range integers
-echo chr(300);
+echo chr(300 % 256);
Remove argument by position by function name
-finfo_buffer($finfo, $fileContents, FILEINFO_NONE, []);
+finfo_buffer($finfo, $fileContents, FILEINFO_NONE);
Replace ord($str) with ord($str[0])
-echo ord('abc');
+echo ord('a');
Transform sequential assignments to pipe operator syntax
$value = "hello world";
-$result1 = function1($value);
-$result2 = function2($result1);
-$result = function3($result2);
+$result = $value
+ |> function1(...)
+ |> function2(...)
+ |> function3(...);
Change deprecated semicolon to colon after switch case
switch ($value) {
- case 'baz';
+ case 'baz':
echo 'baz';
}
Replace backticks based with shell_exec() function calls
-$output = `ls -al`;
+$output = shell_exec('ls -al');
echo "<pre>$output</pre>";
Convert multiple nested function calls in single line to |> pipe operator
class SomeClass
{
public function run($input)
{
- $result = trim(strtolower(htmlspecialchars($input)));
+ $result = $input
+ |> htmlspecialchars(...)
+ |> strtolower(...)
+ |> trim(...);
}
}
Change @deprecated annotation to Deprecated attribute
-/**
- * @deprecated 1.0.0 Use SomeOtherConstant instead
- */
+#[\Deprecated(message: 'Use SomeOtherConstant instead', since: '1.0.0')]
const SomeConstant = 'irrelevant';
Change __wakeup() to __unserialize()
class User {
- public function __wakeup() {
+ public function __unserialize(array $data): void{
+ foreach ($data as $property => $value) {
+ if (property_exists($this, $property)) {
+ $this->{$property} = $value;
+ }
+ }
}
}
Change __sleep() to __serialize() with correct return values
class User {
private $id;
private $name;
- public function __sleep() {
- return ['id', 'name'];
+ public function __serialize(): array {
+ return [
+ 'id' => $this->id,
+ 'name' => $this->name,
+ ];
}
}
Replaces null return value with empty array in __debugInfo methods
new class
{
public function __debugInfo() {
- return null;
+ return [];
}
};
Make use of array_first() and array_last()
-echo $array[array_key_first($array)];
-echo $array[array_key_last($array)];
+echo array_first($array);
+echo array_last($array);
Remove extra parameters
-strlen("asdf", 1);
+strlen("asdf");
String cannot be turned into array by assignment anymore
-$string = '';
+$string = [];
$string[] = 1;
Change binary operation between some number + string to PHP 7.1 compatible version
class SomeClass
{
public function run()
{
- $value = 5 + '';
- $value = 5.0 + 'hi';
+ $value = 5 + 0;
+ $value = 5.0 + 0.0;
}
}
Change multiple catch statements of the same exception to a single one | separated
try {
// Some code...
-} catch (ExceptionType1 $exception) {
- $sameCode;
-} catch (ExceptionType2 $exception) {
+} catch (ExceptionType1 | ExceptionType2 $exception) {
$sameCode;
}
Changes is_array + Traversable check to is_iterable
-is_array($foo) || $foo instanceof Traversable;
+is_iterable($foo);
Change list() to array destruct
class SomeClass
{
public function run()
{
- list($id1, $name1) = $data;
+ [$id1, $name1] = $data;
- foreach ($data as list($id, $name)) {
+ foreach ($data as [$id, $name]) {
}
}
}
Convert dirname(__FILE__) to __DIR__
class SomeClass
{
public function run()
{
- return dirname(__FILE__);
+ return __DIR__;
}
}
Rename old $HTTP_* variable names to new replacements
-$serverVars = $HTTP_SERVER_VARS;
+$serverVars = $_SERVER;
Use ?: instead of ?, where useful
function elvis()
{
- $value = $a ? $a : false;
+ $value = $a ?: false;
}
Change property modifier from var to public
final class SomeController
{
- var $name = 'Tom';
+ public $name = 'Tom';
}
Use break instead of continue in switch statements
function some_run($value)
{
switch ($value) {
case 1:
echo 'Hi';
- continue;
+ break;
case 2:
echo 'Hello';
break;
}
}
Change typehint from Exception to Throwable
-function handler(Exception $exception) { ... }
+function handler(Throwable $exception) { ... }
set_exception_handler('handler');
Changes $this->call() to static method to static call
class SomeClass
{
public static function run()
{
- $this->eat();
+ static::eat();
}
public static function eat()
{
}
}
Changes ereg*() to preg*() calls
-ereg("hi")
+preg_match("#hi#");
Changes call_user_method()/call_user_method_array() to call_user_func()/call_user_func_array()
-call_user_method($method, $obj, "arg1", "arg2");
+call_user_func(array(&$obj, "method"), "arg1", "arg2");
Renames mktime() without arguments to time()
class SomeClass
{
public function run()
{
$time = mktime(1, 2, 3);
- $nextTime = mktime();
+ $nextTime = time();
}
}
Changes multiple dirname() calls to one with nesting level
-dirname(dirname($path));
+dirname($path, 2);
Changes rand, srand, and getrandmax to newer alternatives
-rand();
+random_int();
Changes static call to instance call, where not useful
class Something
{
public function doWork()
{
}
}
class Another
{
public function run()
{
- return Something::doWork();
+ return (new Something)->doWork();
}
}
list() assigns variables in reverse order - relevant in array assign
-list($a[], $a[]) = [1, 2];
+list($a[], $a[]) = array_reverse([1, 2]);
list() cannot split string directly anymore, use str_split()
-list($foo) = "string";
+list($foo) = str_split("string");
Ensure variable variables are wrapped in curly braces
function run($foo)
{
- global $$foo->bar;
+ global ${$foo->bar};
}
Convert break outside for/foreach/switch context to return
class SomeClass
{
public function run()
{
if ($isphp5)
return 1;
else
return 2;
- break;
+ return;
}
}
Change if with isset and return to coalesce
class SomeClass
{
private $items = [];
public function resolve($key)
{
- if (isset($this->items[$key])) {
- return $this->items[$key];
- }
-
- return 'fallback value';
+ return $this->items[$key] ?? 'fallback value';
}
}
Use <=> spaceship instead of ternary with same effect
function order_func($a, $b) {
- return ($a < $b) ? -1 : (($a > $b) ? 1 : 0);
+ return $a <=> $b;
}
Changes unneeded null check to ?? operator
-$value === null ? 10 : $value;
+$value ?? 10;
Remove first default switch, that is ignored
switch ($expr) {
default:
- echo "Hello World";
-
- default:
echo "Goodbye Moon!";
break;
}
list() cannot be empty
-'list() = $values;'
+'list($unusedGenerated) = $values;'
Changes if/else to spaceship <=> where useful
usort($languages, function ($first, $second) {
-if ($first[0] === $second[0]) {
- return 0;
-}
-
-return ($first[0] < $second[0]) ? 1 : -1;
+return $second[0] <=> $first[0];
});
Change PHP 4 style constructor to __construct
class SomeClass
{
- public function SomeClass()
+ public function __construct()
{
}
}
Convert closure with sole nested call to first class callable
-function ($parameter) {
- return AnotherClass::someMethod($parameter);
-}
+AnotherClass::someMethod(...);
Changes various implode forms to consistent one
class SomeClass
{
public function run(array $items)
{
- $itemsAsStrings = implode($items);
- $itemsAsStrings = implode($items, '|');
+ $itemsAsStrings = implode('', $items);
+ $itemsAsStrings = implode('|', $items);
}
}
Upgrade string callback functions to first class callable
final class SomeClass
{
public function run(array $data)
{
- return array_map('trim', $data);
+ return array_map(trim(...), $data);
}
}
Change Closure::fromCallable() to first class callable syntax
-Closure::fromCallable([$obj, 'method']);
+$obj->method(...);
Convert nested arrow function call to first class callable
-fn ($parameter) => Call::to($parameter);
+Call::to(...);
Change closure to arrow function
class SomeClass
{
public function run($meetups)
{
- return array_filter($meetups, function (Meetup $meetup) {
- return is_object($meetup);
- });
+ return array_filter($meetups, fn(Meetup $meetup) => is_object($meetup));
}
}
Change filter_var() with slash escaping to addslashes()
$var= "Satya's here!";
-filter_var($var, FILTER_SANITIZE_MAGIC_QUOTES);
+addslashes($var);
Change money_format() to equivalent number_format()
-$value = money_format('%i', $value);
+$value = number_format(round($value, 2, PHP_ROUND_HALF_ODD), 2, '.', '');
Change mb_strrpos() encoding argument position
-mb_strrpos($text, "abc", "UTF-8");
+mb_strrpos($text, "abc", 0, "UTF-8");
Change hebrevc($str) to nl2br(hebrev($str))
-hebrevc($str);
+nl2br(hebrev($str));
Change array_key_exists() on property to property_exists()
class SomeClass
{
public $value;
}
$someClass = new SomeClass;
-array_key_exists('value', $someClass);
+property_exists($someClass, 'value');
Change restore_include_path() to ini_restore("include_path")
-restore_include_path();
+ini_restore('include_path');
Change export() to ReflectionFunction alternatives
-$reflectionFunction = ReflectionFunction::export('foo');
-$reflectionFunctionAsString = ReflectionFunction::export('foo', true);
+$reflectionFunction = new ReflectionFunction('foo');
+$reflectionFunctionAsString = (string) new ReflectionFunction('foo');
Add null default to properties with PHP 7.4 property nullable type
class SomeClass
{
- public ?string $name;
+ public ?string $name = null;
}
Use null coalescing operator ??=
$array = [];
-$array['user_id'] = $array['user_id'] ?? 'value';
+$array['user_id'] ??= 'value';
Add parentheses to nested ternary
-$value = $a ? $b : $a ?: null;
+$value = ($a ? $b : $a) ?: null;
Change curly based array and string to square bracket
$string = 'test';
-echo $string{0};
+echo $string[0];
$array = ['test'];
-echo $array{0};
+echo $array[0];
Remove & from function and method calls
final class SomeClass
{
public function run($one)
{
- return strlen(&$one);
+ return strlen($one);
}
}
Remove 0 from break and continue
class SomeClass
{
public function run($random)
{
- continue 0;
- break 0;
+ continue;
+ break;
$five = 5;
- continue $five;
+ continue 5;
- break $random;
+ break;
}
}
Long array to short array
class SomeClass
{
public function run()
{
- return array();
+ return [];
}
}
Change get_called_class() to self::class on final class
final class SomeClass
{
public function callOnMe()
{
- var_dump(get_called_class());
+ var_dump(self::class);
}
}
Change get_called_class() to static::class on non-final class
class SomeClass
{
public function callOnMe()
{
- var_dump(get_called_class());
+ var_dump(static::class);
}
}
The /e modifier is no longer supported, use preg_replace_callback instead
class SomeClass
{
public function run()
{
- $comment = preg_replace('~\b(\w)(\w+)~e', '"$1".strtolower("$2")', $comment);
+ $comment = preg_replace_callback('~\b(\w)(\w+)~', function ($matches) {
+ return($matches[1].strtolower($matches[2]));
+ }, $comment);
}
}
Change static::class to self::class on final class
final class SomeClass
{
public function callOnMe()
{
- var_dump(static::class);
+ var_dump(self::class);
}
}
Replace string class names by constant
class AnotherClass
{
}
class SomeClass
{
public function run()
{
- return 'AnotherClass';
+ return \AnotherClass::class;
}
}
Change __CLASS__ to self::class
class SomeClass
{
public function callOnMe()
{
- var_dump(__CLASS__);
+ var_dump(self::class);
}
}
Change get_class($object) to faster $object::class
class SomeClass
{
public function run($object)
{
- return get_class($object);
+ return $object::class;
}
}
Change $this::class to static::class or self::class depends on class modifier
class SomeClass
{
public function run()
{
- return $this::class;
+ return static::class;
}
}
Remove unused variable in catch()
final class SomeClass
{
public function run()
{
try {
- } catch (Throwable $notUsedThrowable) {
+ } catch (Throwable) {
}
}
}
Change nested annotations to attributes
use Doctrine\ORM\Mapping as ORM;
class SomeEntity
{
- /**
- * @ORM\JoinTable(name="join_table_name",
- * joinColumns={@ORM\JoinColumn(name="origin_id")},
- * inverseJoinColumns={@ORM\JoinColumn(name="target_id")}
- * )
- */
+ #[ORM\JoinTable(name: 'join_table_name')]
+ #[ORM\JoinColumn(name: 'origin_id')]
+ #[ORM\InverseJoinColumn(name: 'target_id')]
private $collection;
}
Change helper functions to str_starts_with()
class SomeClass
{
public function run()
{
- $isMatch = substr($haystack, 0, strlen($needle)) === $needle;
+ $isMatch = str_starts_with($haystack, $needle);
- $isNotMatch = substr($haystack, 0, strlen($needle)) !== $needle;
+ $isNotMatch = ! str_starts_with($haystack, $needle);
}
}
Replace mb_strpos() !== false and mb_strstr() with str_contains()
class SomeClass
{
public function run()
{
- return mb_strpos('abc', 'a') !== false;
+ return str_contains('abc', 'a');
}
}
Change switch() to match()
-switch ($input) {
- case Lexer::T_SELECT:
- $statement = 'select';
- break;
- case Lexer::T_UPDATE:
- $statement = 'update';
- break;
- default:
- $statement = 'error';
-}
+$statement = match ($input) {
+ Lexer::T_SELECT => 'select',
+ Lexer::T_UPDATE => 'update',
+ default => 'error',
+};
Add Stringable interface to classes with __toString() method
-class SomeClass
+class SomeClass implements Stringable
{
- public function __toString()
+ public function __toString(): string
{
return 'I can stringz';
}
}
Change annotation to attribute
use Symfony\Component\Routing\Annotation\Route;
class SymfonyRoute
{
- /**
- * @Route("/path", name="action")
- */
+ #[Route(path: '/path', name: 'action')]
public function action()
{
}
}
Change simple property init and assign to constructor promotion
class SomeClass
{
- public float $price;
-
public function __construct(
- float $price = 0.0
+ public float $price = 0.0
) {
- $this->price = $price;
}
}
Change method visibility from final private to only private
class SomeClass
{
- final private function getter() {
+ private function getter() {
return $this;
}
}
Add static visibility to __set_state() methods
class SomeClass
{
- public function __set_state($properties) {
+ public static function __set_state($properties) {
}
}
Add missing parameter based on parent class method
class A
{
public function execute($foo)
{
}
}
class B extends A
{
- public function execute()
+ public function execute($foo)
{
}
}
Add reasonable default value when a required parameter follows an optional one
class SomeObject
{
- public function run($optional = 1, int $required)
+ public function run($optional = 1, int $required = 0)
{
}
}
Add "never" return-type for methods that never return anything
final class SomeClass
{
- public function run()
+ public function run(): never
{
throw new InvalidException();
}
}
Change deprecated utf8_decode() and utf8_encode() to mb_convert_encoding()
-utf8_decode($value);
-utf8_encode($value);
+mb_convert_encoding($value, 'ISO-8859-1');
+mb_convert_encoding($value, 'UTF-8', 'ISO-8859-1');
Replace deprecated ${var} to {$var}
$c = "football";
-echo "I like playing ${c}";
+echo "I like playing {$c}";
Add SensitiveParameter attribute to method and function configured parameters
class SomeClass
{
- public function run(string $password)
+ public function run(#[\SensitiveParameter] string $password)
{
}
}
Prior PHP 8.2 FilesystemIterator::SKIP_DOTS was always set and could not be removed, therefore FilesystemIterator::SKIP_DOTS is added in order to keep this behaviour
-new FilesystemIterator(__DIR__, FilesystemIterator::KEY_AS_FILENAME);
+new FilesystemIterator(__DIR__, FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::SKIP_DOTS);
Decorate read-only class with readonly attribute
-final class SomeClass
+final readonly class SomeClass
{
public function __construct(
- private readonly string $name
+ private string $name
) {
}
}