More PHP 8.1 fixes to be compatible

main
Igor Scheller 3 years ago committed by msquare
parent 643c4c8da7
commit 8d436d988a

@ -93,7 +93,7 @@ class CreateUsersTables extends Migration
'password' => $data->Passwort,
'email' => $data->email,
'api_key' => $data->api_key,
'last_login_at' => Carbon::createFromTimestamp($data->lastLogIn),
'last_login_at' => $data->lastLogIn ? Carbon::createFromTimestamp($data->lastLogIn) : null,
]);
$user->setAttribute('id', $data->UID);
if (!in_array($data->CreateDate, $emptyDates)) {

@ -28,7 +28,7 @@ COPY --from=composer /app/composer.lock /app/
RUN find /app/storage/ -type f -not -name VERSION -exec rm {} \;
# Build the PHP container
FROM php:8.0-fpm-alpine
FROM php:8-fpm-alpine
WORKDIR /var/www
RUN apk add --no-cache icu-dev && \
docker-php-ext-install intl pdo_mysql

@ -1,5 +1,5 @@
# Engelsystem PHP FPM development image including Xdebug
FROM php:8.0-fpm-alpine AS es_php_fpm
FROM php:8-fpm-alpine AS es_php_fpm
WORKDIR /var/www
RUN apk add --no-cache icu-dev $PHPIZE_DEPS && \
pecl install pcov xdebug && \

@ -11,7 +11,7 @@ use Carbon\Carbon;
*/
function form_hidden($name, $value)
{
return '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value) . '" />';
return '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars((string)$value) . '" />';
}
/**
@ -24,7 +24,7 @@ function form_hidden($name, $value)
*/
function form_spinner($name, $label, $value)
{
$value = htmlspecialchars($value);
$value = htmlspecialchars((string)$value);
return form_element($label, '
<div class="input-group">
@ -69,7 +69,7 @@ function form_date($name, $label, $value, $start_date = '', $end_date = '')
return form_element($label, '
<div class="input-group date" id="' . $dom_id . '" data-min-date="' . $start_date . '" data-max-date="' . $end_date . '" data-target-input="nearest">
<input type="date" placeholder="YYYY-MM-DD" name="' . $name . '" class="form-control" value="' . htmlspecialchars($value) . '" autocomplete="off">'
<input type="date" placeholder="YYYY-MM-DD" name="' . $name . '" class="form-control" value="' . htmlspecialchars((string)$value) . '" autocomplete="off">'
. '<span class="input-group-text">' . icon('grid-3x3-gap-fill') . '</span>
</div>
', $dom_id);
@ -178,7 +178,7 @@ function form_checkbox($name, $label, $selected, $value = 'checked', $html_id =
}
return '<div class="checkbox"><label>'
. '<input type="checkbox" id="' . $html_id . '" name="' . $name . '" value="' . htmlspecialchars($value) . '" '
. '<input type="checkbox" id="' . $html_id . '" name="' . $name . '" value="' . htmlspecialchars((string)$value) . '" '
. ($selected ? ' checked="checked"' : '') . ' /> '
. $label
. '</label></div>';
@ -196,7 +196,7 @@ function form_checkbox($name, $label, $selected, $value = 'checked', $html_id =
function form_radio($name, $label, $selected, $value)
{
return '<div class="radio">'
. '<label><input type="radio" id="' . $name . '" name="' . $name . '" value="' . htmlspecialchars($value) . '" '
. '<label><input type="radio" id="' . $name . '" name="' . $name . '" value="' . htmlspecialchars((string)$value) . '" '
. ($selected ? ' checked="checked"' : '') . ' /> '
. $label
. '</label></div>';
@ -268,7 +268,7 @@ function form_text($name, $label, $value, $disabled = false, $maxlength = null,
return form_element(
$label,
'<input class="form-control" id="form_' . $name . '" type="text" name="' . $name
. '" value="' . htmlspecialchars($value) . '"' . $maxlength . $disabled . $autocomplete . '/>',
. '" value="' . htmlspecialchars((string)$value) . '"' . $maxlength . $disabled . $autocomplete . '/>',
'form_' . $name,
$class
);
@ -288,7 +288,7 @@ function form_text_placeholder($name, $placeholder, $value, $disabled = false)
$disabled = $disabled ? ' disabled="disabled"' : '';
return form_element('',
'<input class="form-control" id="form_' . $name . '" type="text" name="' . $name
. '" value="' . htmlspecialchars($value) . '" placeholder="' . $placeholder
. '" value="' . htmlspecialchars((string)$value) . '" placeholder="' . $placeholder
. '" ' . $disabled . '/>'
);
}
@ -313,7 +313,7 @@ function form_email($name, $label, $value, $disabled = false, $autocomplete = nu
return form_element(
$label,
'<input class="form-control" id="form_' . $name . '" type="email" name="' . $name . '" value="'
. htmlspecialchars($value) . '" ' . $disabled . $autocomplete . $maxlength . '/>',
. htmlspecialchars((string)$value) . '" ' . $disabled . $autocomplete . $maxlength . '/>',
'form_' . $name
);
}
@ -391,7 +391,7 @@ function form_textarea($name, $label, $value, $disabled = false)
return form_element(
$label,
'<textarea rows="5" class="form-control" id="form_' . $name . '" name="'
. $name . '" ' . $disabled . '>' . htmlspecialchars($value) . '</textarea>',
. $name . '" ' . $disabled . '>' . htmlspecialchars((string)$value) . '</textarea>',
'form_' . $name
);
}

@ -403,7 +403,7 @@ function AngelType_view_info(
$info[] = '<h3>' . __('Description') . '</h3>';
$parsedown = new Parsedown();
if ($angeltype['description'] != '') {
$info[] = $parsedown->parse($angeltype['description']);
$info[] = $parsedown->parse((string)$angeltype['description']);
}
list($supporters, $members_confirmed, $members_unconfirmed) = AngelType_view_members(
@ -561,7 +561,7 @@ function AngelTypes_about_view_angeltype($angeltype)
);
}
if ($angeltype['description'] != '') {
$html .= $parsedown->parse($angeltype['description']);
$html .= $parsedown->parse((string)$angeltype['description']);
}
$html .= '<hr />';

@ -24,7 +24,7 @@ function Room_view(Room $room, ShiftsFilterRenderer $shiftsFilterRenderer, Shift
if ($room->description) {
$description = '<h3>' . __('Description') . '</h3>';
$parsedown = new Parsedown();
$description .= $parsedown->parse($room->description);
$description .= $parsedown->parse((string)$room->description);
}
$tabs = [];

@ -98,7 +98,7 @@ function ShiftType_view($shifttype, $angeltype)
)
]),
heading(__('Description'), 2),
$parsedown->parse($shifttype['description'])
$parsedown->parse((string)$shifttype['description'])
], true);
}

@ -176,8 +176,8 @@ function Shift_view($shift, $shifttype, Room $room, $angeltypes_source, ShiftSig
]),
div('col-sm-6', [
'<h2>' . __('Description') . '</h2>',
$parsedown->parse($shifttype['description']),
$parsedown->parse($shift['description']),
$parsedown->parse((string)$shifttype['description']),
$parsedown->parse((string)$shift['description']),
])
]);

@ -32,7 +32,7 @@ class ConfigureEnvironmentServiceProvider extends ServiceProvider
*/
protected function setTimeZone(CarbonTimeZone $timeZone)
{
ini_set('date.timezone', $timeZone);
ini_set('date.timezone', (string)$timeZone);
date_default_timezone_set($timeZone);
}

@ -43,7 +43,8 @@ abstract class AbstractHandler implements SessionHandlerInterface
* @param int $maxLifetime
* @return bool
*/
public function gc($maxLifetime): bool
#[\ReturnTypeWillChange]
public function gc($maxLifetime)
{
return true;
}

@ -74,7 +74,7 @@ class DatabaseHandler extends AbstractHandler
/**
* {@inheritdoc}
*/
public function gc($maxLifetime): bool
public function gc($maxLifetime)
{
$timestamp = $this->getCurrentTimestamp(-$maxLifetime);

@ -72,7 +72,7 @@ class Logger extends AbstractLogger
}
// replace the values of the message
$message = str_replace('{' . $key . '}', $val, $message);
$message = str_replace('{' . $key . '}', (string)$val, $message);
}
return $message;

@ -77,7 +77,7 @@ class ErrorHandler implements MiddlewareInterface
$statusCode = $response->getStatusCode();
$contentType = $response->getHeader('content-type');
$contentType = array_shift($contentType);
if (!$contentType && strpos($response->getBody(), '<html') !== false) {
if (!$contentType && strpos($response->getBody() ?? '', '<html') !== false) {
$contentType = 'text/html';
}

@ -64,6 +64,10 @@ class SendResponseHandler implements MiddlewareInterface
*/
protected function sendHeader($content, $replace = true, $code = null)
{
header($content, $replace, $code);
if (is_null($code)) {
header($content, $replace);
} else {
header($content, $replace, $code);
}
}
}

@ -50,7 +50,7 @@ class EventConfig extends BaseModel
*/
public function getValueAttribute($value)
{
$value = $this->fromJson($value);
$value = $value ? $this->fromJson($value) : null;
/** @see \Illuminate\Database\Eloquent\Concerns\HasAttributes::castAttribute */
if (!empty($value)) {

@ -78,6 +78,10 @@ class EventConfigTest extends ModelTest
->value
->format('Y-m-d H:i')
);
$this->assertEquals(
null,
($this->getEventConfig())->getValueAttribute(null)
);
}
/**

Loading…
Cancel
Save