Skip to content

Commit

Permalink
fix(rector): update rector 0.17.7
Browse files Browse the repository at this point in the history
  • Loading branch information
noelma committed Jul 30, 2023
1 parent ad462c4 commit f175c26
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 28 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"phpstan/phpstan": "^1.9",
"phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^10.1",
"rector/rector": "^0.16",
"rector/rector": "^0.17.7",
"soosyze/php-cs-fixer-config": "^1.0"
},
"suggest": {
Expand Down
4 changes: 2 additions & 2 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
]);

// is your PHP version different from the one your refactor to? [default: your PHP version], uses PHP_VERSION_ID format
$rectorConfig->phpVersion(PhpVersion::PHP_80);
$rectorConfig->phpVersion(PhpVersion::PHP_81);

// Define what rule sets will be applied
$rectorConfig->sets([
SetList::CODE_QUALITY,
SetList::PHP_80,
SetList::PHP_81,
SetList::DEAD_CODE,
SetList::TYPE_DECLARATION
]);
Expand Down
1 change: 1 addition & 0 deletions src/Concern/Field/TryOrGetDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function tryOrGetValue(mixed $value): string
$this->throwInvalidType($value);
}

/** @var string $value */
if (strtolower($value) === $this->currentDefault->value) {
return $this->currentDefault->value;
}
Expand Down
1 change: 1 addition & 0 deletions src/Concern/Field/TryOrGetString.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function tryOrGetValue(mixed $value): string
$this->throwInvalidType($value);
}

/** @var string $value */
if (strlen($value) > $this->length) {
throw new \LengthException(
sprintf(
Expand Down
2 changes: 1 addition & 1 deletion src/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
abstract class Driver implements DriverInterface
{
const DS = DIRECTORY_SEPARATOR;
public final const DS = DIRECTORY_SEPARATOR;

/**
* Déclenche une exception si l'extension du fichier n'est pas chargée.
Expand Down
8 changes: 4 additions & 4 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ protected function executeOrderBy(array &$data, array $orderBy): void
}

$sorted = $a[ $field ] > $b[ $field ]
? 1 * $order->value
? $order->value
: -1 * $order->value;

if ($sorted !== 0) {
Expand Down Expand Up @@ -511,10 +511,10 @@ private function selectToString(): string
$output = trim($output, ', ') . ' ';
}
if ($this->limit !== 0) {
$output .= sprintf('LIMIT %d ', (string) $this->limit);
$output .= sprintf('LIMIT %d ', $this->limit);
}
if ($this->offset !== 0) {
$output .= sprintf('OFFSET %d ', (string) $this->offset);
$output .= sprintf('OFFSET %d ', $this->offset);
}

return trim($output) . ';';
Expand Down Expand Up @@ -578,7 +578,7 @@ private function loadAllFieldsSchema(): void
*/
private function tryFrom(): void
{
if (empty($this->from)) {
if ($this->from === '') {
throw new TableNotFoundException();
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,19 +298,19 @@ public function alterTable(string $tableName, callable $callback): self

foreach ($tableBuilder->getFields() as $field) {
if ($field->getExecutionType() === TableExecutionType::Create) {
self::tryFieldAdd($tableSchema, $field);
$this->tryFieldAdd($tableSchema, $field);
self::add($tableSchema, $field, $tableData);
} elseif ($field->getExecutionType() === TableExecutionType::Modify) {
self::tryFieldModify($tableSchema, $field);
$this->tryFieldModify($tableSchema, $field);
self::modify($tableSchema, $field, $tableData);
}
}
foreach($tableBuilder->getCommands() as $command) {
if ($command instanceof RenameCommand) {
self::tryFieldRename($tableSchema, $command);
$this->tryFieldRename($tableSchema, $command);
self::rename($tableSchema, $command, $tableData);
} elseif ($command instanceof DropCommand) {
self::tryFieldDrop($tableSchema, $command);
$this->tryFieldDrop($tableSchema, $command);
self::drop($tableSchema, $command, $tableData);
}
}
Expand Down Expand Up @@ -611,7 +611,7 @@ protected static function tableBuilder(string $tableName, ?callable $callback =
* @throws Exception
* @throws ColumnsNotFoundException
*/
private static function tryFieldAdd(Table $tableSchema, Field $field): void
private function tryFieldAdd(Table $tableSchema, Field $field): void
{
/* Si un champ est ajouté il ne doit pas exister dans le schéma. */
if ($tableSchema->hasField($field->name)) {
Expand Down Expand Up @@ -643,7 +643,7 @@ private static function tryFieldAdd(Table $tableSchema, Field $field): void
* @throws ColumnsValueException
* @throws Exception
*/
private static function tryFieldModify(Table $tableSchema, Field $field): void
private function tryFieldModify(Table $tableSchema, Field $field): void
{
if (!$tableSchema->hasField($field->name)) {
throw new Exception(
Expand Down Expand Up @@ -689,7 +689,7 @@ private static function tryFieldModify(Table $tableSchema, Field $field): void
* @throws ColumnsNotFoundException
* @throws Exception
*/
private static function tryFieldRename(Table $table, RenameCommand $command): void
private function tryFieldRename(Table $table, RenameCommand $command): void
{
if (!$table->hasField($command->name)) {
throw new ColumnsNotFoundException(
Expand All @@ -712,7 +712,7 @@ private static function tryFieldRename(Table $table, RenameCommand $command): vo
*
* @throws ColumnsNotFoundException
*/
private static function tryFieldDrop(Table $table, DropCommand $command): void
private function tryFieldDrop(Table $table, DropCommand $command): void
{
if (!$table->hasField($command->name)) {
throw new ColumnsNotFoundException(
Expand Down
18 changes: 6 additions & 12 deletions tests/Unit/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1296,8 +1296,7 @@ public function testLeftJoin(): void
->leftJoin('role', 'id_role', '=', 'role.id_role');

self::assertEquals(
'SELECT id, name, firstname, labelle FROM user '
. 'LEFT JOIN user_role ON id = \'user_role.id_user\' '
'SELECT id, name, firstname, labelle FROM user LEFT JOIN user_role ON id = \'user_role.id_user\' '
. 'LEFT JOIN role ON id_role = \'role.id_role\';',
(string) $data
);
Expand Down Expand Up @@ -1326,8 +1325,7 @@ public function testLeftJoinWhere(): void
->where('labelle', '=', 'Admin');

self::assertEquals(
'SELECT id, name, firstname FROM user '
. 'LEFT JOIN user_role ON id = \'user_role.id_user\' '
'SELECT id, name, firstname FROM user LEFT JOIN user_role ON id = \'user_role.id_user\' '
. 'LEFT JOIN role ON id_role = \'role.id_role\' '
. 'WHERE labelle = \'Admin\';',
(string) $data
Expand All @@ -1353,8 +1351,7 @@ public function testLeftJoinGroup(): void
->where('labelle', '=', 'Admin');

self::assertEquals(
'SELECT id, name, firstname FROM user '
. 'LEFT JOIN user_role ON id = \'user_role.id_user\' '
'SELECT id, name, firstname FROM user LEFT JOIN user_role ON id = \'user_role.id_user\' '
. 'LEFT JOIN role ON id_role = \'role.id_role\' '
. 'WHERE labelle = \'Admin\';',
(string) $data
Expand Down Expand Up @@ -1382,8 +1379,7 @@ public function testLeftJoinGroupMultiple(): void
->where('labelle', '=', 'Admin');

self::assertEquals(
'SELECT id, name, firstname, labelle FROM user '
. 'LEFT JOIN user_role ON id = \'user_role.id_user\' '
'SELECT id, name, firstname, labelle FROM user LEFT JOIN user_role ON id = \'user_role.id_user\' '
. 'LEFT JOIN role ON (id_role = \'role.id_role\') '
. 'WHERE labelle = \'Admin\';',
(string) $data
Expand Down Expand Up @@ -1433,8 +1429,7 @@ public function testLeftJoinExceptionColumn(): void
$this->expectException(ColumnsNotFoundException::class);
$this->expectExceptionMessage(
'Column foo is absent: '
. 'SELECT id, name, firstname FROM user '
. 'LEFT JOIN user_role ON foo == \'user_role.id_user\' '
. 'SELECT id, name, firstname FROM user LEFT JOIN user_role ON foo == \'user_role.id_user\' '
. 'LEFT JOIN role ON id_role == \'role.id\' '
. 'WHERE labelle = \'Admin\' '
. 'LIMIT 1;'
Expand Down Expand Up @@ -1573,8 +1568,7 @@ public function testUnionAllMultiple(): void
->unionAll($union);

self::assertEquals(
'SELECT name, firstname FROM user '
. 'UNION ALL '
'SELECT name, firstname FROM user UNION ALL '
. 'SELECT name, firstname FROM user WHERE id BETWEEN 1 AND 5;',
(string) $data
);
Expand Down

0 comments on commit f175c26

Please sign in to comment.