Use constructor property promotion

Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
This commit is contained in:
Michael Weimann 2022-12-15 19:57:02 +01:00
parent b004f865b4
commit 61139e03c3
No known key found for this signature in database
GPG Key ID: 34F0524D4DA694A1
73 changed files with 184 additions and 759 deletions

View File

@ -36,5 +36,6 @@
<exclude-pattern>/includes</exclude-pattern> <exclude-pattern>/includes</exclude-pattern>
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification" /> <exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification" />
</rule> </rule>
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion" />
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment" /> <rule ref="SlevomatCodingStandard.Commenting.EmptyComment" />
</ruleset> </ruleset>

View File

@ -11,16 +11,9 @@ class SetAdminPassword extends Migration
{ {
use Reference; use Reference;
protected Authenticator $auth; public function __construct(SchemaBuilder $schemaBuilder, protected Authenticator $auth, protected Config $config)
protected Config $config;
public function __construct(SchemaBuilder $schemaBuilder, Authenticator $auth, Config $config)
{ {
parent::__construct($schemaBuilder); parent::__construct($schemaBuilder);
$this->auth = $auth;
$this->config = $config;
} }
/** /**

View File

@ -13,22 +13,14 @@ use Symfony\Component\Mailer\Exception\TransportException;
class Shift class Shift
{ {
/** @var LoggerInterface */
protected LoggerInterface $log;
/** @var EngelsystemMailer */
protected EngelsystemMailer $mailer;
/** /**
* @param LoggerInterface $log * @param LoggerInterface $log
* @param EngelsystemMailer $mailer * @param EngelsystemMailer $mailer
*/ */
public function __construct( public function __construct(
LoggerInterface $log, protected LoggerInterface $log,
EngelsystemMailer $mailer protected EngelsystemMailer $mailer
) { ) {
$this->log = $log;
$this->mailer = $mailer;
} }
/** /**

View File

@ -53,9 +53,6 @@ class ShiftSignupState
*/ */
public const NOT_ARRIVED = 'NOT_ARRIVED'; public const NOT_ARRIVED = 'NOT_ARRIVED';
/** @var string */
private $state;
/** @var int */ /** @var int */
private $freeEntries; private $freeEntries;
@ -65,9 +62,8 @@ class ShiftSignupState
* @param string $state * @param string $state
* @param int $free_entries * @param int $free_entries
*/ */
public function __construct($state, $free_entries) public function __construct(private $state, $free_entries)
{ {
$this->state = $state;
$this->freeEntries = $free_entries; $this->freeEntries = $free_entries;
} }

View File

@ -29,9 +29,6 @@ class ShiftsFilter
/** @var int[] */ /** @var int[] */
private $filled; private $filled;
/** @var int[] */
private $rooms;
/** @var int[] */ /** @var int[] */
private $types; private $types;
@ -48,9 +45,8 @@ class ShiftsFilter
* @param int[] $rooms * @param int[] $rooms
* @param int[] $angelTypes * @param int[] $angelTypes
*/ */
public function __construct($user_shifts_admin = false, $rooms = [], $angelTypes = []) public function __construct($user_shifts_admin = false, private $rooms = [], $angelTypes = [])
{ {
$this->rooms = $rooms;
$this->types = $angelTypes; $this->types = $angelTypes;
$this->filled = [ $this->filled = [

View File

@ -8,20 +8,12 @@ namespace Engelsystem;
*/ */
class ValidationResult class ValidationResult
{ {
/** @var bool */
private $valid;
/** @var mixed */
private $value;
/** /**
* @param boolean $valid Is the value valid? * @param boolean $valid Is the value valid?
* @param mixed $value The validated value * @param mixed $value The validated value
*/ */
public function __construct($valid, $value) public function __construct(private $valid, private $value)
{ {
$this->valid = $valid;
$this->value = $value;
} }
/** /**

View File

@ -9,15 +9,6 @@ use Exception;
*/ */
class ShiftCalendarLane class ShiftCalendarLane
{ {
/** @var int */
private $firstBlockStartTime;
/** @var int */
private $blockCount;
/** @var string */
private $header;
/** @var array[] */ /** @var array[] */
private $shifts = []; private $shifts = [];
@ -28,11 +19,8 @@ class ShiftCalendarLane
* @param int $firstBlockStartTime Unix timestamp * @param int $firstBlockStartTime Unix timestamp
* @param int $blockCount * @param int $blockCount
*/ */
public function __construct($header, $firstBlockStartTime, $blockCount) public function __construct(private $header, private $firstBlockStartTime, private $blockCount)
{ {
$this->header = $header;
$this->firstBlockStartTime = $firstBlockStartTime;
$this->blockCount = $blockCount;
} }
/** /**

View File

@ -42,12 +42,6 @@ class ShiftCalendarRenderer
/** @var int */ /** @var int */
private $blocksPerSlot = null; private $blocksPerSlot = null;
/** @var array[] */
private $needed_angeltypes;
/** @var array[] */
private $shift_entries;
/** /**
* ShiftCalendarRenderer constructor. * ShiftCalendarRenderer constructor.
* *
@ -56,14 +50,12 @@ class ShiftCalendarRenderer
* @param array[] $shift_entries * @param array[] $shift_entries
* @param ShiftsFilter $shiftsFilter * @param ShiftsFilter $shiftsFilter
*/ */
public function __construct($shifts, $needed_angeltypes, $shift_entries, ShiftsFilter $shiftsFilter) public function __construct($shifts, private $needed_angeltypes, private $shift_entries, ShiftsFilter $shiftsFilter)
{ {
$this->shiftsFilter = $shiftsFilter; $this->shiftsFilter = $shiftsFilter;
$this->firstBlockStartTime = $this->calcFirstBlockStartTime($shifts); $this->firstBlockStartTime = $this->calcFirstBlockStartTime($shifts);
$this->lastBlockEndTime = $this->calcLastBlockEndTime($shifts); $this->lastBlockEndTime = $this->calcLastBlockEndTime($shifts);
$this->lanes = $this->assignShiftsToLanes($shifts); $this->lanes = $this->assignShiftsToLanes($shifts);
$this->needed_angeltypes = $needed_angeltypes;
$this->shift_entries = $shift_entries;
} }
/** /**

View File

@ -6,15 +6,12 @@ use Engelsystem\Application;
abstract class ServiceProvider abstract class ServiceProvider
{ {
protected Application $app;
/** /**
* ServiceProvider constructor. * ServiceProvider constructor.
* *
*/ */
public function __construct(Application $app) public function __construct(protected Application $app)
{ {
$this->app = $app;
} }
/** /**

View File

@ -14,14 +14,8 @@ class FaqController extends BaseController
{ {
use HasUserNotifications; use HasUserNotifications;
protected LoggerInterface $log;
protected Faq $faq;
protected Redirector $redirect; protected Redirector $redirect;
protected Response $response;
/** @var array */ /** @var array */
protected array $permissions = [ protected array $permissions = [
'faq.view', 'faq.view',
@ -29,15 +23,12 @@ class FaqController extends BaseController
]; ];
public function __construct( public function __construct(
LoggerInterface $log, protected LoggerInterface $log,
Faq $faq, protected Faq $faq,
Redirector $redirector, Redirector $redirector,
Response $response protected Response $response
) { ) {
$this->log = $log;
$this->faq = $faq;
$this->redirect = $redirector; $this->redirect = $redirector;
$this->response = $response;
} }
public function edit(Request $request): Response public function edit(Request $request): Response

View File

@ -9,19 +9,13 @@ use Engelsystem\Models\LogEntry;
class LogsController extends BaseController class LogsController extends BaseController
{ {
protected LogEntry $log;
protected Response $response;
/** @var array */ /** @var array */
protected array $permissions = [ protected array $permissions = [
'admin_log', 'admin_log',
]; ];
public function __construct(LogEntry $log, Response $response) public function __construct(protected LogEntry $log, protected Response $response)
{ {
$this->log = $log;
$this->response = $response;
} }
public function index(Request $request): Response public function index(Request $request): Response

View File

@ -15,33 +15,21 @@ class NewsController extends BaseController
{ {
use HasUserNotifications; use HasUserNotifications;
protected Authenticator $auth;
protected LoggerInterface $log;
protected News $news;
protected Redirector $redirect; protected Redirector $redirect;
protected Response $response;
/** @var array */ /** @var array */
protected array $permissions = [ protected array $permissions = [
'admin_news', 'admin_news',
]; ];
public function __construct( public function __construct(
Authenticator $auth, protected Authenticator $auth,
LoggerInterface $log, protected LoggerInterface $log,
News $news, protected News $news,
Redirector $redirector, Redirector $redirector,
Response $response protected Response $response
) { ) {
$this->auth = $auth;
$this->log = $log;
$this->news = $news;
$this->redirect = $redirector; $this->redirect = $redirector;
$this->response = $response;
} }
public function edit(Request $request): Response public function edit(Request $request): Response

View File

@ -16,16 +16,8 @@ class QuestionsController extends BaseController
{ {
use HasUserNotifications; use HasUserNotifications;
protected Authenticator $auth;
protected LoggerInterface $log;
protected Question $question;
protected Redirector $redirect; protected Redirector $redirect;
protected Response $response;
/** @var array */ /** @var array */
protected array $permissions = [ protected array $permissions = [
'question.add', 'question.add',
@ -33,17 +25,13 @@ class QuestionsController extends BaseController
]; ];
public function __construct( public function __construct(
Authenticator $auth, protected Authenticator $auth,
LoggerInterface $log, protected LoggerInterface $log,
Question $question, protected Question $question,
Redirector $redirector, Redirector $redirector,
Response $response protected Response $response
) { ) {
$this->auth = $auth;
$this->log = $log;
$this->question = $question;
$this->redirect = $redirector; $this->redirect = $redirector;
$this->response = $response;
} }
public function index(): Response public function index(): Response

View File

@ -16,18 +16,8 @@ class UserShirtController extends BaseController
{ {
use HasUserNotifications; use HasUserNotifications;
protected Authenticator $auth;
protected Config $config;
protected LoggerInterface $log;
protected Redirector $redirect; protected Redirector $redirect;
protected Response $response;
protected User $user;
/** @var array */ /** @var array */
protected array $permissions = [ protected array $permissions = [
'editShirt' => 'user.edit.shirt', 'editShirt' => 'user.edit.shirt',
@ -35,19 +25,14 @@ class UserShirtController extends BaseController
]; ];
public function __construct( public function __construct(
Authenticator $auth, protected Authenticator $auth,
Config $config, protected Config $config,
LoggerInterface $log, protected LoggerInterface $log,
Redirector $redirector, Redirector $redirector,
Response $response, protected Response $response,
User $user protected User $user
) { ) {
$this->auth = $auth;
$this->config = $config;
$this->log = $log;
$this->redirect = $redirector; $this->redirect = $redirector;
$this->response = $response;
$this->user = $user;
} }
public function editShirt(Request $request): Response public function editShirt(Request $request): Response

View File

@ -19,41 +19,23 @@ class UserWorkLogController extends BaseController
{ {
use HasUserNotifications; use HasUserNotifications;
protected Authenticator $auth;
protected Config $config;
protected LoggerInterface $log;
protected Worklog $worklog;
protected Redirector $redirect; protected Redirector $redirect;
protected Response $response;
protected User $user;
/** @var array */ /** @var array */
protected array $permissions = [ protected array $permissions = [
'admin_user_worklog', 'admin_user_worklog',
]; ];
public function __construct( public function __construct(
Authenticator $auth, protected Authenticator $auth,
Config $config, protected Config $config,
LoggerInterface $log, protected LoggerInterface $log,
Worklog $worklog, protected Worklog $worklog,
Redirector $redirector, Redirector $redirector,
Response $response, protected Response $response,
User $user protected User $user
) { ) {
$this->auth = $auth;
$this->config = $config;
$this->log = $log;
$this->worklog = $worklog;
$this->redirect = $redirector; $this->redirect = $redirector;
$this->response = $response;
$this->user = $user;
} }
public function editWorklog(Request $request): Response public function editWorklog(Request $request): Response

View File

@ -6,11 +6,8 @@ use Engelsystem\Http\Response;
class ApiController extends BaseController class ApiController extends BaseController
{ {
protected Response $response; public function __construct(protected Response $response)
public function __construct(Response $response)
{ {
$this->response = $response;
} }
public function index(): Response public function index(): Response

View File

@ -15,16 +15,6 @@ class AuthController extends BaseController
{ {
use HasUserNotifications; use HasUserNotifications;
protected Response $response;
protected SessionInterface $session;
protected Redirector $redirect;
protected Config $config;
protected Authenticator $auth;
/** @var array */ /** @var array */
protected array $permissions = [ protected array $permissions = [
'login' => 'login', 'login' => 'login',
@ -32,17 +22,12 @@ class AuthController extends BaseController
]; ];
public function __construct( public function __construct(
Response $response, protected Response $response,
SessionInterface $session, protected SessionInterface $session,
Redirector $redirect, protected Redirector $redirect,
Config $config, protected Config $config,
Authenticator $auth protected Authenticator $auth
) { ) {
$this->response = $response;
$this->session = $session;
$this->redirect = $redirect;
$this->config = $config;
$this->auth = $auth;
} }
public function login(): Response public function login(): Response

View File

@ -8,17 +8,8 @@ use Engelsystem\Http\Response;
class CreditsController extends BaseController class CreditsController extends BaseController
{ {
protected Config $config; public function __construct(protected Response $response, protected Config $config, protected Version $version)
protected Response $response;
protected Version $version;
public function __construct(Response $response, Config $config, Version $version)
{ {
$this->config = $config;
$this->response = $response;
$this->version = $version;
} }
public function index(): Response public function index(): Response

View File

@ -11,14 +11,8 @@ use Engelsystem\Models\User\User;
class DesignController extends BaseController class DesignController extends BaseController
{ {
protected Response $response; public function __construct(protected Response $response, protected Config $config)
protected Config $config;
public function __construct(Response $response, Config $config)
{ {
$this->config = $config;
$this->response = $response;
} }
/** /**

View File

@ -10,25 +10,16 @@ class FaqController extends BaseController
{ {
use HasUserNotifications; use HasUserNotifications;
protected Config $config;
protected Faq $faq;
protected Response $response;
/** @var string[] */ /** @var string[] */
protected array $permissions = [ protected array $permissions = [
'faq.view', 'faq.view',
]; ];
public function __construct( public function __construct(
Config $config, protected Config $config,
Faq $faq, protected Faq $faq,
Response $response protected Response $response
) { ) {
$this->config = $config;
$this->faq = $faq;
$this->response = $response;
} }
public function index(): Response public function index(): Response

View File

@ -6,11 +6,8 @@ use Engelsystem\Http\Response;
class HealthController extends BaseController class HealthController extends BaseController
{ {
protected Response $response; public function __construct(protected Response $response)
public function __construct(Response $response)
{ {
$this->response = $response;
} }
public function index(): Response public function index(): Response

View File

@ -9,17 +9,8 @@ use Engelsystem\Http\Response;
class HomeController extends BaseController class HomeController extends BaseController
{ {
protected Authenticator $auth; public function __construct(protected Authenticator $auth, protected Config $config, protected Redirector $redirect)
protected Config $config;
protected Redirector $redirect;
public function __construct(Authenticator $auth, Config $config, Redirector $redirect)
{ {
$this->auth = $auth;
$this->config = $config;
$this->redirect = $redirect;
} }
public function index(): Response public function index(): Response

View File

@ -16,41 +16,23 @@ use Psr\Http\Message\RequestInterface;
class MessagesController extends BaseController class MessagesController extends BaseController
{ {
protected Authenticator $auth;
protected Redirector $redirect;
protected Response $response;
protected RequestInterface $request; protected RequestInterface $request;
protected Database $db;
protected Message $message;
protected User $user;
/** @var string[] */ /** @var string[] */
protected array $permissions = [ protected array $permissions = [
'user_messages', 'user_messages',
]; ];
public function __construct( public function __construct(
Authenticator $auth, protected Authenticator $auth,
Redirector $redirect, protected Redirector $redirect,
Response $response, protected Response $response,
Request $request, Request $request,
Database $db, protected Database $db,
Message $message, protected Message $message,
User $user protected User $user
) { ) {
$this->auth = $auth;
$this->redirect = $redirect;
$this->response = $response;
$this->request = $request; $this->request = $request;
$this->db = $db;
$this->message = $message;
$this->user = $user;
} }
public function index(): Response public function index(): Response

View File

@ -13,32 +13,14 @@ use Psr\Log\LogLevel;
class Controller extends BaseController class Controller extends BaseController
{ {
protected Config $config;
protected MetricsEngine $engine;
protected Request $request;
protected Response $response;
protected Stats $stats;
protected Version $version;
public function __construct( public function __construct(
Response $response, protected Response $response,
MetricsEngine $engine, protected MetricsEngine $engine,
Config $config, protected Config $config,
Request $request, protected Request $request,
Stats $stats, protected Stats $stats,
Version $version protected Version $version
) { ) {
$this->config = $config;
$this->engine = $engine;
$this->request = $request;
$this->response = $response;
$this->stats = $stats;
$this->version = $version;
} }
public function metrics(): Response public function metrics(): Response

View File

@ -30,11 +30,8 @@ use Illuminate\Support\Collection;
class Stats class Stats
{ {
protected Database $db; public function __construct(protected Database $db)
public function __construct(Database $db)
{ {
$this->db = $db;
} }
/** /**

View File

@ -16,22 +16,8 @@ class NewsController extends BaseController
{ {
use HasUserNotifications; use HasUserNotifications;
protected Authenticator $auth;
protected NewsComment $comment;
protected Config $config;
protected LoggerInterface $log;
protected News $news;
protected Redirector $redirect; protected Redirector $redirect;
protected Response $response;
protected Request $request;
/** @var array */ /** @var array */
protected array $permissions = [ protected array $permissions = [
'news', 'news',
@ -41,23 +27,16 @@ class NewsController extends BaseController
]; ];
public function __construct( public function __construct(
Authenticator $auth, protected Authenticator $auth,
NewsComment $comment, protected NewsComment $comment,
Config $config, protected Config $config,
LoggerInterface $log, protected LoggerInterface $log,
News $news, protected News $news,
Redirector $redirector, Redirector $redirector,
Response $response, protected Response $response,
Request $request protected Request $request
) { ) {
$this->auth = $auth;
$this->comment = $comment;
$this->config = $config;
$this->log = $log;
$this->news = $news;
$this->redirect = $redirector; $this->redirect = $redirector;
$this->response = $response;
$this->request = $request;
} }
public function index(): Response public function index(): Response

View File

@ -25,40 +25,16 @@ class OAuthController extends BaseController
{ {
use HasUserNotifications; use HasUserNotifications;
protected Authenticator $auth;
protected AuthController $authController;
protected Config $config;
protected LoggerInterface $log;
protected OAuth $oauth;
protected Redirector $redirector;
protected Session $session;
protected UrlGenerator $url;
public function __construct( public function __construct(
Authenticator $auth, protected Authenticator $auth,
AuthController $authController, protected AuthController $authController,
Config $config, protected Config $config,
LoggerInterface $log, protected LoggerInterface $log,
OAuth $oauth, protected OAuth $oauth,
Redirector $redirector, protected Redirector $redirector,
Session $session, protected Session $session,
UrlGenerator $url protected UrlGenerator $url
) { ) {
$this->auth = $auth;
$this->authController = $authController;
$this->config = $config;
$this->log = $log;
$this->redirector = $redirector;
$this->oauth = $oauth;
$this->session = $session;
$this->url = $url;
} }
public function index(Request $request): Response public function index(Request $request): Response

View File

@ -15,14 +15,6 @@ class PasswordResetController extends BaseController
{ {
use HasUserNotifications; use HasUserNotifications;
protected LoggerInterface $log;
protected EngelsystemMailer $mail;
protected Response $response;
protected SessionInterface $session;
/** @var array */ /** @var array */
protected array $permissions = [ protected array $permissions = [
'reset' => 'login', 'reset' => 'login',
@ -32,15 +24,11 @@ class PasswordResetController extends BaseController
]; ];
public function __construct( public function __construct(
Response $response, protected Response $response,
SessionInterface $session, protected SessionInterface $session,
EngelsystemMailer $mail, protected EngelsystemMailer $mail,
LoggerInterface $log protected LoggerInterface $log
) { ) {
$this->log = $log;
$this->mail = $mail;
$this->response = $response;
$this->session = $session;
} }
public function reset(): Response public function reset(): Response

View File

@ -14,33 +14,18 @@ class QuestionsController extends BaseController
{ {
use HasUserNotifications; use HasUserNotifications;
protected Authenticator $auth;
protected LoggerInterface $log;
protected Question $question;
protected Redirector $redirect;
protected Response $response;
/** @var string[] */ /** @var string[] */
protected array $permissions = [ protected array $permissions = [
'question.add', 'question.add',
]; ];
public function __construct( public function __construct(
Authenticator $auth, protected Authenticator $auth,
LoggerInterface $log, protected LoggerInterface $log,
Question $question, protected Question $question,
Redirector $redirect, protected Redirector $redirect,
Response $response protected Response $response
) { ) {
$this->auth = $auth;
$this->log = $log;
$this->question = $question;
$this->redirect = $redirect;
$this->response = $response;
} }
public function index(): Response public function index(): Response

View File

@ -15,33 +15,21 @@ class SettingsController extends BaseController
use HasUserNotifications; use HasUserNotifications;
use ChecksArrivalsAndDepartures; use ChecksArrivalsAndDepartures;
protected Authenticator $auth;
protected Config $config;
protected LoggerInterface $log;
protected Redirector $redirect; protected Redirector $redirect;
protected Response $response;
/** @var string[] */ /** @var string[] */
protected array $permissions = [ protected array $permissions = [
'user_settings', 'user_settings',
]; ];
public function __construct( public function __construct(
Authenticator $auth, protected Authenticator $auth,
Config $config, protected Config $config,
LoggerInterface $log, protected LoggerInterface $log,
Redirector $redirector, Redirector $redirector,
Response $response protected Response $response
) { ) {
$this->auth = $auth;
$this->config = $config;
$this->log = $log;
$this->redirect = $redirector; $this->redirect = $redirector;
$this->response = $response;
} }
public function profile(): Response public function profile(): Response

View File

@ -7,11 +7,8 @@ use PDO;
class Database class Database
{ {
protected DatabaseConnection $connection; public function __construct(protected DatabaseConnection $connection)
public function __construct(DatabaseConnection $connection)
{ {
$this->connection = $connection;
} }
/** /**

View File

@ -19,10 +19,6 @@ class Migrate
/** @var string */ /** @var string */
public const DOWN = 'down'; public const DOWN = 'down';
protected Application $app;
protected SchemaBuilder $schema;
/** @var callable */ /** @var callable */
protected $output; protected $output;
@ -32,10 +28,8 @@ class Migrate
* Migrate constructor * Migrate constructor
* *
*/ */
public function __construct(SchemaBuilder $schema, Application $app) public function __construct(protected SchemaBuilder $schema, protected Application $app)
{ {
$this->app = $app;
$this->schema = $schema;
$this->output = function (): void { $this->output = function (): void {
}; };
} }

View File

@ -12,20 +12,11 @@ use Symfony\Component\Mailer\Exception\TransportException;
class News class News
{ {
protected LoggerInterface $log;
protected EngelsystemMailer $mailer;
protected UserSettings $settings;
public function __construct( public function __construct(
LoggerInterface $log, protected LoggerInterface $log,
EngelsystemMailer $mailer, protected EngelsystemMailer $mailer,
UserSettings $settings protected UserSettings $settings
) { ) {
$this->log = $log;
$this->mailer = $mailer;
$this->settings = $settings;
} }
public function created(NewsModel $news): void public function created(NewsModel $news): void

View File

@ -12,18 +12,12 @@ use Psr\Log\LoggerInterface;
class OAuth2 class OAuth2
{ {
protected Authenticator $auth;
/** @var array */ /** @var array */
protected array $config; protected array $config;
protected LoggerInterface $log; public function __construct(Config $config, protected LoggerInterface $log, protected Authenticator $auth)
public function __construct(Config $config, LoggerInterface $log, Authenticator $auth)
{ {
$this->auth = $auth;
$this->config = $config->get('oauth'); $this->config = $config->get('oauth');
$this->log = $log;
} }
/** /**

View File

@ -10,8 +10,6 @@ use Throwable;
class Handler class Handler
{ {
protected string $environment;
/** @var HandlerInterface[] */ /** @var HandlerInterface[] */
protected array $handler = []; protected array $handler = [];
@ -28,9 +26,8 @@ class Handler
* *
* @param string $environment prod|dev * @param string $environment prod|dev
*/ */
public function __construct(string $environment = self::ENV_PRODUCTION) public function __construct(protected string $environment = self::ENV_PRODUCTION)
{ {
$this->environment = $environment;
} }
/** /**

View File

@ -4,16 +4,13 @@ namespace Engelsystem\Helpers;
class Assets class Assets
{ {
protected string $assetsPath;
protected string $manifestFile = 'manifest.json'; protected string $manifestFile = 'manifest.json';
/** /**
* @param string $assetsPath Directory containing assets * @param string $assetsPath Directory containing assets
*/ */
public function __construct(string $assetsPath) public function __construct(protected string $assetsPath)
{ {
$this->assetsPath = $assetsPath;
} }
public function getAssetPath(string $asset): string public function getAssetPath(string $asset): string

View File

@ -13,12 +13,6 @@ class Authenticator
{ {
protected ?User $user = null; protected ?User $user = null;
protected ServerRequestInterface $request;
protected Session $session;
protected UserRepository $userRepository;
/** @var string[] */ /** @var string[] */
protected array $permissions = []; protected array $permissions = [];
@ -28,11 +22,11 @@ class Authenticator
protected int $guestRole = 10; protected int $guestRole = 10;
public function __construct(ServerRequestInterface $request, Session $session, UserRepository $userRepository) public function __construct(
{ protected ServerRequestInterface $request,
$this->request = $request; protected Session $session,
$this->session = $session; protected UserRepository $userRepository
$this->userRepository = $userRepository; ) {
} }
/** /**

View File

@ -8,42 +8,19 @@ class Conference
{ {
use CalculatesTime; use CalculatesTime;
/** @var string required */
protected string $title;
/** @var string required */
protected string $acronym;
protected ?string $start = null;
protected ?string $end = null;
protected ?int $days = null;
protected ?string $timeslotDuration = null;
protected ?string $baseUrl = null;
/** /**
* Event constructor. * Event constructor.
* *
*/ */
public function __construct( public function __construct(
string $title, protected string $title,
string $acronym, protected string $acronym,
?string $start = null, protected ?string $start = null,
?string $end = null, protected ?string $end = null,
?int $days = null, protected ?int $days = null,
?string $timeslotDuration = null, protected ?string $timeslotDuration = null,
?string $baseUrl = null protected ?string $baseUrl = null
) { ) {
$this->title = $title;
$this->acronym = $acronym;
$this->start = $start;
$this->end = $end;
$this->days = $days;
$this->timeslotDuration = $timeslotDuration;
$this->baseUrl = $baseUrl;
} }
public function getTitle(): string public function getTitle(): string

View File

@ -10,121 +10,46 @@ class Event
{ {
use CalculatesTime; use CalculatesTime;
/** @var string required globally unique */
protected string $guid;
/** @var int required globally unique */
protected int $id;
/** @var Room required, string in XML */
protected Room $room;
/** @var string required */
protected string $title;
/** @var string required */
protected string $subtitle;
/** @var string required */
protected string $type;
/** @var Carbon required */
protected Carbon $date;
/** @var string required time (hh:mm:ss || hh:mm) */
protected string $start;
/** @var string required (h?h:mm:ss || h?h:mm) */
protected string $duration;
/** @var string required */
protected string $abstract;
/** @var string required globally unique */
protected string $slug;
/** @var string required */
protected string $track;
protected ?string $logo = null;
/** @var string[] id => name */
protected array $persons;
/** @var string|null two letter code */
protected ?string $language = null;
protected ?string $description = null;
/** @var string|null license (and opt out in XML, null if not recorded, empty if no license defined) */
protected ?string $recording = null;
/** @var array href => title */
protected array $links;
/** @var array href => name */
protected array $attachments;
protected ?string $url = null;
protected ?string $videoDownloadUrl = null;
/** @var Carbon Calculated */ /** @var Carbon Calculated */
protected Carbon $endDate; protected Carbon $endDate;
/** /**
* Event constructor. * Event constructor.
* *
* @param string[] $persons * @param string $guid globally unique
* @param string|null $recording license * @param int $id globally unique
* @param array $links * @param string $start time (hh:mm:ss || hh:mm)
* @param array $attachments * @param string $duration (h?h:mm:ss || h?h:mm)
* @param string $slug globally unique
* @param string[] $persons id => name
* @param string|null $language two letter code
* @param string|null $recording license (and opt out in XML, null if not recorded, empty if no license defined)/
* @param array $links href => title
* @param array $attachments href => title
*/ */
public function __construct( public function __construct(
string $guid, protected string $guid,
int $id, protected int $id,
Room $room, protected Room $room,
string $title, protected string $title,
string $subtitle, protected string $subtitle,
string $type, protected string $type,
Carbon $date, protected Carbon $date,
string $start, protected string $start,
string $duration, protected string $duration,
string $abstract, protected string $abstract,
string $slug, protected string $slug,
string $track, protected string $track,
?string $logo = null, protected ?string $logo = null,
array $persons = [], protected array $persons = [],
?string $language = null, protected ?string $language = null,
?string $description = null, protected ?string $description = null,
string $recording = '', protected string $recording = '',
array $links = [], protected array $links = [],
array $attachments = [], protected array $attachments = [],
?string $url = null, protected ?string $url = null,
?string $videoDownloadUrl = null protected ?string $videoDownloadUrl = null
) { ) {
$this->guid = $guid;
$this->id = $id;
$this->room = $room;
$this->title = $title;
$this->subtitle = $subtitle;
$this->type = $type;
$this->date = $date;
$this->start = $start;
$this->duration = $duration;
$this->abstract = $abstract;
$this->slug = $slug;
$this->track = $track;
$this->logo = $logo;
$this->persons = $persons;
$this->language = $language;
$this->description = $description;
$this->recording = $recording;
$this->links = $links;
$this->attachments = $attachments;
$this->url = $url;
$this->videoDownloadUrl = $videoDownloadUrl;
$this->endDate = $this->date $this->endDate = $this->date
->copy() ->copy()
->addSeconds($this->getDurationSeconds()); ->addSeconds($this->getDurationSeconds());

View File

@ -8,10 +8,6 @@ use Carbon\Carbon;
class Schedule class Schedule
{ {
protected string $version;
protected Conference $conference;
/** @var Day[] */ /** @var Day[] */
protected array $day; protected array $day;
@ -19,12 +15,10 @@ class Schedule
* @param Day[] $days * @param Day[] $days
*/ */
public function __construct( public function __construct(
string $version, protected string $version,
Conference $conference, protected Conference $conference,
array $days array $days
) { ) {
$this->version = $version;
$this->conference = $conference;
$this->day = $days; $this->day = $days;
} }

View File

@ -4,13 +4,8 @@ namespace Engelsystem\Helpers\Translation;
class Translator class Translator
{ {
/** @var string[] */
protected array $locales;
protected string $locale; protected string $locale;
protected string $fallbackLocale;
/** @var callable */ /** @var callable */
protected $getTranslatorCallback; protected $getTranslatorCallback;
@ -24,17 +19,15 @@ class Translator
*/ */
public function __construct( public function __construct(
string $locale, string $locale,
string $fallbackLocale, protected string $fallbackLocale,
callable $getTranslatorCallback, callable $getTranslatorCallback,
array $locales = [], protected array $locales = [],
callable $localeChangeCallback = null callable $localeChangeCallback = null
) { ) {
$this->localeChangeCallback = $localeChangeCallback; $this->localeChangeCallback = $localeChangeCallback;
$this->getTranslatorCallback = $getTranslatorCallback; $this->getTranslatorCallback = $getTranslatorCallback;
$this->setLocale($locale); $this->setLocale($locale);
$this->fallbackLocale = $fallbackLocale;
$this->locales = $locales;
} }
/** /**

View File

@ -6,16 +6,10 @@ use Engelsystem\Config\Config;
class Version class Version
{ {
protected Config $config;
protected string $storage;
protected string $versionFile = 'VERSION'; protected string $versionFile = 'VERSION';
public function __construct(string $storage, Config $config) public function __construct(protected string $storage, protected Config $config)
{ {
$this->storage = $storage;
$this->config = $config;
} }
public function getVersion(): string public function getVersion(): string

View File

@ -7,24 +7,17 @@ use Throwable;
class HttpException extends RuntimeException class HttpException extends RuntimeException
{ {
protected int $statusCode;
/** @var array */
protected array $headers = [];
/** /**
* @param array $headers * @param array $headers
* @param Throwable|null $previous * @param Throwable|null $previous
*/ */
public function __construct( public function __construct(
int $statusCode, protected int $statusCode,
string $message = '', string $message = '',
array $headers = [], protected array $headers = [],
int $code = 0, int $code = 0,
Throwable $previous = null Throwable $previous = null
) { ) {
$this->headers = $headers;
$this->statusCode = $statusCode;
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
} }

View File

@ -8,18 +8,15 @@ use Throwable;
class ValidationException extends RuntimeException class ValidationException extends RuntimeException
{ {
protected Validator $validator;
/** /**
* @param Throwable|null $previous * @param Throwable|null $previous
*/ */
public function __construct( public function __construct(
Validator $validator, protected Validator $validator,
string $message = '', string $message = '',
int $code = 0, int $code = 0,
Throwable $previous = null Throwable $previous = null
) { ) {
$this->validator = $validator;
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
} }

View File

@ -4,17 +4,11 @@ namespace Engelsystem\Http;
class Redirector class Redirector
{ {
protected Request $request; public function __construct(
protected Request $request,
protected Response $response; protected Response $response,
protected UrlGeneratorInterface $url
protected UrlGeneratorInterface $url; ) {
public function __construct(Request $request, Response $response, UrlGeneratorInterface $url)
{
$this->request = $request;
$this->response = $response;
$this->url = $url;
} }
/** /**

View File

@ -7,11 +7,8 @@ use Illuminate\Database\Query\Builder as QueryBuilder;
class DatabaseHandler extends AbstractHandler class DatabaseHandler extends AbstractHandler
{ {
protected Database $database; public function __construct(protected Database $database)
public function __construct(Database $database)
{ {
$this->database = $database;
} }
/** /**

View File

@ -23,11 +23,8 @@ class Logger extends AbstractLogger
LogLevel::WARNING, LogLevel::WARNING,
]; ];
protected LogEntry $log; public function __construct(protected LogEntry $log)
public function __construct(LogEntry $log)
{ {
$this->log = $log;
} }
/** /**

View File

@ -7,15 +7,12 @@ use Symfony\Component\Mime\Email;
class Mailer class Mailer
{ {
protected MailerInterface $mailer;
protected string $fromAddress = ''; protected string $fromAddress = '';
protected ?string $fromName = null; protected ?string $fromName = null;
public function __construct(MailerInterface $mailer) public function __construct(protected MailerInterface $mailer)
{ {
$this->mailer = $mailer;
} }
/** /**

View File

@ -8,11 +8,8 @@ use Symfony\Component\Mailer\Transport\AbstractTransport;
class LogTransport extends AbstractTransport class LogTransport extends AbstractTransport
{ {
protected LoggerInterface $logger; public function __construct(protected LoggerInterface $logger)
public function __construct(LoggerInterface $logger)
{ {
$this->logger = $logger;
parent::__construct(); parent::__construct();
} }

View File

@ -10,11 +10,8 @@ use Psr\Http\Server\RequestHandlerInterface;
class AddHeaders implements MiddlewareInterface class AddHeaders implements MiddlewareInterface
{ {
protected Config $config; public function __construct(protected Config $config)
public function __construct(Config $config)
{ {
$this->config = $config;
} }
/** /**

View File

@ -14,17 +14,13 @@ class Dispatcher implements MiddlewareInterface, RequestHandlerInterface
{ {
use ResolvesMiddlewareTrait; use ResolvesMiddlewareTrait;
/** @var MiddlewareInterface[]|string[] */
protected array $stack;
protected RequestHandlerInterface $next; protected RequestHandlerInterface $next;
/** /**
* @param MiddlewareInterface[]|string[] $stack * @param MiddlewareInterface[]|string[] $stack
*/ */
public function __construct(array $stack = [], protected ?Application $container = null) public function __construct(protected array $stack = [], protected ?Application $container = null)
{ {
$this->stack = $stack;
} }
/** /**

View File

@ -16,8 +16,6 @@ use Twig\Loader\LoaderInterface as TwigLoader;
class ErrorHandler implements MiddlewareInterface class ErrorHandler implements MiddlewareInterface
{ {
protected TwigLoader $loader;
protected string $viewPrefix = 'errors/'; protected string $viewPrefix = 'errors/';
/** /**
@ -36,9 +34,8 @@ class ErrorHandler implements MiddlewareInterface
'_token', '_token',
]; ];
public function __construct(TwigLoader $loader) public function __construct(protected TwigLoader $loader)
{ {
$this->loader = $loader;
} }
/** /**

View File

@ -12,11 +12,8 @@ use Throwable;
class ExceptionHandler implements MiddlewareInterface class ExceptionHandler implements MiddlewareInterface
{ {
protected ContainerInterface $container; public function __construct(protected ContainerInterface $container)
public function __construct(ContainerInterface $container)
{ {
$this->container = $container;
} }
/** /**

View File

@ -29,14 +29,8 @@ class LegacyMiddleware implements MiddlewareInterface
'admin_shifts_history', 'admin_shifts_history',
]; ];
protected ContainerInterface $container; public function __construct(protected ContainerInterface $container, protected Authenticator $auth)
protected Authenticator $auth;
public function __construct(ContainerInterface $container, Authenticator $auth)
{ {
$this->container = $container;
$this->auth = $auth;
} }
/** /**

View File

@ -16,11 +16,8 @@ class RequestHandler implements MiddlewareInterface
{ {
use ResolvesMiddlewareTrait; use ResolvesMiddlewareTrait;
protected Application $container; public function __construct(protected Application $container)
public function __construct(Application $container)
{ {
$this->container = $container;
} }
/** /**

View File

@ -12,10 +12,6 @@ use Psr\Http\Server\RequestHandlerInterface;
class RouteDispatcher implements MiddlewareInterface class RouteDispatcher implements MiddlewareInterface
{ {
protected FastRouteDispatcher $dispatcher;
protected ResponseInterface $response;
protected ?MiddlewareInterface $notFound = null; protected ?MiddlewareInterface $notFound = null;
/** /**
@ -23,12 +19,10 @@ class RouteDispatcher implements MiddlewareInterface
* @param MiddlewareInterface|null $notFound Handles any requests if the route can't be found * @param MiddlewareInterface|null $notFound Handles any requests if the route can't be found
*/ */
public function __construct( public function __construct(
FastRouteDispatcher $dispatcher, protected FastRouteDispatcher $dispatcher,
ResponseInterface $response, protected ResponseInterface $response,
MiddlewareInterface $notFound = null MiddlewareInterface $notFound = null
) { ) {
$this->dispatcher = $dispatcher;
$this->response = $response;
$this->notFound = $notFound; $this->notFound = $notFound;
} }

View File

@ -11,18 +11,11 @@ use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface;
class SessionHandler implements MiddlewareInterface class SessionHandler implements MiddlewareInterface
{ {
protected SessionStorageInterface $session;
/** @var string[] */
protected array $paths = [];
/** /**
* @param array $paths * @param array $paths
*/ */
public function __construct(SessionStorageInterface $session, array $paths = []) public function __construct(protected SessionStorageInterface $session, protected array $paths = [])
{ {
$this->paths = $paths;
$this->session = $session;
} }
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface

View File

@ -12,17 +12,11 @@ use Symfony\Component\HttpFoundation\Session\Session;
class SetLocale implements MiddlewareInterface class SetLocale implements MiddlewareInterface
{ {
protected Authenticator $auth; public function __construct(
protected Translator $translator,
protected Translator $translator; protected Session $session,
protected Authenticator $auth
protected Session $session; ) {
public function __construct(Translator $translator, Session $session, Authenticator $auth)
{
$this->auth = $auth;
$this->translator = $translator;
$this->session = $session;
} }
/** /**

View File

@ -11,11 +11,8 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface;
class VerifyCsrfToken implements MiddlewareInterface class VerifyCsrfToken implements MiddlewareInterface
{ {
protected SessionInterface $session; public function __construct(protected SessionInterface $session)
public function __construct(SessionInterface $session)
{ {
$this->session = $session;
} }
/** /**

View File

@ -10,14 +10,8 @@ use Twig\TwigFunction;
class Assets extends TwigExtension class Assets extends TwigExtension
{ {
protected AssetsProvider $assets; public function __construct(protected AssetsProvider $assets, protected UrlGeneratorInterface $urlGenerator)
protected UrlGeneratorInterface $urlGenerator;
public function __construct(AssetsProvider $assets, UrlGeneratorInterface $urlGenerator)
{ {
$this->assets = $assets;
$this->urlGenerator = $urlGenerator;
} }
/** /**

View File

@ -8,11 +8,8 @@ use Twig\TwigFunction;
class Authentication extends TwigExtension class Authentication extends TwigExtension
{ {
protected Authenticator $auth; public function __construct(protected Authenticator $auth)
public function __construct(Authenticator $auth)
{ {
$this->auth = $auth;
} }
/** /**

View File

@ -8,11 +8,8 @@ use Twig\TwigFunction;
class Config extends TwigExtension class Config extends TwigExtension
{ {
protected EngelsystemConfig $config; public function __construct(protected EngelsystemConfig $config)
public function __construct(EngelsystemConfig $config)
{ {
$this->config = $config;
} }
/** /**

View File

@ -8,11 +8,8 @@ use Twig\TwigFunction;
class Csrf extends TwigExtension class Csrf extends TwigExtension
{ {
protected SessionInterface $session; public function __construct(protected SessionInterface $session)
public function __construct(SessionInterface $session)
{ {
$this->session = $session;
} }
/** /**

View File

@ -9,13 +9,10 @@ use Twig\TwigFunction;
class Develop extends TwigExtension class Develop extends TwigExtension
{ {
protected Config $config;
protected ?VarDumper $dumper = null; protected ?VarDumper $dumper = null;
public function __construct(Config $config) public function __construct(protected Config $config)
{ {
$this->config = $config;
} }
/** /**

View File

@ -11,14 +11,8 @@ use function array_key_exists;
class Globals extends TwigExtension implements GlobalsInterface class Globals extends TwigExtension implements GlobalsInterface
{ {
protected Authenticator $auth; public function __construct(protected Authenticator $auth, protected Request $request)
protected Request $request;
public function __construct(Authenticator $auth, Request $request)
{ {
$this->auth = $auth;
$this->request = $request;
} }
/** /**

View File

@ -8,11 +8,8 @@ use Twig\TwigFunction;
class Legacy extends TwigExtension class Legacy extends TwigExtension
{ {
protected Request $request; public function __construct(protected Request $request)
public function __construct(Request $request)
{ {
$this->request = $request;
} }
/** /**

View File

@ -8,11 +8,8 @@ use Twig\TwigFilter;
class Markdown extends TwigExtension class Markdown extends TwigExtension
{ {
protected Parsedown $renderer; public function __construct(protected Parsedown $renderer)
public function __construct(Parsedown $renderer)
{ {
$this->renderer = $renderer;
} }
/** /**

View File

@ -8,11 +8,8 @@ use Twig\TwigFunction;
class Session extends TwigExtension class Session extends TwigExtension
{ {
protected SymfonySession $session; public function __construct(protected SymfonySession $session)
public function __construct(SymfonySession $session)
{ {
$this->session = $session;
} }
/** /**

View File

@ -9,11 +9,8 @@ use Twig\TwigFunction;
class Translation extends TwigExtension class Translation extends TwigExtension
{ {
protected Translator $translator; public function __construct(protected Translator $translator)
public function __construct(Translator $translator)
{ {
$this->translator = $translator;
} }
/** /**

View File

@ -8,11 +8,8 @@ use Twig\TwigFunction;
class Url extends TwigExtension class Url extends TwigExtension
{ {
protected UrlGeneratorInterface $urlGenerator; public function __construct(protected UrlGeneratorInterface $urlGenerator)
public function __construct(UrlGeneratorInterface $urlGenerator)
{ {
$this->urlGenerator = $urlGenerator;
} }
/** /**

View File

@ -9,11 +9,8 @@ use Twig\Error\SyntaxError as SyntaxError;
class TwigEngine extends Engine class TwigEngine extends Engine
{ {
protected Twig $twig; public function __construct(protected Twig $twig)
public function __construct(Twig $twig)
{ {
$this->twig = $twig;
} }
/** /**

View File

@ -9,11 +9,8 @@ use Psr\Http\Server\RequestHandlerInterface;
class ReturnResponseMiddleware implements MiddlewareInterface class ReturnResponseMiddleware implements MiddlewareInterface
{ {
protected ResponseInterface $response; public function __construct(protected ResponseInterface $response)
public function __construct(ResponseInterface $response)
{ {
$this->response = $response;
} }
/** /**

View File

@ -9,11 +9,8 @@ use Psr\Http\Server\RequestHandlerInterface;
class ReturnResponseMiddlewareHandler implements RequestHandlerInterface class ReturnResponseMiddlewareHandler implements RequestHandlerInterface
{ {
protected ResponseInterface $response; public function __construct(protected ResponseInterface $response)
public function __construct(ResponseInterface $response)
{ {
$this->response = $response;
} }
/** /**