Skip to content

Commit

Permalink
PHP up to 8.3 update
Browse files Browse the repository at this point in the history
  • Loading branch information
Daren Sipes committed Apr 16, 2024
1 parent d0eceab commit 9234197
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/Command/BakeMigrationDiffCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ protected function checkSync()
$lastVersion = $this->migratedItems[0]['version'];
$lastFile = end($this->migrationsFiles);

return (bool)strpos($lastFile, (string)$lastVersion);
return (bool)strpos((string) $lastFile, (string)$lastVersion);
}

return false;
Expand Down Expand Up @@ -555,7 +555,7 @@ protected function getCurrentSchema()
}
$collection = $connection->getSchemaCollection();
foreach ($this->tables as $table) {
if (preg_match('/^.*phinxlog$/', $table) === 1) {
if (preg_match('/^.*phinxlog$/', (string) $table) === 1) {
continue;
}

Expand All @@ -580,7 +580,7 @@ public function template(): string
*/
public function getOptionParser(): ConsoleOptionParser
{
$parser = parent::getOptionParser();
$parser = null;

$parser->addArgument('name', [
'help' => 'Name of the migration to bake. Can use Plugin.name to bake migration files into plugins.',
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Component/RefererComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ public function normalizeUrl($url = null): ?string
* @param int $status http status code, default is null
* @return \Cake\Http\Response|null
*/
public function redirect($url, int $status = 302): ?Response
public function redirect(mixed $url, int $status = 302): ?Response
{
$referer = $this->getReferer();

if (in_array($referer, $this->_config['ignored'])) {
$referer = null;
}

if (strlen($referer) == 0 || $referer == '/') {
if (strlen((string) $referer) == 0 || $referer == '/') {
return $this->getController()->redirect($url, $status);
} else {
return $this->getController()->redirect($referer, $status);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function paginate($object = null, array $settings = [])

try {
return $this->Paginator->paginate($table, $settings);
} catch (NotFoundException $e) {
} catch (NotFoundException) {
$request = $this->getRequest();
$queryString = $request->getQueryParams();
if (isset($queryString['page'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Type/JsonArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function manyToPHP(array $values, array $fields, DriverInterface $driver)
continue;
}

$values[$field] = json_decode($values[$field], false);
$values[$field] = json_decode((string) $values[$field], false);
}

return $values;
Expand Down
4 changes: 2 additions & 2 deletions src/Filesystem/FileApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public static function put($tmpFilePath, array $metaData = [])
$file->meta = $metaData['meta'];
}
/** @var array $pathInfo */
$pathInfo = pathinfo($metaData['original_filename']);
$pathInfo = pathinfo((string) $metaData['original_filename']);
$file->filename = Text::uuid() . isset($pathInfo['extension']) ? '.' . $pathInfo['extension'] : null;

$folder = new Folder(Configure::read('FileApi.basePath') . $file->category . DS . $file->tag, true, 0755);
Expand Down Expand Up @@ -243,7 +243,7 @@ public static function resize(string $id, array $options = [])
// Get additional image data
try {
$imageInfo = getimagesize($file->path);
} catch (Exception $e) {
} catch (Exception) {
$imageInfo = [];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Message/StatusMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,6 @@ public static function toString(string $key)
$message = static::$_messages[$key]['responseText'] ?? '';
$type = static::$_messages[$key]['type'] ?? 'notice';

return trim($message . ' ' . strtoupper($type) . ': ' . $code);
return trim($message . ' ' . strtoupper((string) $type) . ': ' . $code);
}
}
2 changes: 1 addition & 1 deletion src/Model/Entity/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ protected function _getBase64()
$contents = '';
}

return 'data:' . $file->mime() . ';base64,' . base64_encode($contents);
return 'data:' . $file->mime() . ';base64,' . base64_encode((string) $contents);
}
}
6 changes: 3 additions & 3 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected function findInPath(string $namespace, string $path): array

try {
$reflection = new ReflectionClass($class);
} catch (ReflectionException $e) {
} catch (ReflectionException) {
continue;
}
if (!$reflection->isInstantiable() || !$reflection->isSubclassOf(BakeCommand::class)) {
Expand All @@ -134,15 +134,15 @@ protected function findInPath(string $namespace, string $path): array

// Trim off 'Command' from the name.
[$ns, $className] = namespaceSplit($class);
$name = Inflector::underscore(substr($className, 0, -7));
$name = Inflector::underscore(substr((string) $className, 0, -7));

$shortName = $class::defaultName();

if (!empty($shortName)) {
$candidates[$shortName] = $class;
} else {
// Commands ending with `_all` should be ` all` instead.
if (substr($name, -4) === '_all') {
if (str_ends_with($name, '_all')) {
$name = substr($name, 0, -4) . ' all';
}
$candidates["bake {$name}"] = $class;
Expand Down
2 changes: 1 addition & 1 deletion src/Routing/Middleware/SessionTimeoutMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
}

/** @var \Cake\Http\ServerRequest $request */
if ((!$request->is('ajax') || ($request->getQuery('session_timeout') && strtolower($request->getQuery('session_timeout')) === 'extend')) && $request->getParam('plugin') !== 'DebugKit') {
if ((!$request->is('ajax') || ($request->getQuery('session_timeout') && strtolower((string) $request->getQuery('session_timeout')) === 'extend')) && $request->getParam('plugin') !== 'DebugKit') {
$session->write('SessionTimeoutFilter.lastAccess', time());
}

Expand Down
4 changes: 2 additions & 2 deletions src/Utility/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static function phone(string $phone, array $formats = [], string $extForm
];

$phone = self::parsePhone($phone, true);
$format = !empty($formats[strlen($phone['string'])]) ? $formats[strlen($phone['string'])] : '';
$format = !empty($formats[strlen((string) $phone['string'])]) ? $formats[strlen((string) $phone['string'])] : '';
$formattedPhone = self::formatString($phone['string'], $format);

if (!empty($phone['parts']['ext'])) {
Expand Down Expand Up @@ -160,7 +160,7 @@ public static function maskString(string $string = '', string $format = '', stri
$spos++;
} else {
$result .= substr($format, $fpos, 1);
if (strpos($ignore, substr($format, $fpos, 1)) === false) {
if (!str_contains($ignore, substr($format, $fpos, 1))) {
++$spos;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Utility/Muddle.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Muddle
* @param string $separator The separator character
* @return bool True/False did the value get inserted
*/
public static function insert(array &$array, $path, $value, string $separator = '.'): bool
public static function insert(array &$array, $path, mixed $value, string $separator = '.'): bool
{
if (!is_array($path)) {
$path = explode($separator, $path);
Expand Down
2 changes: 1 addition & 1 deletion src/View/Helper/FormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function postLink(string $title, $url = null, array $options = []): strin

$requestMethod = 'POST';
if (!empty($options['method'])) {
$requestMethod = strtoupper($options['method']);
$requestMethod = strtoupper((string) $options['method']);
unset($options['method']);
}

Expand Down
2 changes: 1 addition & 1 deletion src/View/Helper/TableHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function header(string $key, $title = null, array $options = []): string
$keyArr = explode('.', $key); // As Model names are now required for all fields, remove the base model from the title
$title = array_pop($keyArr);

if (strpos($title, '.') !== false) {
if (str_contains($title, '.')) {
$title = str_replace('.', ' ', $title);
}

Expand Down
2 changes: 1 addition & 1 deletion templates/element/paginate.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
'data-url' => Cake\Routing\Router::url(['?' => $this->getRequest()->getQuery()]),
'data-update' => $this->fetch('ajax_update_element'),
'options' => !empty($paginatorOptions['limit']['options']) && is_array($paginatorOptions['limit']['options']) ? $paginatorOptions['limit']['options'] : [20 => 20, 40 => 40, 60 => 60, 80 => 80, 100 => 100],
'default' => $this->getRequest()->getQuery('limit') ? $this->getRequest()->getQuery('limit') : $paginatorOptions['limit']['default'] ?? 20,
'default' => $this->getRequest()->getQuery('limit') ?: $paginatorOptions['limit']['default'] ?? 20,
'templates' => [
'select' => '<select class="input-xs ' . ($this->layout == 'ajax' ? 'ajax-set-pagination-limit' : 'set-pagination-limit') . '"{{attrs}}>{{content}}</select>',
'inputContainer' => 'Show: {{content}}',
Expand Down
2 changes: 1 addition & 1 deletion templates/layout/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function each(els, cb) {
<?= h($this->fetch('title')) ?>
</div>
<div class="col text-right">
<small><?= get_class($error) ?></small>
<small><?= $error::class ?></small>
</div>
</div>
</div>
Expand Down
4 changes: 1 addition & 3 deletions templates/layout/pdf/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
} else {
$this->prepend('css', $this->Html->css(['app.min.css?cb=' . Configure::read('CacheBuster.cssCB')], ['fullBase' => true]));
}
$sanitize = function ($strIn) {
return preg_replace('/[\`\$]/i', '', $strIn);
};
$sanitize = fn($strIn) => preg_replace('/[\`\$]/i', '', (string) $strIn);
if ($this instanceof \CakePdf\View\PdfView) {
$this->renderer()->header([
'left' => $this->fetch('pageNumbers') ? 'Page [page] of [toPage]' : '',
Expand Down

0 comments on commit 9234197

Please sign in to comment.