Fixed linter warnings
This commit is contained in:
parent
905d91d6ed
commit
87b50507f3
|
@ -26,7 +26,7 @@ return [
|
|||
'environment' => env('ENVIRONMENT', 'production'),
|
||||
|
||||
// Application URL and base path to use instead of the auto-detected one
|
||||
'url' => env('APP_URL', null),
|
||||
'url' => env('APP_URL'),
|
||||
|
||||
// Header links
|
||||
// Available link placeholders: %lang%
|
||||
|
@ -61,7 +61,7 @@ return [
|
|||
],
|
||||
|
||||
// Text displayed on the FAQ page, rendered as markdown
|
||||
'faq_text' => env('FAQ_TEXT', null),
|
||||
'faq_text' => env('FAQ_TEXT'),
|
||||
|
||||
// Link to documentation/help
|
||||
'documentation_url' => env('DOCUMENTATION_URL', 'https://engelsystem.de/doc/'),
|
||||
|
@ -79,20 +79,20 @@ return [
|
|||
'host' => env('MAIL_HOST', 'localhost'),
|
||||
'port' => env('MAIL_PORT', 587),
|
||||
// If tls transport encryption should be used
|
||||
'tls' => env('MAIL_TLS', null),
|
||||
'tls' => env('MAIL_TLS'),
|
||||
'username' => env('MAIL_USERNAME'),
|
||||
'password' => env('MAIL_PASSWORD'),
|
||||
'sendmail' => env('MAIL_SENDMAIL', '/usr/sbin/sendmail -bs'),
|
||||
],
|
||||
|
||||
// Your privacy@ contact address
|
||||
'privacy_email' => env('PRIVACY_EMAIL', null),
|
||||
'privacy_email' => env('PRIVACY_EMAIL'),
|
||||
|
||||
// Show opt in to save some personal data after the event on user profile and registration pages
|
||||
'enable_email_goody' => (bool) env('ENABLE_EMAIL_GOODY', true),
|
||||
|
||||
// Initial admin password
|
||||
'setup_admin_password' => env('SETUP_ADMIN_PASSWORD', null),
|
||||
'setup_admin_password' => env('SETUP_ADMIN_PASSWORD'),
|
||||
|
||||
'oauth' => [
|
||||
// '[name]' => [config]
|
||||
|
@ -364,7 +364,7 @@ return [
|
|||
'shifts_per_voucher' => env('SHIFTS_PER_VOUCHER', 0),
|
||||
'hours_per_voucher' => env('HOURS_PER_VOUCHER', 2),
|
||||
// 'Y-m-d' formatted
|
||||
'voucher_start' => env('VOUCHER_START', null) ?: null,
|
||||
'voucher_start' => env('VOUCHER_START') ?: null,
|
||||
],
|
||||
|
||||
// Enables Driving License
|
||||
|
@ -374,8 +374,7 @@ return [
|
|||
'ifsg_enabled' => (bool) env('IFSG_ENABLED', false),
|
||||
|
||||
# Instruction only onsite in accordance with § 43 Para. 1 of the German Infection Protection Act (IfSG)
|
||||
'ifsg_light_enabled' => (bool) env('IFSG_LIGHT_ENABLED', false)
|
||||
&& env('IFSG_ENABLED', false),
|
||||
'ifsg_light_enabled' => env('IFSG_LIGHT_ENABLED', false) && env('IFSG_ENABLED', false),
|
||||
|
||||
// Available locales in /resources/lang/
|
||||
// To disable a locale in the config.php, you can set its value to null
|
||||
|
@ -404,7 +403,7 @@ return [
|
|||
],
|
||||
|
||||
// T-shirt Size-Guide link
|
||||
'tshirt_link' => env('TSHIRT_LINK', null),
|
||||
'tshirt_link' => env('TSHIRT_LINK'),
|
||||
|
||||
// Whether to show the current day of the event (-2, -1, 0, 1, 2…) in footer and on the dashboard.
|
||||
// The event start date has to be set for it to appear.
|
||||
|
|
|
@ -9,7 +9,6 @@ use Illuminate\Database\Schema\Blueprint;
|
|||
|
||||
class ChangeUsersContactDectFieldSize extends Migration
|
||||
{
|
||||
/** @var array */
|
||||
protected array $tables = [
|
||||
'AngelTypes' => 'contact_dect',
|
||||
'users_contact' => 'dect',
|
||||
|
|
|
@ -307,9 +307,8 @@ function shift_entry_load()
|
|||
if (!$request->has('shift_entry_id') || !test_request_int('shift_entry_id')) {
|
||||
throw_redirect(url('/user-shifts'));
|
||||
}
|
||||
$shiftEntry = ShiftEntry::findOrFail($request->input('shift_entry_id'));
|
||||
|
||||
return $shiftEntry;
|
||||
return ShiftEntry::findOrFail($request->input('shift_entry_id'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -195,7 +195,7 @@ function shift_edit_controller()
|
|||
htmlspecialchars($angeltype_name),
|
||||
$needed_angel_types[$angeltype_id],
|
||||
[],
|
||||
ScheduleShift::whereShiftId($shift->id)->first() ? true : false,
|
||||
(bool) ScheduleShift::whereShiftId($shift->id)->first(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* Bootstrap application
|
||||
*/
|
||||
|
||||
use Engelsystem\Application;
|
||||
use Engelsystem\Http\UrlGeneratorInterface;
|
||||
|
||||
require __DIR__ . '/application.php';
|
||||
|
@ -18,7 +19,7 @@ require __DIR__ . '/includes.php';
|
|||
/**
|
||||
* Check for maintenance
|
||||
*/
|
||||
/** @var \Engelsystem\Application $app */
|
||||
/** @var Application $app */
|
||||
if ($app->get('config')->get('maintenance')) {
|
||||
http_response_code(503);
|
||||
$url = $app->get(UrlGeneratorInterface::class);
|
||||
|
|
|
@ -14,9 +14,6 @@ function theme_id(): int
|
|||
return $globals['themeId'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function theme(): array
|
||||
{
|
||||
$theme_id = theme_id();
|
||||
|
|
|
@ -45,7 +45,7 @@ function admin_shifts()
|
|||
$location_array = $locations->pluck('name', 'id')->toArray();
|
||||
|
||||
// Load angeltypes
|
||||
/** @var AngelType[] $types */
|
||||
/** @var AngelType[]|Collection $types */
|
||||
$types = AngelType::all();
|
||||
$no_angeltypes = $types->isEmpty();
|
||||
$needed_angel_types = [];
|
||||
|
|
|
@ -20,8 +20,9 @@ function form_hidden($name, $value)
|
|||
*
|
||||
* @param string $name
|
||||
* @param string $label
|
||||
* @param int $value
|
||||
* @param array $data_attributes
|
||||
* @param int $value
|
||||
* @param array $data_attributes
|
||||
* @param bool $isDisabled
|
||||
* @return string
|
||||
*/
|
||||
function form_spinner(string $name, string $label, int $value, array $data_attributes = [], bool $isDisabled = false)
|
||||
|
@ -139,8 +140,9 @@ function form_info($label, $text = '')
|
|||
* @param string $name
|
||||
* @param string $label
|
||||
* @param string $class
|
||||
* @param bool $wrapForm
|
||||
* @param bool $wrapForm
|
||||
* @param string $buttonType
|
||||
* @param string $title
|
||||
* @param array $dataAttributes
|
||||
* @return string
|
||||
*/
|
||||
|
|
|
@ -116,7 +116,7 @@ function check_date($input, $error_message = null, $null_allowed = false, $time_
|
|||
} else {
|
||||
$time = Carbon::createFromFormat('Y-m-d', $trimmed_input);
|
||||
}
|
||||
} catch (InvalidArgumentException $e) {
|
||||
} catch (InvalidArgumentException) {
|
||||
$time = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -302,7 +302,7 @@ class ShiftCalendarRenderer
|
|||
*/
|
||||
private function calcBlocksPerSlot()
|
||||
{
|
||||
return ceil(
|
||||
return (int) ceil(
|
||||
($this->getLastBlockEndTime() - $this->getFirstBlockStartTime())
|
||||
/ ShiftCalendarRenderer::SECONDS_PER_ROW
|
||||
);
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
&-40 {
|
||||
// >= 40 bars
|
||||
--barchart-bar-margin: 1px;
|
||||
--barchart-bar-margin: 0.5px;
|
||||
--barchart-group-margin: 0.5%;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ class ConfigServiceProvider extends ServiceProvider
|
|||
try {
|
||||
/** @var EventConfig[] $values */
|
||||
$values = $this->eventConfig->newQuery()->get(['name', 'value']);
|
||||
} catch (QueryException $e) {
|
||||
} catch (QueryException) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ declare(strict_types=1);
|
|||
namespace Engelsystem\Controllers;
|
||||
|
||||
use Carbon\CarbonImmutable;
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use Engelsystem\Config\Config;
|
||||
use Engelsystem\Helpers\BarChart;
|
||||
use Engelsystem\Http\Response;
|
||||
|
@ -60,26 +62,26 @@ class DesignController extends BaseController
|
|||
}
|
||||
|
||||
$themes = $this->config->get('themes');
|
||||
$date = new \DateTimeImmutable();
|
||||
$date = new DateTimeImmutable();
|
||||
$data = [
|
||||
'demo_user' => $demoUser,
|
||||
'demo_user_2' => $demoUser2,
|
||||
'themes' => $themes,
|
||||
'bar_chart' => BarChart::render(...BarChart::generateChartDemoData(23)),
|
||||
|
||||
'timestamp30m' => $date->add(new \DateInterval('PT30M')),
|
||||
'timestamp59m' => $date->add(new \DateInterval('PT59M')),
|
||||
'timestamp1h' => $date->add(new \DateInterval('PT1H')),
|
||||
'timestamp1h30m' => $date->add(new \DateInterval('PT1H30M')),
|
||||
'timestamp1h31m' => $date->add(new \DateInterval('PT1H31M')),
|
||||
'timestamp2h' => $date->add(new \DateInterval('PT2H')),
|
||||
'timestamp2d' => $date->add(new \DateInterval('P2D')),
|
||||
'timestamp3m' => $date->add(new \DateInterval('P3M')),
|
||||
'timestamp22y' => $date->add(new \DateInterval('P22Y')),
|
||||
'timestamp30s' => $date->add(new \DateInterval('PT30S')),
|
||||
'timestamp30m' => $date->add(new DateInterval('PT30M')),
|
||||
'timestamp59m' => $date->add(new DateInterval('PT59M')),
|
||||
'timestamp1h' => $date->add(new DateInterval('PT1H')),
|
||||
'timestamp1h30m' => $date->add(new DateInterval('PT1H30M')),
|
||||
'timestamp1h31m' => $date->add(new DateInterval('PT1H31M')),
|
||||
'timestamp2h' => $date->add(new DateInterval('PT2H')),
|
||||
'timestamp2d' => $date->add(new DateInterval('P2D')),
|
||||
'timestamp3m' => $date->add(new DateInterval('P3M')),
|
||||
'timestamp22y' => $date->add(new DateInterval('P22Y')),
|
||||
'timestamp30s' => $date->add(new DateInterval('PT30S')),
|
||||
|
||||
'timestamp30mago' => $date->sub(new \DateInterval('PT30M')),
|
||||
'timestamp45mago' => $date->sub(new \DateInterval('PT45M')),
|
||||
'timestamp30mago' => $date->sub(new DateInterval('PT30M')),
|
||||
'timestamp45mago' => $date->sub(new DateInterval('PT45M')),
|
||||
'selectOptions' => $selectOptions,
|
||||
'dateSelectOptions' => $dateSelectOptions,
|
||||
];
|
||||
|
|
|
@ -48,7 +48,7 @@ class Controller extends BaseController
|
|||
$oauthProviders = $this->config->get('oauth');
|
||||
foreach ($userOauth as $key => $oauth) {
|
||||
$provider = $oauth['labels']['provider'];
|
||||
$name = isset($oauthProviders[$provider]['name']) ? $oauthProviders[$provider]['name'] : $provider;
|
||||
$name = $oauthProviders[$provider]['name'] ?? $provider;
|
||||
$userOauth[$key]['labels']['name'] = $name;
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ class Controller extends BaseController
|
|||
$data['scrape_memory_bytes'] = [
|
||||
'type' => 'gauge',
|
||||
'help' => 'Memory usage of the current request',
|
||||
memory_get_usage(false),
|
||||
memory_get_usage(),
|
||||
];
|
||||
|
||||
return $this->response
|
||||
|
@ -215,7 +215,7 @@ class Controller extends BaseController
|
|||
$data = [
|
||||
'user_count' => $this->stats->usersState() + $this->stats->usersState(null, false),
|
||||
'arrived_user_count' => $this->stats->usersState(),
|
||||
'done_work_hours' => round($this->stats->workSeconds(true) / 60 / 60, 0),
|
||||
'done_work_hours' => round($this->stats->workSeconds(true) / 60 / 60),
|
||||
'users_in_action' => $this->stats->currentlyWorkingUsers(),
|
||||
];
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ class MetricsEngine implements EngineInterface
|
|||
);
|
||||
}
|
||||
|
||||
$sum = isset($row['sum']) ? $row['sum'] : 'NaN';
|
||||
$sum = $row['sum'] ?? 'NaN';
|
||||
$count = $row['value']['+Inf'];
|
||||
$return[] = $this->formatData($name . '_sum', $data + ['value' => $sum]);
|
||||
$return[] = $this->formatData($name . '_count', $data + ['value' => $count]);
|
||||
|
|
|
@ -156,9 +156,6 @@ class NewsController extends BaseController
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*/
|
||||
protected function renderView(string $page, array $data): Response
|
||||
{
|
||||
return $this->response->withView($page, $data);
|
||||
|
|
|
@ -424,7 +424,7 @@ class SettingsController extends BaseController
|
|||
protected function checkOauthHidden(): bool
|
||||
{
|
||||
foreach (config('oauth') as $config) {
|
||||
if (empty($config['hidden']) || !$config['hidden']) {
|
||||
if (empty($config['hidden'])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,8 +53,7 @@ class Handler
|
|||
$this->request = new Request();
|
||||
}
|
||||
|
||||
$handler = isset($this->handler[$this->environment->value])
|
||||
? $this->handler[$this->environment->value] : new Legacy();
|
||||
$handler = $this->handler[$this->environment->value] ?? new Legacy();
|
||||
$handler->report($e);
|
||||
ob_start();
|
||||
$handler->render($this->request, $e);
|
||||
|
@ -65,7 +64,12 @@ class Handler
|
|||
return $output;
|
||||
}
|
||||
|
||||
http_response_code(500);
|
||||
if (!headers_sent()) {
|
||||
// @codeCoverageIgnoreStart
|
||||
http_response_code(500);
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
ob_end_flush();
|
||||
|
||||
$this->terminateApplicationImmediately();
|
||||
|
|
|
@ -40,7 +40,7 @@ class Legacy implements HandlerInterface
|
|||
|
||||
try {
|
||||
$this->log->critical('', ['exception' => $e]);
|
||||
} catch (Throwable $e) {
|
||||
} catch (Throwable) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,5 @@ class NullHandler extends Legacy
|
|||
{
|
||||
public function render(Request $request, Throwable $e): void
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class Carbon extends \Carbon\Carbon
|
|||
public static function createTimestampFromDatetime(string $value): ?int
|
||||
{
|
||||
$carbon = self::createFromDateTime($value);
|
||||
return $carbon === null ? null : $carbon->timestamp;
|
||||
return $carbon?->timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Engelsystem\Helpers;
|
|||
class DayOfEvent
|
||||
{
|
||||
/**
|
||||
* @return ?int The current day of the event.
|
||||
* @return ?int The current day of the event.
|
||||
* If `event_has_day0` is set to true in config, the first day of the event will be 0, else 1.
|
||||
* Returns null if "event_start" is not set.
|
||||
*/
|
||||
|
|
|
@ -59,7 +59,7 @@ class Translator
|
|||
try {
|
||||
$translated = call_user_func_array([$translator, $type], $parameters);
|
||||
break;
|
||||
} catch (TranslationNotFound $e) {
|
||||
} catch (TranslationNotFound) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Engelsystem\Http;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Nyholm\Psr7\UploadedFile;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
|
@ -124,7 +125,7 @@ class Request extends SymfonyRequest implements ServerRequestInterface
|
|||
*
|
||||
* @param string $method Case-sensitive method.
|
||||
* @return static
|
||||
* @throws \InvalidArgumentException for invalid HTTP methods.
|
||||
* @throws InvalidArgumentException for invalid HTTP methods.
|
||||
*/
|
||||
public function withMethod(mixed $method): static
|
||||
{
|
||||
|
@ -309,7 +310,7 @@ class Request extends SymfonyRequest implements ServerRequestInterface
|
|||
*
|
||||
* @param array $uploadedFiles An array tree of UploadedFileInterface instances.
|
||||
* @return static
|
||||
* @throws \InvalidArgumentException if an invalid structure is provided.
|
||||
* @throws InvalidArgumentException if an invalid structure is provided.
|
||||
*/
|
||||
public function withUploadedFiles(array $uploadedFiles): static
|
||||
{
|
||||
|
@ -381,7 +382,7 @@ class Request extends SymfonyRequest implements ServerRequestInterface
|
|||
* @param null|array|object $data The deserialized body data. This will
|
||||
* typically be in an array or object.
|
||||
* @return static
|
||||
* @throws \InvalidArgumentException if an unsupported argument type is
|
||||
* @throws InvalidArgumentException if an unsupported argument type is
|
||||
* provided.
|
||||
*/
|
||||
public function withParsedBody(mixed $data): static
|
||||
|
|
|
@ -42,8 +42,6 @@ class UrlGenerator implements UrlGeneratorInterface
|
|||
|
||||
/**
|
||||
* Prepend the auto-detected or configured app base path and domain
|
||||
*
|
||||
* @param $path
|
||||
*/
|
||||
protected function generateUrl(string $path): string
|
||||
{
|
||||
|
|
|
@ -9,7 +9,7 @@ use Engelsystem\Http\Request;
|
|||
|
||||
trait ValidatesRequest
|
||||
{
|
||||
protected Validator $validator;
|
||||
protected ?Validator $validator;
|
||||
|
||||
protected function validate(Request $request, array $rules): array
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@ class Validator
|
|||
$v = new RespectValidator();
|
||||
$v->with('\\Engelsystem\\Http\\Validation\\Rules', true);
|
||||
|
||||
$value = isset($data[$key]) ? $data[$key] : null;
|
||||
$value = $data[$key] ?? null;
|
||||
$values = explode('|', $values);
|
||||
|
||||
// Rules that have side effects on others like inverting the result with not and making them optional
|
||||
|
|
|
@ -65,14 +65,14 @@ class ErrorHandler implements MiddlewareInterface
|
|||
if ($request instanceof Request) {
|
||||
$response->withInput(Arr::except($request->request->all(), $this->formIgnore));
|
||||
}
|
||||
} catch (ModelNotFoundException $e) {
|
||||
} catch (ModelNotFoundException) {
|
||||
$response = $this->createResponse('', 404);
|
||||
}
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
$contentType = $response->getHeader('content-type');
|
||||
$contentType = array_shift($contentType);
|
||||
if (!$contentType && strpos($response->getBody()?->getContents() ?? '', '<html') !== false) {
|
||||
if (!$contentType && str_contains($response->getBody()?->getContents() ?? '', '<html')) {
|
||||
$contentType = 'text/html';
|
||||
}
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ class LegacyMiddleware implements MiddlewareInterface
|
|||
return response($content, $page);
|
||||
}
|
||||
|
||||
if (strpos((string) $content, '<html') !== false) {
|
||||
if (str_contains($content, '<html')) {
|
||||
return response($content);
|
||||
}
|
||||
|
||||
|
@ -158,8 +158,7 @@ class LegacyMiddleware implements MiddlewareInterface
|
|||
'title' => $title,
|
||||
'content' => msg() . $content,
|
||||
]
|
||||
),
|
||||
200
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,6 +91,6 @@ class EventConfig extends BaseModel
|
|||
*/
|
||||
protected function getValueCast(string $value): ?string
|
||||
{
|
||||
return isset($this->valueCasts[$value]) ? $this->valueCasts[$value] : null;
|
||||
return $this->valueCasts[$value] ?? null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,14 @@ interface EngineInterface
|
|||
*/
|
||||
public function get(string $path, array $data = []): string;
|
||||
|
||||
/**
|
||||
* Check if the engine can render the specified template
|
||||
*/
|
||||
public function canRender(string $path): bool;
|
||||
|
||||
/**
|
||||
* Add shared variables
|
||||
*
|
||||
* @param string|mixed[] $key
|
||||
*/
|
||||
public function share(string|array $key, mixed $value = null): void;
|
||||
|
|
|
@ -16,10 +16,8 @@ class HtmlEngine extends Engine
|
|||
$data = array_replace_recursive($this->sharedData, $data);
|
||||
$template = file_get_contents($path);
|
||||
|
||||
if (is_array($data)) {
|
||||
foreach ($data as $name => $content) {
|
||||
$template = str_replace('%' . $name . '%', $content, $template);
|
||||
}
|
||||
foreach ($data as $name => $content) {
|
||||
$template = str_replace('%' . $name . '%', $content, $template);
|
||||
}
|
||||
|
||||
return $template;
|
||||
|
|
|
@ -28,9 +28,7 @@ class Renderer
|
|||
return $renderer->get($template, $data);
|
||||
}
|
||||
|
||||
if ($this->logger) {
|
||||
$this->logger->critical('Unable to find a renderer for template file "{file}"', ['file' => $template]);
|
||||
}
|
||||
$this->logger?->critical('Unable to find a renderer for template file "{file}"', ['file' => $template]);
|
||||
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -160,7 +160,6 @@ class ApplicationTest extends TestCase
|
|||
->willReturnOnConsecutiveCalls([$serviceProvider], $middleware);
|
||||
|
||||
$property = (new ReflectionClass($app))->getProperty('serviceProviders');
|
||||
$property->setAccessible(true);
|
||||
$property->setValue($app, [$serviceProvider]);
|
||||
|
||||
$app->bootstrap($config);
|
||||
|
|
|
@ -22,7 +22,6 @@ class RoutesFileTest extends TestCase
|
|||
->onlyMethods(['addRoute'])
|
||||
->getMock();
|
||||
|
||||
$this->doesNotPerformAssertions();
|
||||
/** @see RouteCollector::addRoute */
|
||||
$route->expects($this->any())
|
||||
->method('addRoute')
|
||||
|
|
|
@ -13,7 +13,6 @@ use Engelsystem\Test\Unit\Controllers\ControllerTest;
|
|||
|
||||
class FaqControllerTest extends ControllerTest
|
||||
{
|
||||
/** @var array */
|
||||
protected array $data = [
|
||||
'question' => 'Foo?',
|
||||
'text' => 'Bar!',
|
||||
|
|
|
@ -21,7 +21,6 @@ class NewsControllerTest extends ControllerTest
|
|||
protected Authenticator|MockObject $auth;
|
||||
protected EventDispatcher|MockObject $eventDispatcher;
|
||||
|
||||
/** @var array */
|
||||
protected array $data = [
|
||||
[
|
||||
'title' => 'Foo',
|
||||
|
|
|
@ -136,7 +136,7 @@ class UserShirtControllerTest extends ControllerTest
|
|||
try {
|
||||
$controller->saveShirt($request);
|
||||
self::fail('Expected exception was not raised');
|
||||
} catch (ValidationException $e) {
|
||||
} catch (ValidationException) {
|
||||
// ignore
|
||||
}
|
||||
$user = User::find(1);
|
||||
|
|
|
@ -99,7 +99,7 @@ class AuthControllerTest extends ControllerTest
|
|||
try {
|
||||
$controller->postLogin($request);
|
||||
$this->fail('Login without credentials possible');
|
||||
} catch (ValidationException $e) {
|
||||
} catch (ValidationException) {
|
||||
}
|
||||
|
||||
// Missing password
|
||||
|
@ -107,7 +107,7 @@ class AuthControllerTest extends ControllerTest
|
|||
try {
|
||||
$controller->postLogin($request);
|
||||
$this->fail('Login without password possible');
|
||||
} catch (ValidationException $e) {
|
||||
} catch (ValidationException) {
|
||||
}
|
||||
|
||||
// No user found
|
||||
|
|
|
@ -23,7 +23,6 @@ class NewsControllerTest extends ControllerTest
|
|||
|
||||
protected Authenticator|MockObject $auth;
|
||||
|
||||
/** @var array */
|
||||
protected array $data = [
|
||||
[
|
||||
'title' => 'Foo',
|
||||
|
|
|
@ -459,10 +459,10 @@ class OAuthControllerTest extends TestCase
|
|||
$this->assertEquals(4242424242, $this->session->get('oauth2_expires_at')->unix());
|
||||
$this->assertFalse($this->session->get('oauth2_enable_password'));
|
||||
$this->assertEquals(null, $this->session->get('oauth2_allow_registration'));
|
||||
$this->assertEquals($this->session->get('form-data-username'), 'username');
|
||||
$this->assertEquals($this->session->get('form-data-email'), 'foo.bar@localhost');
|
||||
$this->assertEquals($this->session->get('form-data-firstname'), 'Foo');
|
||||
$this->assertEquals($this->session->get('form-data-lastname'), 'Bar');
|
||||
$this->assertEquals('username', $this->session->get('form-data-username'));
|
||||
$this->assertEquals('foo.bar@localhost', $this->session->get('form-data-email'));
|
||||
$this->assertEquals('Foo', $this->session->get('form-data-firstname'));
|
||||
$this->assertEquals('Bar', $this->session->get('form-data-lastname'));
|
||||
|
||||
$this->config->set('registration_enabled', false);
|
||||
$this->expectException(HttpNotFound::class);
|
||||
|
@ -539,10 +539,10 @@ class OAuthControllerTest extends TestCase
|
|||
$this->setExpects($controller, 'getProvider', ['testprovider'], $provider, $this->atLeastOnce());
|
||||
|
||||
$controller->index($request);
|
||||
$this->assertEquals($this->session->get('form-data-username'), 'testuser');
|
||||
$this->assertEquals($this->session->get('form-data-email'), 'foo.bar@localhost');
|
||||
$this->assertEquals($this->session->get('form-data-firstname'), 'Test');
|
||||
$this->assertEquals($this->session->get('form-data-lastname'), 'Tester');
|
||||
$this->assertEquals('testuser', $this->session->get('form-data-username'));
|
||||
$this->assertEquals('foo.bar@localhost', $this->session->get('form-data-email'));
|
||||
$this->assertEquals('Test', $this->session->get('form-data-firstname'));
|
||||
$this->assertEquals('Tester', $this->session->get('form-data-lastname'));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ class PasswordResetControllerTest extends ControllerTest
|
|||
use ArraySubsetAsserts;
|
||||
use HasDatabase;
|
||||
|
||||
/** @var array */
|
||||
protected array $args = [];
|
||||
|
||||
/**
|
||||
|
|
|
@ -188,7 +188,6 @@ final class RegistrationControllerTest extends ControllerTest
|
|||
public function testViewRegistrationDisabled(): void
|
||||
{
|
||||
$this->config->set('registration_enabled', false);
|
||||
$request = $this->request->withParsedBody([]);
|
||||
|
||||
// Assert the controller does not call createFromData
|
||||
$this->userFactory
|
||||
|
@ -201,7 +200,7 @@ final class RegistrationControllerTest extends ControllerTest
|
|||
->method('redirectTo')
|
||||
->with('http://localhost/', 302);
|
||||
|
||||
$this->subject->view($request);
|
||||
$this->subject->view();
|
||||
|
||||
// Assert that the error notification is there
|
||||
self::assertEquals(
|
||||
|
|
|
@ -773,8 +773,8 @@ class SettingsControllerTest extends ControllerTest
|
|||
|
||||
$this->controller->saveIfsgCertificate($this->request);
|
||||
|
||||
$this->assertEquals(true, $this->user->license->ifsg_certificate_light);
|
||||
$this->assertEquals(false, $this->user->license->ifsg_certificate);
|
||||
$this->assertTrue($this->user->license->ifsg_certificate_light);
|
||||
$this->assertFalse($this->user->license->ifsg_certificate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -803,8 +803,8 @@ class SettingsControllerTest extends ControllerTest
|
|||
|
||||
$this->controller->saveIfsgCertificate($this->request);
|
||||
|
||||
$this->assertEquals(false, $this->user->license->ifsg_certificate_light);
|
||||
$this->assertEquals(false, $this->user->license->ifsg_certificate);
|
||||
$this->assertFalse($this->user->license->ifsg_certificate_light);
|
||||
$this->assertFalse($this->user->license->ifsg_certificate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -831,8 +831,8 @@ class SettingsControllerTest extends ControllerTest
|
|||
|
||||
$this->controller->saveIfsgCertificate($this->request);
|
||||
|
||||
$this->assertEquals(false, $this->user->license->ifsg_certificate_light);
|
||||
$this->assertEquals(true, $this->user->license->ifsg_certificate);
|
||||
$this->assertFalse($this->user->license->ifsg_certificate_light);
|
||||
$this->assertTrue($this->user->license->ifsg_certificate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -859,8 +859,8 @@ class SettingsControllerTest extends ControllerTest
|
|||
|
||||
$this->controller->saveIfsgCertificate($this->request);
|
||||
|
||||
$this->assertEquals(false, $this->user->license->ifsg_certificate_light);
|
||||
$this->assertEquals(true, $this->user->license->ifsg_certificate);
|
||||
$this->assertFalse($this->user->license->ifsg_certificate_light);
|
||||
$this->assertTrue($this->user->license->ifsg_certificate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -154,7 +154,7 @@ class MigrateTest extends TestCase
|
|||
$this->setExpects($migration, 'getMigrations', null, collect([
|
||||
['migration' => '1234_01_23_123456_init_foo', 'path' => '/foo'],
|
||||
]));
|
||||
$this->setExpects($migration, 'getMigrated', null, collect([]));
|
||||
$this->setExpects($migration, 'getMigrated', null, collect());
|
||||
$migration->expects($this->once())
|
||||
->method('migrate')
|
||||
->willReturnCallback(function (): void {
|
||||
|
|
|
@ -9,7 +9,6 @@ use Engelsystem\Test\Unit\TestCase;
|
|||
|
||||
class EventDispatcherTest extends TestCase
|
||||
{
|
||||
/** @var array */
|
||||
protected array $firedEvents = [];
|
||||
|
||||
/**
|
||||
|
|
|
@ -72,7 +72,6 @@ class XmlParserTest extends TestCase
|
|||
$this->assertEquals('Testing', $tracks[0]->getName());
|
||||
$this->assertEquals('#dead55', $tracks[0]->getColor());
|
||||
$this->assertEquals('testing', $tracks[0]->getSlug());
|
||||
;
|
||||
|
||||
/** @var Day $day */
|
||||
$day = Arr::first($schedule->getDays());
|
||||
|
|
|
@ -17,7 +17,11 @@ class UserModelImplementation extends User
|
|||
|
||||
public static ?string $apiKey = null;
|
||||
|
||||
public function find(mixed $id, array $columns = ['*']): ?User
|
||||
/**
|
||||
* @param mixed $id
|
||||
* @param array $columns
|
||||
*/
|
||||
public function find($id, $columns = ['*']): ?User // phpcs:ignore
|
||||
{
|
||||
if ($id != static::$id) {
|
||||
throw new InvalidArgumentException('Wrong user ID searched');
|
||||
|
@ -29,9 +33,9 @@ class UserModelImplementation extends User
|
|||
/**
|
||||
* @return User[]|Collection|QueryBuilder
|
||||
*/
|
||||
public static function whereApiKey(string $apiKey): array|Collection|QueryBuilder
|
||||
public static function whereApiKey(string $value): array|Collection|QueryBuilder
|
||||
{
|
||||
if ($apiKey != static::$apiKey) {
|
||||
if ($value != static::$apiKey) {
|
||||
throw new InvalidArgumentException('Wrong api key searched');
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ class ShirtSizeTest extends ServiceProviderTest
|
|||
*/
|
||||
public function provideTestValidateData(): array
|
||||
{
|
||||
$data = [
|
||||
return [
|
||||
'empty string' => ['', false],
|
||||
'null' => [null, false],
|
||||
'0' => [0, false],
|
||||
|
@ -34,8 +34,6 @@ class ShirtSizeTest extends ServiceProviderTest
|
|||
'"M" (known value)' => ['M', true],
|
||||
'"L" (unknown value)' => ['L', false],
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,7 +20,6 @@ use Symfony\Component\Mailer\Transport\TransportInterface;
|
|||
|
||||
class MailerServiceProviderTest extends ServiceProviderTest
|
||||
{
|
||||
/** @var array */
|
||||
protected array $defaultConfig = [
|
||||
'app_name' => 'Engelsystem App',
|
||||
'email' => [
|
||||
|
@ -33,7 +32,6 @@ class MailerServiceProviderTest extends ServiceProviderTest
|
|||
],
|
||||
];
|
||||
|
||||
/** @var array */
|
||||
protected array $smtpConfig = [
|
||||
'email' => [
|
||||
'driver' => 'smtp',
|
||||
|
|
|
@ -36,7 +36,6 @@ class DispatcherTest extends TestCase
|
|||
|
||||
$reflection = new Reflection(get_class($dispatcher));
|
||||
$property = $reflection->getProperty('container');
|
||||
$property->setAccessible(true);
|
||||
$this->assertEquals($container, $property->getValue($dispatcher));
|
||||
}
|
||||
|
||||
|
@ -66,7 +65,6 @@ class DispatcherTest extends TestCase
|
|||
|
||||
$reflection = new Reflection(get_class($dispatcher));
|
||||
$property = $reflection->getProperty('next');
|
||||
$property->setAccessible(true);
|
||||
|
||||
$this->assertEquals($handler, $property->getValue($dispatcher));
|
||||
}
|
||||
|
@ -113,7 +111,6 @@ class DispatcherTest extends TestCase
|
|||
|
||||
$reflection = new Reflection(get_class($dispatcher));
|
||||
$property = $reflection->getProperty('next');
|
||||
$property->setAccessible(true);
|
||||
$property->setValue($dispatcher, $handler);
|
||||
|
||||
$return = $dispatcher->handle($request);
|
||||
|
@ -193,7 +190,6 @@ class DispatcherTest extends TestCase
|
|||
|
||||
$reflection = new Reflection(get_class($middleware));
|
||||
$property = $reflection->getProperty('container');
|
||||
$property->setAccessible(true);
|
||||
|
||||
$this->assertEquals($container, $property->getValue($middleware));
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ class RequestHandlerTest extends TestCase
|
|||
|
||||
$reflection = new Reflection(get_class($handler));
|
||||
$property = $reflection->getProperty('container');
|
||||
$property->setAccessible(true);
|
||||
|
||||
$this->assertEquals($container, $property->getValue($handler));
|
||||
}
|
||||
|
|
|
@ -93,8 +93,6 @@ class EventConfigTest extends ModelTest
|
|||
{
|
||||
$model = new EventConfig(['name' => 'foo', 'value' => 'bar']);
|
||||
$this->assertEquals('bar', $model->value);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,6 @@ class NewsCommentsTest extends ModelTest
|
|||
|
||||
private News $news;
|
||||
|
||||
/** @var array */
|
||||
private array $newsCommentData;
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,6 @@ use Engelsystem\Models\User\User;
|
|||
*/
|
||||
class NewsTest extends ModelTest
|
||||
{
|
||||
/** @var array */
|
||||
private array $newsData;
|
||||
|
||||
private User $user;
|
||||
|
|
|
@ -9,6 +9,7 @@ use Engelsystem\Test\Unit\TestCase;
|
|||
use Exception;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Twig\Node\Node as TwigNode;
|
||||
use Twig\TwigFilter;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
abstract class ExtensionTest extends TestCase
|
||||
|
@ -35,9 +36,9 @@ abstract class ExtensionTest extends TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* Assert that a twig function was registered
|
||||
* Assert that a twig function or filter was registered
|
||||
*
|
||||
* @param TwigFunction[] $functions
|
||||
* @param TwigFunction[]|TwigFilter[] $functions
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function assertExtensionExists(
|
||||
|
|
|
@ -19,7 +19,6 @@ class TwigLoaderTest extends TestCase
|
|||
|
||||
$reflection = new Reflection(get_class($loader));
|
||||
$property = $reflection->getProperty('cache');
|
||||
$property->setAccessible(true);
|
||||
|
||||
$realPath = __DIR__ . '/Stub/foo.twig';
|
||||
$property->setValue($loader, ['Stub/foo.twig' => $realPath]);
|
||||
|
|
|
@ -197,7 +197,6 @@ class TwigServiceProviderTest extends ServiceProviderTest
|
|||
$reflection = new Reflection(get_class($serviceProvider));
|
||||
|
||||
$property = $reflection->getProperty('extensions');
|
||||
$property->setAccessible(true);
|
||||
|
||||
$property->setValue($serviceProvider, $extensions);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue