Skip to content

Commit 954c9b9

Browse files
author
Jonas De Keukelaere
committed
Rector upgrade PHP 8.5
1 parent 859887d commit 954c9b9

8 files changed

Lines changed: 15 additions & 21 deletions

File tree

rector.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
__DIR__ . '/spoon',
1111
])
1212
// uncomment to reach your current PHP version
13-
->withPhpSets(php84: true)
14-
->withRules([
15-
ExplicitNullableParamTypeRector::class,
16-
])
13+
->withPhpSets(php85: true)
1714
->withTypeCoverageLevel(0)
1815
->withDeadCodeLevel(0)
1916
->withCodeQualityLevel(0);

spoon/database/database.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public function delete($table, $where = null, $parameters = [])
248248
*/
249249
public function drop($tables)
250250
{
251-
$this->execute('DROP TABLE ' . implode(', ', array_map([$this, 'quoteName'], (array) $tables)));
251+
$this->execute('DROP TABLE ' . implode(', ', array_map($this->quoteName(...), (array) $tables)));
252252
}
253253

254254

@@ -825,7 +825,7 @@ public function insert($table, array $values)
825825
$subKeys = array_keys($actualValues[0]);
826826

827827
// prefix with table name
828-
array_walk($subKeys, [$this, 'prefixTableNames'], $table);
828+
array_walk($subKeys, $this->prefixTableNames(...), $table);
829829

830830
// build query
831831
$query .= implode(', ', $subKeys) . ') VALUES ';
@@ -882,7 +882,7 @@ public function insert($table, array $values)
882882
$numFields = count($actualValues);
883883

884884
// prefix with table name
885-
array_walk($keys, [$this, 'prefixTableNames'], $table);
885+
array_walk($keys, $this->prefixTableNames(...), $table);
886886

887887
// build query
888888
$query .= implode(', ', $keys) . ') VALUES (';
@@ -955,7 +955,7 @@ public function optimize($tables)
955955
$tables = (func_num_args() == 1) ? (array) $tables : func_get_args();
956956

957957
// build & execute query
958-
return $this->getRecords('OPTIMIZE TABLE ' . implode(', ', array_map([$this, 'quoteName'], $tables)));
958+
return $this->getRecords('OPTIMIZE TABLE ' . implode(', ', array_map($this->quoteName(...), $tables)));
959959
}
960960

961961

@@ -1145,7 +1145,7 @@ public function update($table, array $values, $where = null, $parameters = [])
11451145
foreach($parameters as $key => $value)
11461146
{
11471147
// key such as ':id' starting
1148-
if(str_starts_with($key, ':'))
1148+
if(str_starts_with((string) $key, ':'))
11491149
{
11501150
$namedParameters = true;
11511151
break;

spoon/exception/exception.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function getObfuscate()
8484

8585
// Redefine the exception handler if we are not running in the command line.
8686
if (!Spoon::inCli()) {
87-
set_exception_handler('exceptionHandler');
87+
set_exception_handler(exceptionHandler(...));
8888
}
8989

9090
/**

spoon/file/csv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public static function fileToArray($path, array $columns = [], ?array $excludeCo
216216
$handle = @fopen($path, 'r');
217217

218218
// loop lines and store the rows
219-
while(($row = @fgetcsv($handle, 0, (($delimiter == '') ? ',' : $delimiter), (($enclosure == '') ? '"' : $enclosure))) !== false) $rows[] = $row;
219+
while(($row = @fgetcsv($handle, 0, (($delimiter == '') ? ',' : $delimiter), (($enclosure == '') ? '"' : $enclosure), escape: '\\')) !== false) $rows[] = $row;
220220

221221
// close file
222222
@fclose($handle);

spoon/filter/filter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,16 @@ public static function disableMagicQuotes()
156156
*/
157157
function fixMagicQuotes($value)
158158
{
159-
$value = is_array($value) ? array_map('fixMagicQuotes', $value) : stripslashes((string) $value);
159+
$value = is_array($value) ? array_map(fixMagicQuotes(...), $value) : stripslashes((string) $value);
160160
return $value;
161161
}
162162
}
163163

164164
// fix the thing with magic dust!
165-
$_POST = array_map('fixMagicQuotes', $_POST);
166-
$_GET = array_map('fixMagicQuotes', $_GET);
167-
$_COOKIE = array_map('fixMagicQuotes', $_COOKIE);
168-
$_REQUEST = array_map('fixMagicQuotes', $_REQUEST);
165+
$_POST = array_map(fixMagicQuotes(...), $_POST);
166+
$_GET = array_map(fixMagicQuotes(...), $_GET);
167+
$_COOKIE = array_map(fixMagicQuotes(...), $_COOKIE);
168+
$_REQUEST = array_map(fixMagicQuotes(...), $_REQUEST);
169169
}
170170
}
171171

spoon/form/dropdown.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ public function setSingle($single = true)
712712
*/
713713
private function setValues(?array $values = null)
714714
{
715-
$values = $values ?? [];
715+
$values ??= [];
716716

717717
// has no items
718718
if(count($values) == 0) $this->setDefaultElement('');

spoon/template/compiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ protected function prepareIterations($content)
11111111
while(1)
11121112
{
11131113
// replace iteration names to ensure that they're unique
1114-
$content = preg_replace_callback($pattern, [$this, 'prepareIterationsCallback'], (string) $content, -1, $count);
1114+
$content = preg_replace_callback($pattern, $this->prepareIterationsCallback(...), (string) $content, -1, $count);
11151115

11161116
// break the loop, no matches were found
11171117
if(!$count) break;

spoon/thumbnail/thumbnail.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,6 @@ private function resizeImageWithoutForceAspectRatio($currentWidth, $currentHeigh
599599
// resize
600600
$success = @imagecopyresampled($tempImage, $currentImage, 0, 0, 0, 0, $tempWidth, $tempHeight, $currentWidth, $currentHeight);
601601

602-
// destroy original image
603-
imagedestroy($currentImage);
604-
605602
// image creation fail
606603
if(!$success)
607604
{

0 commit comments

Comments
 (0)