Set native parameter types

Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
This commit is contained in:
Michael Weimann 2022-12-14 00:28:34 +01:00
parent f835a7538c
commit 2b88322c0c
No known key found for this signature in database
GPG Key ID: 34F0524D4DA694A1
174 changed files with 239 additions and 1057 deletions

View File

@ -23,4 +23,9 @@
<rule ref="Generic.Files.LineLength.TooLong">
<exclude-pattern>/includes</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
<exclude-pattern>/includes</exclude-pattern>
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification" />
</rule>
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment" />
</ruleset>

View File

@ -53,10 +53,9 @@ class AddAngelSupporterPermissions extends Migration
}
/**
* @param string $type
* @return string
*/
protected function getQuery($type)
protected function getQuery(string $type)
{
return sprintf('
%s FROM GroupPrivileges

View File

@ -113,8 +113,6 @@ class CreateEventConfigTable extends Migration
}
/**
* @param Collection $config
* @param string $name
* @return mixed|null
*/
protected function getConfigValue(Collection $config, string $name)

View File

@ -29,9 +29,6 @@ class ChangeUsersContactDectFieldSize extends Migration
$this->changeDectTo(5);
}
/**
* @param int $length
*/
protected function changeDectTo(int $length)
{
foreach ($this->tables as $table => $column) {

View File

@ -17,11 +17,6 @@ class SetAdminPassword extends Migration
/** @var Config */
protected Config $config;
/**
* @param SchemaBuilder $schemaBuilder
* @param Authenticator $auth
* @param Config $config
*/
public function __construct(SchemaBuilder $schemaBuilder, Authenticator $auth, Config $config)
{
parent::__construct($schemaBuilder);

View File

@ -7,13 +7,6 @@ use stdClass;
trait ChangesReferences
{
/**
* @param string $fromTable
* @param string $fromColumn
* @param string $targetTable
* @param string $targetColumn
* @param string $type
*/
protected function changeReferences(
string $fromTable,
string $fromColumn,
@ -44,8 +37,6 @@ trait ChangesReferences
}
/**
* @param string $table
* @param string $column
*
* @return array
*/

View File

@ -9,8 +9,6 @@ use Illuminate\Support\Str;
trait Reference
{
/**
* @param Blueprint $table
* @param bool $setPrimary
* @return ColumnDefinition
*/
protected function referencesUser(Blueprint $table, bool $setPrimary = false): ColumnDefinition
@ -19,12 +17,6 @@ trait Reference
}
/**
* @param Blueprint $table
* @param string $targetTable
* @param string|null $fromColumn
* @param string|null $targetColumn
* @param bool $setPrimary
* @param string $type
* @return ColumnDefinition
*/
protected function references(
@ -47,12 +39,6 @@ trait Reference
return $col;
}
/**
* @param Blueprint $table
* @param string $fromColumn
* @param string $targetTable
* @param string|null $targetColumn
*/
protected function addReference(
Blueprint $table,
string $fromColumn,

View File

@ -31,9 +31,8 @@ class Application extends Container
/**
* Application constructor.
*
* @param string $appPath
*/
public function __construct($appPath = null)
public function __construct(string $appPath = null)
{
if (!is_null($appPath)) {
$this->setAppPath($appPath);
@ -56,10 +55,9 @@ class Application extends Container
}
/**
* @param string|ServiceProvider $provider
* @return ServiceProvider
*/
public function register($provider)
public function register(string|ServiceProvider $provider)
{
if (is_string($provider)) {
$provider = $this->make($provider);
@ -124,10 +122,9 @@ class Application extends Container
/**
* Set app base path
*
* @param string $appPath
* @return static
*/
public function setAppPath($appPath)
public function setAppPath(string $appPath)
{
$appPath = realpath($appPath);
$appPath = rtrim($appPath, DIRECTORY_SEPARATOR);

View File

@ -14,11 +14,9 @@ class Config extends Fluent
protected $attributes = [];
/**
* @param string|null $key
* @param mixed $default
* @return mixed
* @param string|array $key
*/
public function get($key, $default = null)
public function get(mixed $key, mixed $default = null)
{
if (is_null($key)) {
return $this->attributes;
@ -33,9 +31,8 @@ class Config extends Fluent
/**
* @param string|array $key
* @param mixed $value
*/
public function set($key, $value = null)
public function set(mixed $key, mixed $value = null)
{
if (is_array($key)) {
foreach ($key as $configKey => $configValue) {
@ -52,7 +49,7 @@ class Config extends Fluent
* @param string $key
* @return bool
*/
public function has($key)
public function has(mixed $key)
{
return $this->offsetExists($key);
}
@ -60,7 +57,7 @@ class Config extends Fluent
/**
* @param string $key
*/
public function remove($key)
public function remove(mixed $key)
{
$this->offsetUnset($key);
}

View File

@ -16,10 +16,6 @@ class ConfigServiceProvider extends ServiceProvider
/** @var EventConfig */
protected $eventConfig;
/**
* @param Application $app
* @param EventConfig $eventConfig
*/
public function __construct(Application $app, EventConfig $eventConfig = null)
{
parent::__construct($app);
@ -84,10 +80,9 @@ class ConfigServiceProvider extends ServiceProvider
/**
* Get the config path
*
* @param string $path
* @return string
*/
protected function getConfigPath($path = ''): string
protected function getConfigPath(string $path = ''): string
{
return config_path($path);
}

View File

@ -12,7 +12,6 @@ abstract class ServiceProvider
/**
* ServiceProvider constructor.
*
* @param Application $app
*/
public function __construct(Application $app)
{

View File

@ -32,12 +32,6 @@ class FaqController extends BaseController
'faq.edit',
];
/**
* @param LoggerInterface $log
* @param Faq $faq
* @param Redirector $redirector
* @param Response $response
*/
public function __construct(
LoggerInterface $log,
Faq $faq,
@ -51,7 +45,6 @@ class FaqController extends BaseController
}
/**
* @param Request $request
*
* @return Response
*/
@ -65,7 +58,6 @@ class FaqController extends BaseController
}
/**
* @param Request $request
*
* @return Response
*/
@ -110,7 +102,6 @@ class FaqController extends BaseController
}
/**
* @param Faq|null $faq
*
* @return Response
*/

View File

@ -20,10 +20,6 @@ class LogsController extends BaseController
'admin_log',
];
/**
* @param LogEntry $log
* @param Response $response
*/
public function __construct(LogEntry $log, Response $response)
{
$this->log = $log;
@ -31,7 +27,6 @@ class LogsController extends BaseController
}
/**
* @param Request $request
* @return Response
*/
public function index(Request $request): Response

View File

@ -35,13 +35,6 @@ class NewsController extends BaseController
'admin_news',
];
/**
* @param Authenticator $auth
* @param LoggerInterface $log
* @param News $news
* @param Redirector $redirector
* @param Response $response
*/
public function __construct(
Authenticator $auth,
LoggerInterface $log,
@ -57,7 +50,6 @@ class NewsController extends BaseController
}
/**
* @param Request $request
*
* @return Response
*/
@ -72,8 +64,6 @@ class NewsController extends BaseController
}
/**
* @param News|null $news
* @param bool $isMeetingDefault
*
* @return Response
*/
@ -90,7 +80,6 @@ class NewsController extends BaseController
}
/**
* @param Request $request
*
* @return Response
*/

View File

@ -37,13 +37,6 @@ class QuestionsController extends BaseController
'question.edit',
];
/**
* @param Authenticator $auth
* @param LoggerInterface $log
* @param Question $question
* @param Redirector $redirector
* @param Response $response
*/
public function __construct(
Authenticator $auth,
LoggerInterface $log,
@ -75,7 +68,6 @@ class QuestionsController extends BaseController
}
/**
* @param Request $request
*
* @return Response
*/
@ -96,7 +88,6 @@ class QuestionsController extends BaseController
}
/**
* @param Request $request
*
* @return Response
*/
@ -110,7 +101,6 @@ class QuestionsController extends BaseController
}
/**
* @param Request $request
*
* @return Response
*/
@ -160,7 +150,6 @@ class QuestionsController extends BaseController
}
/**
* @param Question|null $question
*
* @return Response
*/

View File

@ -40,14 +40,6 @@ class UserShirtController extends BaseController
'saveShirt' => 'user.edit.shirt',
];
/**
* @param Authenticator $auth
* @param Config $config
* @param LoggerInterface $log
* @param Redirector $redirector
* @param Response $response
* @param User $user
*/
public function __construct(
Authenticator $auth,
Config $config,
@ -65,7 +57,6 @@ class UserShirtController extends BaseController
}
/**
* @param Request $request
*
* @return Response
*/
@ -82,7 +73,6 @@ class UserShirtController extends BaseController
}
/**
* @param Request $request
*
* @return Response
*/

View File

@ -45,15 +45,6 @@ class UserWorkLogController extends BaseController
'admin_user_worklog',
];
/**
* @param Authenticator $auth
* @param Config $config
* @param LoggerInterface $log
* @param Worklog $worklog
* @param Redirector $redirector
* @param Response $response
* @param User $user
*/
public function __construct(
Authenticator $auth,
Config $config,
@ -73,7 +64,6 @@ class UserWorkLogController extends BaseController
}
/**
* @param Request $request
* @return Response
*/
public function editWorklog(Request $request): Response
@ -96,7 +86,6 @@ class UserWorkLogController extends BaseController
}
/**
* @param Request $request
* @return Response
*/
public function saveWorklog(Request $request): Response
@ -135,7 +124,6 @@ class UserWorkLogController extends BaseController
}
/**
* @param Request $request
* @return Response
*/
public function showDeleteWorklog(Request $request): Response
@ -157,7 +145,6 @@ class UserWorkLogController extends BaseController
}
/**
* @param Request $request
* @return Response
*/
public function deleteWorklog(Request $request): Response

View File

@ -9,9 +9,6 @@ class ApiController extends BaseController
/** @var Response */
protected $response;
/**
* @param Response $response
*/
public function __construct(Response $response)
{
$this->response = $response;

View File

@ -36,13 +36,6 @@ class AuthController extends BaseController
'postLogin' => 'login',
];
/**
* @param Response $response
* @param SessionInterface $session
* @param Redirector $redirect
* @param Config $config
* @param Authenticator $auth
*/
public function __construct(
Response $response,
SessionInterface $session,
@ -79,7 +72,6 @@ class AuthController extends BaseController
/**
* Posted login form
*
* @param Request $request
* @return Response
*/
public function postLogin(Request $request): Response
@ -101,7 +93,6 @@ class AuthController extends BaseController
}
/**
* @param User $user
*
* @return Response
*/

View File

@ -8,8 +8,6 @@ use DateTime;
trait ChecksArrivalsAndDepartures
{
/**
* @param string|null $arrival
* @param string|null $departure
* @return bool
*/
protected function isArrivalDateValid(?string $arrival, ?string $departure): bool
@ -29,8 +27,6 @@ trait ChecksArrivalsAndDepartures
}
/**
* @param string|null $arrival
* @param string|null $departure
* @return bool
*/
protected function isDepartureDateValid(?string $arrival, ?string $departure): bool

View File

@ -17,11 +17,6 @@ class CreditsController extends BaseController
/** @var Version */
protected $version;
/**
* @param Response $response
* @param Config $config
* @param Version $version
*/
public function __construct(Response $response, Config $config, Version $version)
{
$this->config = $config;

View File

@ -17,10 +17,6 @@ class DesignController extends BaseController
/** @var Config */
protected $config;
/**
* @param Response $response
* @param Config $config
*/
public function __construct(Response $response, Config $config)
{
$this->config = $config;

View File

@ -24,11 +24,6 @@ class FaqController extends BaseController
'faq.view',
];
/**
* @param Config $config
* @param Faq $faq
* @param Response $response
*/
public function __construct(
Config $config,
Faq $faq,

View File

@ -7,11 +7,7 @@ use Illuminate\Support\Collection;
trait HasUserNotifications
{
/**
* @param string|array $value
* @param string $type
*/
protected function addNotification($value, $type = 'messages')
protected function addNotification(string|array $value, string $type = 'messages')
{
session()->set(
$type,

View File

@ -9,9 +9,6 @@ class HealthController extends BaseController
/** @var Response */
protected $response;
/**
* @param Response $response
*/
public function __construct(Response $response)
{
$this->response = $response;

View File

@ -18,11 +18,6 @@ class HomeController extends BaseController
/** @var Redirector */
protected $redirect;
/**
* @param Authenticator $auth
* @param Config $config
* @param Redirector $redirect
*/
public function __construct(Authenticator $auth, Config $config, Redirector $redirect)
{
$this->auth = $auth;

View File

@ -41,15 +41,6 @@ class MessagesController extends BaseController
'user_messages',
];
/**
* @param Authenticator $auth
* @param Redirector $redirect
* @param Response $response
* @param Request $request
* @param Database $db
* @param Message $message
* @param User $user
*/
public function __construct(
Authenticator $auth,
Redirector $redirect,
@ -211,7 +202,7 @@ class MessagesController extends BaseController
* The number of unread messages per conversation of the current user.
* @return Collection of unread message amounts. Each object with key=other user, value=amount of unread messages
*/
protected function numberOfUnreadMessagesPerConversation($currentUser): Collection
protected function numberOfUnreadMessagesPerConversation(User $currentUser): Collection
{
return $currentUser->messagesReceived()
->select('user_id', $this->raw('count(*) as amount'))
@ -228,7 +219,7 @@ class MessagesController extends BaseController
* which were either send by or addressed to the current user.
* @return Collection of messages
*/
protected function latestMessagePerConversation($currentUser): Collection
protected function latestMessagePerConversation(User $currentUser): Collection
{
/* requesting the IDs first, grouped by "conversation".
The more complex grouping is required for associating the messages to the correct conversations.
@ -252,10 +243,9 @@ class MessagesController extends BaseController
}
/**
* @param mixed $value
* @return QueryExpression
*/
protected function raw($value): QueryExpression
protected function raw(mixed $value): QueryExpression
{
return $this->db->getConnection()->raw($value);
}

View File

@ -31,14 +31,6 @@ class Controller extends BaseController
/** @var Version */
protected $version;
/**
* @param Response $response
* @param MetricsEngine $engine
* @param Config $config
* @param Request $request
* @param Stats $stats
* @param Version $version
*/
public function __construct(
Response $response,
MetricsEngine $engine,
@ -242,9 +234,8 @@ class Controller extends BaseController
/**
* Ensure that the if the request is authorized
*
* @param bool $isJson
*/
protected function checkAuth($isJson = false)
protected function checkAuth(bool $isJson = false)
{
$apiKey = $this->config->get('api_key');
if (empty($apiKey) || $this->request->get('api_key') == $apiKey) {
@ -265,10 +256,6 @@ class Controller extends BaseController
/**
* Formats the stats collection as stats data
*
* @param Collection $data
* @param string $config
* @param string $dataField
* @param string|null $label
* @return array
*/
protected function formatStats(Collection $data, string $config, string $dataField, ?string $label = null): array

View File

@ -12,7 +12,6 @@ class MetricsEngine implements EngineInterface
/**
* Render metrics
*
* @param string $path
* @param mixed[] $data
*
* @return string
@ -62,7 +61,6 @@ class MetricsEngine implements EngineInterface
/**
* @param array $row
* @param string $name
*
* @return array[]
*/
@ -94,11 +92,9 @@ class MetricsEngine implements EngineInterface
/**
* Expand the value to be an array
*
* @param $data
*
* @return array
*/
protected function expandData($data): array
protected function expandData(mixed $data): array
{
$data = is_array($data) ? $data : [$data];
$return = ['labels' => [], 'value' => null];
@ -124,13 +120,11 @@ class MetricsEngine implements EngineInterface
}
/**
* @param string $name
* @param array|mixed $row
*
* @return string
* @see https://prometheus.io/docs/instrumenting/exposition_formats/
*/
protected function formatData($name, $row): string
protected function formatData(string $name, mixed $row): string
{
return sprintf(
'%s%s %s',
@ -159,11 +153,10 @@ class MetricsEngine implements EngineInterface
}
/**
* @param array|mixed $row
*
* @return mixed
*/
protected function renderValue($row)
protected function renderValue(mixed $row)
{
if (is_array($row)) {
$row = array_pop($row);
@ -173,11 +166,10 @@ class MetricsEngine implements EngineInterface
}
/**
* @param mixed $value
*
* @return mixed
*/
protected function formatValue($value)
protected function formatValue(mixed $value)
{
if (is_bool($value)) {
return (int)$value;
@ -187,11 +179,10 @@ class MetricsEngine implements EngineInterface
}
/**
* @param mixed $value
*
* @return mixed
*/
protected function escape($value)
protected function escape(mixed $value)
{
$replace = [
'\\' => '\\\\',
@ -207,7 +198,6 @@ class MetricsEngine implements EngineInterface
}
/**
* @param string $path
*
* @return bool
*/
@ -220,9 +210,8 @@ class MetricsEngine implements EngineInterface
* Does nothing as shared data will only result in unexpected behaviour
*
* @param string|mixed[] $key
* @param mixed $value
*/
public function share($key, $value = null): void
public function share(string|array $key, mixed $value = null): void
{
}
}

View File

@ -22,6 +22,7 @@ use Engelsystem\Models\User\Settings;
use Engelsystem\Models\User\State;
use Engelsystem\Models\User\User;
use Engelsystem\Models\Worklog;
use Illuminate\Contracts\Database\Query\Builder as BuilderContract;
use Illuminate\Database\Query\Builder as QueryBuilder;
use Illuminate\Database\Query\Expression as QueryExpression;
use Illuminate\Support\Collection;
@ -31,9 +32,6 @@ class Stats
/** @var Database */
protected $db;
/**
* @param Database $db
*/
public function __construct(Database $db)
{
$this->db = $db;
@ -103,7 +101,6 @@ class Stats
}
/**
* @param string $type
*
* @return int
*/
@ -315,16 +312,17 @@ class Stats
/**
* @param array $buckets
* @param QueryBuilder $basicQuery
* @param string $groupBy
* @param string $having
* @param string $count
*
* @return array
* @codeCoverageIgnore As long as its only used for old tables
*/
protected function getBuckets(array $buckets, $basicQuery, string $groupBy, string $having, string $count): array
{
protected function getBuckets(
array $buckets,
BuilderContract $basicQuery,
string $groupBy,
string $having,
string $count
): array {
$return = [];
foreach ($buckets as $bucket) {
@ -512,7 +510,6 @@ class Stats
}
/**
* @param string $table
* @return QueryBuilder
*/
protected function getQuery(string $table): QueryBuilder
@ -523,10 +520,9 @@ class Stats
}
/**
* @param mixed $value
* @return QueryExpression
*/
protected function raw($value): QueryExpression
protected function raw(mixed $value): QueryExpression
{
return $this->db->getConnection()->raw($value);
}

View File

@ -48,16 +48,6 @@ class NewsController extends BaseController
'deleteComment' => 'news_comments',
];
/**
* @param Authenticator $auth
* @param Config $config
* @param NewsComment $comment
* @param LoggerInterface $log
* @param News $news
* @param Redirector $redirector
* @param Response $response
* @param Request $request
*/
public function __construct(
Authenticator $auth,
NewsComment $comment,
@ -95,7 +85,6 @@ class NewsController extends BaseController
}
/**
* @param Request $request
* @return Response
*/
public function show(Request $request): Response
@ -111,7 +100,6 @@ class NewsController extends BaseController
}
/**
* @param Request $request
* @return Response
*/
public function comment(Request $request): Response
@ -144,7 +132,6 @@ class NewsController extends BaseController
}
/**
* @param Request $request
*
* @return Response
*/
@ -180,7 +167,6 @@ class NewsController extends BaseController
}
/**
* @param bool $onlyMeetings
* @return Response
*/
protected function showOverview(bool $onlyMeetings = false): Response
@ -216,7 +202,6 @@ class NewsController extends BaseController
}
/**
* @param string $page
* @param array $data
* @return Response
*/

View File

@ -49,16 +49,6 @@ class OAuthController extends BaseController
/** @var UrlGenerator */
protected $url;
/**
* @param Authenticator $auth
* @param AuthController $authController
* @param Config $config
* @param LoggerInterface $log
* @param OAuth $oauth
* @param Redirector $redirector
* @param Session $session
* @param UrlGenerator $url
*/
public function __construct(
Authenticator $auth,
AuthController $authController,
@ -80,7 +70,6 @@ class OAuthController extends BaseController
}
/**
* @param Request $request
*
* @return Response
*/
@ -213,7 +202,6 @@ class OAuthController extends BaseController
}
/**
* @param Request $request
*
* @return Response
*/
@ -229,7 +217,6 @@ class OAuthController extends BaseController
}
/**
* @param Request $request
*
* @return Response
*/
@ -249,7 +236,6 @@ class OAuthController extends BaseController
}
/**
* @param string $name
*
* @return AbstractProvider
*/
@ -272,8 +258,6 @@ class OAuthController extends BaseController
}
/**
* @param string $providerName
* @param ResourceOwner $resourceOwner
* @return mixed
*/
protected function getId(string $providerName, ResourceOwner $resourceOwner)
@ -287,9 +271,6 @@ class OAuthController extends BaseController
return $data[$config['id']];
}
/**
* @param string $provider
*/
protected function requireProvider(string $provider): void
{
if (!$this->isValidProvider($provider)) {
@ -298,7 +279,6 @@ class OAuthController extends BaseController
}
/**
* @param string $name
*
* @return bool
*/
@ -309,11 +289,6 @@ class OAuthController extends BaseController
return isset($config[$name]);
}
/**
* @param OAuth $auth
* @param string $providerName
* @param ResourceOwner $resourceOwner
*/
protected function handleArrive(
string $providerName,
OAuth $auth,
@ -342,8 +317,6 @@ class OAuthController extends BaseController
}
/**
* @param IdentityProviderException $e
* @param string $providerName
*
* @throws HttpNotFound
*/
@ -364,11 +337,7 @@ class OAuthController extends BaseController
}
/**
* @param string $providerName
* @param string $providerUserIdentifier
* @param AccessTokenInterface $accessToken
* @param array $config
* @param Collection $userdata
*
* @return Response
*/

View File

@ -35,12 +35,6 @@ class PasswordResetController extends BaseController
'postResetPassword' => 'login',
];
/**
* @param Response $response
* @param SessionInterface $session
* @param EngelsystemMailer $mail
* @param LoggerInterface $log
*/
public function __construct(
Response $response,
SessionInterface $session,
@ -62,7 +56,6 @@ class PasswordResetController extends BaseController
}
/**
* @param Request $request
* @return Response
*/
public function postReset(Request $request): Response
@ -96,7 +89,6 @@ class PasswordResetController extends BaseController
}
/**
* @param Request $request
* @return Response
*/
public function resetPassword(Request $request): Response
@ -110,7 +102,6 @@ class PasswordResetController extends BaseController
}
/**
* @param Request $request
* @return Response
*/
public function postResetPassword(Request $request): Response
@ -135,11 +126,10 @@ class PasswordResetController extends BaseController
}
/**
* @param string $view
* @param array $data
* @return Response
*/
protected function showView($view = 'pages/password/reset', $data = []): Response
protected function showView(string $view = 'pages/password/reset', array $data = []): Response
{
return $this->response->withView(
$view,
@ -148,7 +138,6 @@ class PasswordResetController extends BaseController
}
/**
* @param Request $request
* @return PasswordReset
*/
protected function requireToken(Request $request): PasswordReset

View File

@ -34,13 +34,6 @@ class QuestionsController extends BaseController
'question.add',
];
/**
* @param Authenticator $auth
* @param LoggerInterface $log
* @param Question $question
* @param Redirector $redirect
* @param Response $response
*/
public function __construct(
Authenticator $auth,
LoggerInterface $log,
@ -84,7 +77,6 @@ class QuestionsController extends BaseController
}
/**
* @param Request $request
*
* @return Response
*/
@ -112,7 +104,6 @@ class QuestionsController extends BaseController
}
/**
* @param Request $request
*
* @return Response
*/

View File

@ -35,13 +35,6 @@ class SettingsController extends BaseController
'user_settings',
];
/**
* @param Authenticator $auth
* @param Config $config
* @param LoggerInterface $log
* @param Redirector $redirector
* @param Response $response
*/
public function __construct(
Authenticator $auth,
Config $config,
@ -73,7 +66,6 @@ class SettingsController extends BaseController
}
/**
* @param Request $request
* @return Response
*/
public function saveProfile(Request $request): Response
@ -151,7 +143,6 @@ class SettingsController extends BaseController
}
/**
* @param Request $request
* @return Response
*/
public function savePassword(Request $request): Response
@ -201,7 +192,6 @@ class SettingsController extends BaseController
}
/**
* @param Request $request
* @return Response
*/
public function saveTheme(Request $request): Response
@ -242,7 +232,6 @@ class SettingsController extends BaseController
}
/**
* @param Request $request
* @return Response
*/
public function saveLanguage(Request $request): Response

View File

@ -10,9 +10,6 @@ class Database
/** @var DatabaseConnection */
protected $connection;
/**
* @param DatabaseConnection $connection
*/
public function __construct(DatabaseConnection $connection)
{
$this->connection = $connection;
@ -21,11 +18,10 @@ class Database
/**
* Run a select query
*
* @param string $query
* @param array $bindings
* @return object[]
*/
public function select($query, array $bindings = [])
public function select(string $query, array $bindings = [])
{
return $this->connection->select($query, $bindings);
}
@ -33,11 +29,10 @@ class Database
/**
* Run a select query and return only the first result or null if no result is found.
*
* @param string $query
* @param array $bindings
* @return object|null
*/
public function selectOne($query, array $bindings = [])
public function selectOne(string $query, array $bindings = [])
{
return $this->connection->selectOne($query, $bindings);
}
@ -45,11 +40,10 @@ class Database
/**
* Run an insert query
*
* @param string $query
* @param array $bindings
* @return bool
*/
public function insert($query, array $bindings = [])
public function insert(string $query, array $bindings = [])
{
return $this->connection->insert($query, $bindings);
}
@ -57,11 +51,10 @@ class Database
/**
* Run an update query
*
* @param string $query
* @param array $bindings
* @return int
*/
public function update($query, array $bindings = [])
public function update(string $query, array $bindings = [])
{
return $this->connection->update($query, $bindings);
}
@ -69,11 +62,10 @@ class Database
/**
* Run a delete query
*
* @param string $query
* @param array $bindings
* @return int
*/
public function delete($query, array $bindings = [])
public function delete(string $query, array $bindings = [])
{
return $this->connection->delete($query, $bindings);
}

View File

@ -57,7 +57,6 @@ class DatabaseServiceProvider extends ServiceProvider
}
/**
* @param Throwable $exception
*
* @throws Exception
*/

View File

@ -15,9 +15,8 @@ class Db
/**
* Set the database connection manager
*
* @param CapsuleManager $dbManager
*/
public static function setDbManager($dbManager)
public static function setDbManager(CapsuleManager $dbManager)
{
self::$dbManager = $dbManager;
}
@ -25,11 +24,10 @@ class Db
/**
* Run a select query
*
* @param string $query
* @param array $bindings
* @return array[]
*/
public static function select($query, array $bindings = [])
public static function select(string $query, array $bindings = [])
{
$return = self::connection()->select($query, $bindings);
@ -44,11 +42,10 @@ class Db
/**
* Run a select query and return only the first result or null if no result is found.
*
* @param string $query
* @param array $bindings
* @return array|null
*/
public static function selectOne($query, array $bindings = [])
public static function selectOne(string $query, array $bindings = [])
{
$result = self::connection()->selectOne($query, $bindings);
@ -64,11 +61,10 @@ class Db
/**
* Run an insert query
*
* @param string $query
* @param array $bindings
* @return bool
*/
public static function insert($query, array $bindings = [])
public static function insert(string $query, array $bindings = [])
{
return self::connection()->insert($query, $bindings);
}
@ -76,11 +72,10 @@ class Db
/**
* Run an update query
*
* @param string $query
* @param array $bindings
* @return int
*/
public static function update($query, array $bindings = [])
public static function update(string $query, array $bindings = [])
{
return self::connection()->update($query, $bindings);
}
@ -88,11 +83,10 @@ class Db
/**
* Run a delete query
*
* @param string $query
* @param array $bindings
* @return int
*/
public static function delete($query, array $bindings = [])
public static function delete(string $query, array $bindings = [])
{
return self::connection()->delete($query, $bindings);
}

View File

@ -34,8 +34,6 @@ class Migrate
/**
* Migrate constructor
*
* @param SchemaBuilder $schema
* @param Application $app
*/
public function __construct(SchemaBuilder $schema, Application $app)
{
@ -48,12 +46,9 @@ class Migrate
/**
* Run a migration
*
* @param string $path
* @param string $type (up|down)
* @param bool $oneStep
* @param bool $forceMigration
*/
public function run($path, $type = self::UP, $oneStep = false, $forceMigration = false)
public function run(string $path, string $type = self::UP, bool $oneStep = false, bool $forceMigration = false)
{
$this->initMigration();
@ -118,8 +113,6 @@ class Migrate
/**
* Merge file migrations with already migrated tables
*
* @param Collection $migrations
* @param Collection $migrated
* @return Collection
*/
protected function mergeMigrations(Collection $migrations, Collection $migrated)
@ -163,11 +156,9 @@ class Migrate
/**
* Migrate a migration
*
* @param string $file
* @param string $migration
* @param string $type (up|down)
*/
protected function migrate($file, $migration, $type = self::UP)
protected function migrate(string $file, string $migration, string $type = self::UP)
{
require_once $file;
@ -183,10 +174,9 @@ class Migrate
/**
* Set a migration to migrated
*
* @param string $migration
* @param string $type (up|down)
*/
protected function setMigrated($migration, $type = self::UP)
protected function setMigrated(string $migration, string $type = self::UP)
{
$table = $this->getTableQuery();
@ -201,11 +191,10 @@ class Migrate
/**
* Lock the migrations table
*
* @param bool $forceMigration
*
* @throws Throwable
*/
protected function lockTable($forceMigration = false)
protected function lockTable(bool $forceMigration = false)
{
$this->schema->getConnection()->transaction(function () use ($forceMigration) {
$lock = $this->getTableQuery()
@ -235,11 +224,10 @@ class Migrate
/**
* Get a list of migration files
*
* @param string $dir
*
* @return Collection
*/
protected function getMigrations($dir)
protected function getMigrations(string $dir)
{
$files = $this->getMigrationFiles($dir);
@ -260,11 +248,10 @@ class Migrate
/**
* List all migration files from the given directory
*
* @param string $dir
*
* @return array
*/
protected function getMigrationFiles($dir)
protected function getMigrationFiles(string $dir)
{
return glob($dir . '/*_*.php');
}
@ -282,7 +269,6 @@ class Migrate
/**
* Set the output function
*
* @param callable $output
*/
public function setOutput(callable $output)
{

View File

@ -12,7 +12,6 @@ abstract class Migration
/**
* Migration constructor.
*
* @param SchemaBuilder $schemaBuilder
*/
public function __construct(SchemaBuilder $schemaBuilder)
{

View File

@ -10,45 +10,33 @@ class EventDispatcher
/** @var callable[] */
protected $listeners;
/**
* @param array|string $events
* @param callable|string $listener
*/
public function listen($events, $listener): void
public function listen(array|string $events, callable|string $listener): void
{
foreach ((array)$events as $event) {
$this->listeners[$event][] = $listener;
}
}
/**
* @param string $event
*/
public function forget($event): void
public function forget(string $event): void
{
unset($this->listeners[$event]);
}
/**
* @param string|object $event
* @param array|mixed $payload
* @param bool $halt
*
* @return array|mixed|null
*/
public function fire($event, $payload = [], $halt = false)
public function fire(string|object $event, mixed $payload = [], bool $halt = false)
{
return $this->dispatch($event, $payload, $halt);
}
/**
* @param string|object $event
* @param array|mixed $payload
* @param bool $halt Stop on first non-null return
*
* @return array|null|mixed
*/
public function dispatch($event, $payload = [], $halt = false)
public function dispatch(string|object $event, mixed $payload = [], bool $halt = false)
{
if (is_object($event)) {
$payload = $event;

View File

@ -17,9 +17,6 @@ class EventsServiceProvider extends ServiceProvider
$this->registerEvents($dispatcher);
}
/**
* @param EventDispatcher $dispatcher
*/
protected function registerEvents(EventDispatcher $dispatcher)
{
/** @var Config $config */

View File

@ -21,11 +21,6 @@ class News
/** @var UserSettings */
protected $settings;
/**
* @param LoggerInterface $log
* @param EngelsystemMailer $mailer
* @param UserSettings $settings
*/
public function __construct(
LoggerInterface $log,
EngelsystemMailer $mailer,
@ -36,9 +31,6 @@ class News
$this->settings = $settings;
}
/**
* @param NewsModel $news
*/
public function created(NewsModel $news)
{
/** @var UserSettings[]|Collection $recipients */
@ -52,12 +44,6 @@ class News
}
}
/**
* @param NewsModel $news
* @param User $user
* @param string $subject
* @param string $template
*/
protected function sendMail(NewsModel $news, User $user, string $subject, string $template)
{
try {

View File

@ -21,10 +21,6 @@ class OAuth2
/** @var LoggerInterface */
protected LoggerInterface $log;
/**
* @param Config $config
* @param LoggerInterface $log
*/
public function __construct(Config $config, LoggerInterface $log, Authenticator $auth)
{
$this->auth = $auth;
@ -33,7 +29,6 @@ class OAuth2
}
/**
* @param string $event
* @param string $provider OAuth provider name
* @param Collection $data OAuth userdata
*/

View File

@ -32,10 +32,7 @@ class ExceptionsServiceProvider extends ServiceProvider
$this->addLogger($handler);
}
/**
* @param Handler $errorHandler
*/
protected function addProductionHandler($errorHandler)
protected function addProductionHandler(Handler $errorHandler)
{
$handler = $this->app->make(Legacy::class);
$this->app->instance('error.handler.production', $handler);
@ -43,10 +40,7 @@ class ExceptionsServiceProvider extends ServiceProvider
$this->app->bind(HandlerInterface::class, 'error.handler.production');
}
/**
* @param Handler $errorHandler
*/
protected function addDevelopmentHandler($errorHandler)
protected function addDevelopmentHandler(Handler $errorHandler)
{
$handler = $this->app->make(LegacyDevelopment::class);
@ -58,9 +52,6 @@ class ExceptionsServiceProvider extends ServiceProvider
$errorHandler->setHandler(Handler::ENV_DEVELOPMENT, $handler);
}
/**
* @param Handler $handler
*/
protected function addLogger(Handler $handler)
{
foreach ($handler->getHandler() as $h) {

View File

@ -30,7 +30,7 @@ class Handler
*
* @param string $environment prod|dev
*/
public function __construct($environment = self::ENV_PRODUCTION)
public function __construct(string $environment = self::ENV_PRODUCTION)
{
$this->environment = $environment;
}
@ -44,24 +44,16 @@ class Handler
set_exception_handler([$this, 'exceptionHandler']);
}
/**
* @param int $number
* @param string $message
* @param string $file
* @param int $line
*/
public function errorHandler($number, $message, $file, $line)
public function errorHandler(int $number, string $message, string $file, int $line)
{
$exception = new ErrorException($message, 0, $number, $file, $line);
$this->exceptionHandler($exception);
}
/**
* @param Throwable $e
* @param bool $return
* @return string
*/
public function exceptionHandler($e, $return = false)
public function exceptionHandler(Throwable $e, bool $return = false)
{
if (!$this->request instanceof Request) {
$this->request = new Request();
@ -90,9 +82,8 @@ class Handler
* Exit the application
*
* @codeCoverageIgnore
* @param string $message
*/
protected function terminateApplicationImmediately($message = '')
protected function terminateApplicationImmediately(string $message = '')
{
echo $message;
die(1);
@ -106,19 +97,15 @@ class Handler
return $this->environment;
}
/**
* @param string $environment
*/
public function setEnvironment($environment)
public function setEnvironment(string $environment)
{
$this->environment = $environment;
}
/**
* @param string $environment
* @return HandlerInterface|HandlerInterface[]
*/
public function getHandler($environment = null)
public function getHandler(string $environment = null)
{
if (!is_null($environment)) {
return $this->handler[$environment];
@ -127,11 +114,7 @@ class Handler
return $this->handler;
}
/**
* @param string $environment
* @param HandlerInterface $handler
*/
public function setHandler($environment, HandlerInterface $handler)
public function setHandler(string $environment, HandlerInterface $handler)
{
$this->handler[$environment] = $handler;
}
@ -144,9 +127,6 @@ class Handler
return $this->request;
}
/**
* @param Request $request
*/
public function setRequest(Request $request)
{
$this->request = $request;

View File

@ -7,14 +7,7 @@ use Throwable;
interface HandlerInterface
{
/**
* @param Request $request
* @param Throwable $e
*/
public function render($request, Throwable $e);
public function render(Request $request, Throwable $e);
/**
* @param Throwable $e
*/
public function report(Throwable $e);
}

View File

@ -11,18 +11,11 @@ class Legacy implements HandlerInterface
/** @var LoggerInterface */
protected $log;
/**
* @param Request $request
* @param Throwable $e
*/
public function render($request, Throwable $e)
public function render(Request $request, Throwable $e)
{
echo 'An <del>un</del>expected error occurred. A team of untrained monkeys has been dispatched to fix it.';
}
/**
* @param Throwable $e
*/
public function report(Throwable $e)
{
$previous = $e->getPrevious();
@ -46,19 +39,15 @@ class Legacy implements HandlerInterface
}
}
/**
* @param LoggerInterface $logger
*/
public function setLogger(LoggerInterface $logger)
{
$this->log = $logger;
}
/**
* @param string $path
* @return string
*/
protected function stripBasePath($path)
protected function stripBasePath(string $path)
{
$basePath = realpath(__DIR__ . '/../../..') . '/';
return str_replace($basePath, '', $path);

View File

@ -7,11 +7,7 @@ use Throwable;
class LegacyDevelopment extends Legacy
{
/**
* @param Request $request
* @param Throwable $e
*/
public function render($request, Throwable $e)
public function render(Request $request, Throwable $e)
{
$file = $this->stripBasePath($e->getFile());
@ -40,7 +36,7 @@ class LegacyDevelopment extends Legacy
* @param array $stackTrace
* @return array
*/
protected function formatStackTrace($stackTrace)
protected function formatStackTrace(array $stackTrace)
{
$return = [];
$stackTrace = array_reverse($stackTrace);

View File

@ -7,11 +7,7 @@ use Throwable;
class NullHandler extends Legacy
{
/**
* @param Request $request
* @param Throwable $e
*/
public function render($request, Throwable $e)
public function render(Request $request, Throwable $e)
{
return;
}

View File

@ -19,18 +19,13 @@ class Whoops extends Legacy implements HandlerInterface
/**
* Whoops constructor.
*
* @param Container $app
*/
public function __construct(Container $app)
{
$this->app = $app;
}
/**
* @param Request $request
* @param Throwable $e
*/
public function render($request, Throwable $e)
public function render(Request $request, Throwable $e)
{
$whoops = $this->app->make(WhoopsRunner::class);
$handler = $this->getPrettyPageHandler($e);
@ -47,7 +42,6 @@ class Whoops extends Legacy implements HandlerInterface
}
/**
* @param Throwable $e
* @return PrettyPageHandler
*/
protected function getPrettyPageHandler(Throwable $e)

View File

@ -19,7 +19,6 @@ class Assets
}
/**
* @param string $asset
* @return string
*/
public function getAssetPath(string $asset): string

View File

@ -35,11 +35,6 @@ class Authenticator
/** @var int */
protected int $guestRole = 10;
/**
* @param ServerRequestInterface $request
* @param Session $session
* @param UserRepository $userRepository
*/
public function __construct(ServerRequestInterface $request, Session $session, UserRepository $userRepository)
{
$this->request = $request;
@ -78,7 +73,6 @@ class Authenticator
/**
* Get the user by his api key
*
* @param string $parameter
* @return User|null
*/
public function apiUser(string $parameter = 'api_key'): ?User
@ -110,7 +104,7 @@ class Authenticator
* @param string[]|string $abilities
* @return bool
*/
public function can($abilities): bool
public function can(array|string $abilities): bool
{
$abilities = (array)$abilities;
@ -143,8 +137,6 @@ class Authenticator
}
/**
* @param string $login
* @param string $password
* @return User|null
*/
public function authenticate(string $login, string $password): ?User
@ -167,8 +159,6 @@ class Authenticator
}
/**
* @param User $user
* @param string $password
* @return bool
*/
public function verifyPassword(User $user, string $password): bool
@ -184,10 +174,6 @@ class Authenticator
return true;
}
/**
* @param User $user
* @param string $password
*/
public function setPassword(User $user, string $password)
{
$user->password = password_hash($password, $this->passwordAlgorithm);
@ -202,10 +188,7 @@ class Authenticator
return $this->passwordAlgorithm;
}
/**
* @param int|string|null $passwordAlgorithm
*/
public function setPasswordAlgorithm($passwordAlgorithm)
public function setPasswordAlgorithm(int|string|null $passwordAlgorithm)
{
$this->passwordAlgorithm = $passwordAlgorithm;
}
@ -218,9 +201,6 @@ class Authenticator
return $this->defaultRole;
}
/**
* @param int $defaultRole
*/
public function setDefaultRole(int $defaultRole)
{
$this->defaultRole = $defaultRole;
@ -234,9 +214,6 @@ class Authenticator
return $this->guestRole;
}
/**
* @param int $guestRole
*/
public function setGuestRole(int $guestRole)
{
$this->guestRole = $guestRole;

View File

@ -18,7 +18,6 @@ class Carbon extends \Carbon\Carbon
/**
* Parses HTML datetime-local and ISO date/time strings.
*
* @param string $value
* @return \Carbon\Carbon|null Carbon if parseable, else null
* @see self::DATETIME_FORMATS
*/
@ -36,7 +35,6 @@ class Carbon extends \Carbon\Carbon
/**
* Parses HTML datetime-local and ISO date/time strings.
*
* @param string $value
* @return int|null Timestamp if parseable, else null
* @see self::DATETIME_FORMATS
*/

View File

@ -27,7 +27,6 @@ class ConfigureEnvironmentServiceProvider extends ServiceProvider
}
/**
* @param CarbonTimeZone $timeZone
* @codeCoverageIgnore
*/
protected function setTimeZone(CarbonTimeZone $timeZone)
@ -37,7 +36,6 @@ class ConfigureEnvironmentServiceProvider extends ServiceProvider
}
/**
* @param bool $displayErrors
* @codeCoverageIgnore
*/
protected function displayErrors(bool $displayErrors)
@ -46,7 +44,6 @@ class ConfigureEnvironmentServiceProvider extends ServiceProvider
}
/**
* @param int $errorReporting
* @codeCoverageIgnore
*/
protected function errorReporting(int $errorReporting)

View File

@ -7,7 +7,6 @@ namespace Engelsystem\Helpers\Schedule;
trait CalculatesTime
{
/**
* @param string $time
* @return int
*/
protected function secondsFromTime(string $time): int

View File

@ -32,13 +32,6 @@ class Conference
/**
* Event constructor.
*
* @param string $title
* @param string $acronym
* @param string|null $start
* @param string|null $end
* @param int|null $days
* @param string|null $timeslotDuration
* @param string|null $baseUrl
*/
public function __construct(
string $title,

View File

@ -26,10 +26,6 @@ class Day
/**
* Day constructor.
*
* @param string $date
* @param Carbon $start
* @param Carbon $end
* @param int $index
* @param Room[] $rooms
*/
public function __construct(

View File

@ -79,27 +79,10 @@ class Event
/**
* Event constructor.
*
* @param string $guid
* @param int $id
* @param Room $room
* @param string $title
* @param string $subtitle
* @param string $type
* @param Carbon $date
* @param string $start
* @param string $duration
* @param string $abstract
* @param string $slug
* @param string $track
* @param string|null $logo
* @param string[] $persons
* @param string|null $language
* @param string|null $description
* @param string|null $recording license
* @param array $links
* @param array $attachments
* @param string|null $url
* @param string|null $videoDownloadUrl
*/
public function __construct(
string $guid,
@ -183,9 +166,6 @@ class Event
return $this->title;
}
/**
* @param string $title
*/
public function setTitle(string $title): void
{
$this->title = $title;

View File

@ -15,7 +15,6 @@ class Room
/**
* Room constructor.
*
* @param string $name
* @param Event[] $events
*/
public function __construct(

View File

@ -18,8 +18,6 @@ class Schedule
protected $day;
/**
* @param string $version
* @param Conference $conference
* @param Day[] $days
*/
public function __construct(

View File

@ -16,7 +16,6 @@ class XmlParser
protected $schedule;
/**
* @param string $xml
* @return bool
*/
public function load(string $xml): bool
@ -82,7 +81,6 @@ class XmlParser
/**
* @param SimpleXMLElement[] $eventElements
* @param Room $room
* @return array
*/
protected function parseEvents(array $eventElements, Room $room): array
@ -129,8 +127,6 @@ class XmlParser
}
/**
* @param string $path
* @param SimpleXMLElement|null $xml
* @return string
*/
protected function getFirstXpathContent(string $path, ?SimpleXMLElement $xml = null): string
@ -143,10 +139,6 @@ class XmlParser
/**
* Resolves a list from a sequence of elements
*
* @param SimpleXMLElement $element
* @param string $firstElement
* @param string $secondElement
* @param string $idAttribute
* @return array
*/
protected function getListFromSequence(

View File

@ -10,8 +10,6 @@ class Shifts
/**
* Check if a time range is a night shift
*
* @param Carbon $start
* @param Carbon $end
* @return bool
*/
public static function isNightShift(Carbon $start, Carbon $end): bool
@ -27,8 +25,6 @@ class Shifts
/**
* Calculate a shifts night multiplier
*
* @param Carbon $start
* @param Carbon $end
* @return float
*/
public static function getNightShiftMultiplier(Carbon $start, Carbon $end): float

View File

@ -7,9 +7,6 @@ use Gettext\Translator;
class GettextTranslator extends Translator
{
/**
* @param string|null $domain
* @param string|null $context
* @param string $original
* @return string
* @throws TranslationNotFound
*/
@ -21,11 +18,6 @@ class GettextTranslator extends Translator
}
/**
* @param string|null $domain
* @param string|null $context
* @param string $original
* @param string $plural
* @param int $value
* @return string
* @throws TranslationNotFound
*/
@ -42,12 +34,9 @@ class GettextTranslator extends Translator
}
/**
* @param string $domain
* @param string $context
* @param string $original
* @throws TranslationNotFound
*/
protected function assertHasTranslation($domain, $context, $original)
protected function assertHasTranslation(?string $domain, ?string $context, string $original)
{
if ($this->getTranslation($domain, $context, $original)) {
return;

View File

@ -54,7 +54,6 @@ class TranslationServiceProvider extends ServiceProvider
}
/**
* @param string $locale
* @codeCoverageIgnore
*/
public function setLocale(string $locale): void
@ -70,7 +69,6 @@ class TranslationServiceProvider extends ServiceProvider
}
/**
* @param string $locale
* @return GettextTranslator
*/
public function getTranslator(string $locale): GettextTranslator
@ -101,8 +99,6 @@ class TranslationServiceProvider extends ServiceProvider
}
/**
* @param string $locale
* @param string $name
* @return string
*/
protected function getFile(string $locale, string $name = 'default'): string

View File

@ -22,11 +22,7 @@ class Translator
/**
* Translator constructor.
*
* @param string $locale
* @param string $fallbackLocale
* @param callable $getTranslatorCallback
* @param string[] $locales
* @param callable $localeChangeCallback
*/
public function __construct(
string $locale,
@ -46,7 +42,6 @@ class Translator
/**
* Get the translation for a given key
*
* @param string $key
* @param array $replace
* @return string
*/
@ -58,9 +53,6 @@ class Translator
/**
* Get the translation for a given key
*
* @param string $key
* @param string $pluralKey
* @param int $number
* @param array $replace
* @return string
*/
@ -70,7 +62,6 @@ class Translator
}
/**
* @param string $type
* @param array $parameters
* @param array $replace
* @return mixed|string
@ -96,7 +87,6 @@ class Translator
/**
* Replace placeholders
*
* @param string $key
* @param array $replace
* @return mixed|string
*/
@ -117,9 +107,6 @@ class Translator
return $this->locale;
}
/**
* @param string $locale
*/
public function setLocale(string $locale)
{
$this->locale = $locale;
@ -138,7 +125,6 @@ class Translator
}
/**
* @param string $locale
* @return bool
*/
public function hasLocale(string $locale): bool

View File

@ -15,10 +15,6 @@ class Version
/** @var string */
protected $versionFile = 'VERSION';
/**
* @param string $storage
* @param Config $config
*/
public function __construct(string $storage, Config $config)
{
$this->storage = $storage;

View File

@ -7,9 +7,7 @@ use Throwable;
class HttpAuthExpired extends HttpException
{
/**
* @param string $message
* @param array $headers
* @param int $code
* @param Throwable|null $previous
*/
public function __construct(

View File

@ -14,10 +14,7 @@ class HttpException extends RuntimeException
protected $headers = [];
/**
* @param int $statusCode
* @param string $message
* @param array $headers
* @param int $code
* @param Throwable|null $previous
*/
public function __construct(

View File

@ -7,9 +7,7 @@ use Throwable;
class HttpForbidden extends HttpException
{
/**
* @param string $message
* @param array $headers
* @param int $code
* @param Throwable|null $previous
*/
public function __construct(

View File

@ -7,9 +7,7 @@ use Throwable;
class HttpNotFound extends HttpException
{
/**
* @param string $message
* @param array $headers
* @param int $code
* @param Throwable|null $previous
*/
public function __construct(

View File

@ -5,7 +5,6 @@ namespace Engelsystem\Http\Exceptions;
class HttpPermanentRedirect extends HttpRedirect
{
/**
* @param string $url
* @param array $headers
*/
public function __construct(

View File

@ -5,8 +5,6 @@ namespace Engelsystem\Http\Exceptions;
class HttpRedirect extends HttpException
{
/**
* @param string $url
* @param int $statusCode
* @param array $headers
*/
public function __construct(

View File

@ -5,7 +5,6 @@ namespace Engelsystem\Http\Exceptions;
class HttpTemporaryRedirect extends HttpRedirect
{
/**
* @param string $url
* @param array $headers
*/
public function __construct(

View File

@ -12,9 +12,6 @@ class ValidationException extends RuntimeException
protected $validator;
/**
* @param Validator $validator
* @param string $message
* @param int $code
* @param Throwable|null $previous
*/
public function __construct(

View File

@ -36,10 +36,11 @@ trait MessageTrait
* @param string $version HTTP protocol version
* @return static
*/
public function withProtocolVersion($version)
public function withProtocolVersion(mixed $version)
{
$new = clone $this;
if (method_exists($new, 'setProtocolVersion')) {
/** @var MessageTrait */
$new->setProtocolVersion($version);
} else {
$new->server->set('SERVER_PROTOCOL', $version);
@ -90,7 +91,7 @@ trait MessageTrait
* name using a case-insensitive string comparison. Returns false if
* no matching header name is found in the message.
*/
public function hasHeader($name)
public function hasHeader(mixed $name)
{
return $this->headers->has($name);
}
@ -109,7 +110,7 @@ trait MessageTrait
* header. If the header does not appear in the message, this method MUST
* return an empty array.
*/
public function getHeader($name)
public function getHeader(mixed $name)
{
return $this->headers->all($name);
}
@ -133,7 +134,7 @@ trait MessageTrait
* concatenated together using a comma. If the header does not appear in
* the message, this method MUST return an empty string.
*/
public function getHeaderLine($name)
public function getHeaderLine(mixed $name)
{
return implode(',', $this->getHeader($name));
}
@ -153,7 +154,7 @@ trait MessageTrait
* @return static
* @throws \InvalidArgumentException for invalid header names or values.
*/
public function withHeader($name, $value)
public function withHeader(mixed $name, mixed $value)
{
$new = clone $this;
$new->headers->set($name, $value);
@ -177,7 +178,7 @@ trait MessageTrait
* @return static
* @throws \InvalidArgumentException for invalid header names or values.
*/
public function withAddedHeader($name, $value)
public function withAddedHeader(mixed $name, mixed $value)
{
$new = clone $this;
$new->headers->set($name, $value, false);
@ -197,7 +198,7 @@ trait MessageTrait
* @param string $name Case-insensitive header field name to remove.
* @return static
*/
public function withoutHeader($name)
public function withoutHeader(mixed $name)
{
$new = clone $this;
$new->headers->remove($name);

View File

@ -13,11 +13,6 @@ class Redirector
/** @var UrlGeneratorInterface */
protected $url;
/**
* @param Request $request
* @param Response $response
* @param UrlGeneratorInterface $url
*/
public function __construct(Request $request, Response $response, UrlGeneratorInterface $url)
{
$this->request = $request;
@ -28,8 +23,6 @@ class Redirector
/**
* Redirects to a path, generating a full URL
*
* @param string $path
* @param int $status
* @param array $headers
* @return Response
*/
@ -39,7 +32,6 @@ class Redirector
}
/**
* @param int $status
* @param array $headers
* @return Response
*/

View File

@ -16,11 +16,9 @@ class Request extends SymfonyRequest implements ServerRequestInterface
/**
* Get POST input
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public function postData($key, $default = null)
public function postData(string $key, mixed $default = null)
{
return $this->request->get($key, $default);
}
@ -28,11 +26,9 @@ class Request extends SymfonyRequest implements ServerRequestInterface
/**
* Get input data
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public function input($key, $default = null)
public function input(string $key, mixed $default = null)
{
return $this->get($key, $default);
}
@ -40,10 +36,9 @@ class Request extends SymfonyRequest implements ServerRequestInterface
/**
* Checks if the input exists
*
* @param string $key
* @return bool
*/
public function has($key)
public function has(string $key)
{
$value = $this->input($key);
@ -53,10 +48,9 @@ class Request extends SymfonyRequest implements ServerRequestInterface
/**
* Checks if the POST data exists
*
* @param string $key
* @return bool
*/
public function hasPostData($key)
public function hasPostData(string $key)
{
$value = $this->postData($key);
@ -122,10 +116,9 @@ class Request extends SymfonyRequest implements ServerRequestInterface
*
* @link http://tools.ietf.org/html/rfc7230#section-5.3 (for the various
* request-target forms allowed in request messages)
* @param mixed $requestTarget
* @return static
*/
public function withRequestTarget($requestTarget)
public function withRequestTarget(mixed $requestTarget)
{
return $this->create($requestTarget);
}
@ -145,7 +138,7 @@ class Request extends SymfonyRequest implements ServerRequestInterface
* @return static
* @throws \InvalidArgumentException for invalid HTTP methods.
*/
public function withMethod($method)
public function withMethod(mixed $method)
{
$new = clone $this;
$new->setMethod($method);
@ -183,7 +176,7 @@ class Request extends SymfonyRequest implements ServerRequestInterface
* @param bool $preserveHost Preserve the original state of the Host header.
* @return static
*/
public function withUri(UriInterface $uri, $preserveHost = false)
public function withUri(UriInterface $uri, mixed $preserveHost = false)
{
$new = $this->create($uri);
if ($preserveHost) {
@ -409,7 +402,7 @@ class Request extends SymfonyRequest implements ServerRequestInterface
* @throws \InvalidArgumentException if an unsupported argument type is
* provided.
*/
public function withParsedBody($data)
public function withParsedBody(mixed $data)
{
$new = clone $this;
$new->request = clone $this->request;
@ -450,7 +443,7 @@ class Request extends SymfonyRequest implements ServerRequestInterface
* @return mixed
* @see getAttributes()
*/
public function getAttribute($name, $default = null)
public function getAttribute(mixed $name, mixed $default = null)
{
return $this->attributes->get($name, $default);
}
@ -470,7 +463,7 @@ class Request extends SymfonyRequest implements ServerRequestInterface
* @return static
* @see getAttributes()
*/
public function withAttribute($name, $value)
public function withAttribute(mixed $name, mixed $value)
{
$new = clone $this;
$new->attributes = clone $this->attributes;
@ -494,7 +487,7 @@ class Request extends SymfonyRequest implements ServerRequestInterface
* @return static
* @see getAttributes()
*/
public function withoutAttribute($name)
public function withoutAttribute(mixed $name)
{
$new = clone $this;
$new->attributes = clone $this->attributes;

View File

@ -53,7 +53,7 @@ class RequestServiceProvider extends ServiceProvider
array $cookies = [],
array $files = [],
array $server = [],
$content = null
mixed $content = null
): Request {
if (
!empty($this->appUrl['path'])
@ -81,15 +81,13 @@ class RequestServiceProvider extends ServiceProvider
*
* Required for unit tests (static methods can't be mocked)
*
* @param Request $request
* @param array $proxies
* @param int $trustedHeadersSet
* @codeCoverageIgnore
*/
protected function setTrustedProxies(
$request,
$proxies,
$trustedHeadersSet = Request::HEADER_FORWARDED | Request::HEADER_X_FORWARDED_TRAEFIK
Request $request,
array $proxies,
int $trustedHeadersSet = Request::HEADER_FORWARDED | Request::HEADER_X_FORWARDED_TRAEFIK
) {
$request->setTrustedProxies($proxies, $trustedHeadersSet);
}

View File

@ -21,14 +21,10 @@ class Response extends SymfonyResponse implements ResponseInterface
protected $renderer;
/**
* @param string $content
* @param int $status
* @param array $headers
* @param Renderer $renderer
* @param SessionInterface $session
*/
public function __construct(
$content = '',
string $content = '',
int $status = 200,
array $headers = [],
Renderer $renderer = null,
@ -60,7 +56,7 @@ class Response extends SymfonyResponse implements ResponseInterface
* @return static
* @throws InvalidArgumentException For invalid status code arguments.
*/
public function withStatus($code, $reasonPhrase = '')
public function withStatus(mixed $code, mixed $reasonPhrase = '')
{
$new = clone $this;
$new->setStatusCode($code, !empty($reasonPhrase) ? $reasonPhrase : null);
@ -96,7 +92,7 @@ class Response extends SymfonyResponse implements ResponseInterface
* @param mixed $content Content that can be cast to string
* @return static
*/
public function withContent($content)
public function withContent(mixed $content)
{
$new = clone $this;
$new->setContent($content);
@ -110,13 +106,11 @@ class Response extends SymfonyResponse implements ResponseInterface
* This method retains the immutability of the message and returns
* an instance with the updated status and headers
*
* @param string $view
* @param array $data
* @param int $status
* @param string[]|string[][] $headers
* @return Response
*/
public function withView($view, $data = [], $status = 200, $headers = [])
public function withView(string $view, array $data = [], int $status = 200, array $headers = [])
{
if (!$this->renderer instanceof Renderer) {
throw new InvalidArgumentException('Renderer not defined');
@ -139,12 +133,10 @@ class Response extends SymfonyResponse implements ResponseInterface
* This method retains the immutability of the message and returns
* an instance with the updated status and headers
*
* @param string $path
* @param int $status
* @param array $headers
* @return Response
*/
public function redirectTo($path, $status = 302, $headers = [])
public function redirectTo(string $path, int $status = 302, array $headers = [])
{
$response = $this->withStatus($status);
$response = $response->withHeader('location', $path);
@ -159,7 +151,6 @@ class Response extends SymfonyResponse implements ResponseInterface
/**
* Set the renderer to use
*
* @param Renderer $renderer
*/
public function setRenderer(Renderer $renderer)
{
@ -169,11 +160,9 @@ class Response extends SymfonyResponse implements ResponseInterface
/**
* Sets a session attribute (which is mutable)
*
* @param string $key
* @param mixed|mixed[] $value
* @return Response
*/
public function with(string $key, $value)
public function with(string $key, mixed $value)
{
if (!$this->session instanceof SessionInterface) {
throw new InvalidArgumentException('Session not defined');

View File

@ -12,7 +12,6 @@ class UrlGenerator implements UrlGeneratorInterface
/**
* Create a URL for the given path, using the applications base url if configured
*
* @param string $path
* @param array $parameters
* @return string url in the form [app url]/[path]?[parameters]
*/
@ -35,7 +34,6 @@ class UrlGenerator implements UrlGeneratorInterface
/**
* Check if the URL is valid
*
* @param string $path
* @return bool
*/
public function isValidUrl(string $path): bool

View File

@ -8,7 +8,6 @@ namespace Engelsystem\Http;
interface UrlGeneratorInterface
{
/**
* @param string $path
* @param array $parameters
* @return string
*/

View File

@ -6,7 +6,7 @@ use Respect\Validation\Rules\AbstractRule;
class Checked extends AbstractRule
{
public function validate($input)
public function validate(mixed $input)
{
return in_array($input, ['yes', 'on', 1, '1', 'true', true], true);
}

View File

@ -6,11 +6,7 @@ use Respect\Validation\Rules\In as RespectIn;
class In extends RespectIn
{
/**
* @param mixed $haystack
* @param bool $compareIdentical
*/
public function __construct($haystack, $compareIdentical = false)
public function __construct(mixed $haystack, bool $compareIdentical = false)
{
if (!is_array($haystack)) {
$haystack = explode(',', $haystack);

View File

@ -5,10 +5,9 @@ namespace Engelsystem\Http\Validation\Rules;
class NotIn extends In
{
/**
* @param mixed $input
* @return bool
*/
public function validate($input)
public function validate(mixed $input)
{
return !parent::validate($input);
}

View File

@ -11,10 +11,9 @@ trait StringInputLength
/**
* Use the input length of a string
*
* @param mixed $input
* @return bool
*/
public function validate($input): bool
public function validate(mixed $input): bool
{
if (
is_string($input)
@ -28,10 +27,9 @@ trait StringInputLength
}
/**
* @param mixed $input
* @return bool
*/
protected function isDateTime($input): bool
protected function isDateTime(mixed $input): bool
{
try {
new DateTime($input);

View File

@ -11,7 +11,6 @@ trait ValidatesRequest
protected $validator;
/**
* @param Request $request
* @param array $rules
* @return array
*/
@ -29,9 +28,6 @@ trait ValidatesRequest
return $this->validator->getData();
}
/**
* @param Validator $validator
*/
public function setValidator(Validator $validator)
{
$this->validator = $validator;

View File

@ -31,7 +31,7 @@ class Validator
* @param array $rules
* @return bool
*/
public function validate($data, $rules)
public function validate(array $data, array $rules)
{
$this->errors = [];
$this->data = [];
@ -86,19 +86,17 @@ class Validator
}
/**
* @param string $rule
* @return string
*/
protected function map($rule)
protected function map(string $rule)
{
return $this->mapping[$rule] ?? $rule;
}
/**
* @param string $rule
* @return string
*/
protected function mapBack($rule)
protected function mapBack(string $rule)
{
$mapping = array_flip($this->mapping);

View File

@ -25,9 +25,6 @@ class Logger extends AbstractLogger
/** @var LogEntry */
protected $log;
/**
* @param LogEntry $log
*/
public function __construct(LogEntry $log)
{
$this->log = $log;
@ -36,12 +33,10 @@ class Logger extends AbstractLogger
/**
* Logs with an arbitrary level.
*
* @param mixed $level
* @param string|Stringable $message
* @param array $context
*
*/
public function log($level, string|Stringable $message, array $context = []): void
public function log(mixed $level, string|Stringable $message, array $context = []): void
{
if (!$this->checkLevel($level)) {
throw new InvalidArgumentException('Unknown log level: ' . $level);
@ -59,11 +54,10 @@ class Logger extends AbstractLogger
/**
* Interpolates context values into the message placeholders.
*
* @param string $message
* @param array $context
* @return string
*/
protected function interpolate($message, array $context = []): string
protected function interpolate(string $message, array $context = []): string
{
foreach ($context as $key => $val) {
// check that the value can be casted to string
@ -79,7 +73,6 @@ class Logger extends AbstractLogger
}
/**
* @param Throwable $e
* @return string
*/
protected function formatException(Throwable $e): string
@ -95,10 +88,9 @@ class Logger extends AbstractLogger
}
/**
* @param string $level
* @return bool
*/
protected function checkLevel($level): bool
protected function checkLevel(string $level): bool
{
return in_array($level, $this->allowedLevels);
}

View File

@ -14,13 +14,11 @@ class UserAwareLogger extends Logger
/**
* Logs with an arbitrary level and prepends the user
*
* @param mixed $level
* @param string|Stringable $message
* @param array $context
*
* @throws InvalidArgumentException
*/
public function log($level, string|Stringable $message, array $context = []): void
public function log(mixed $level, string|Stringable $message, array $context = []): void
{
if ($this->auth && ($user = $this->auth->user())) {
$message = sprintf('%s (%u): %s', $user->name, $user->id, $message);
@ -29,9 +27,6 @@ class UserAwareLogger extends Logger
parent::log($level, $message, $context);
}
/**
* @param Authenticator $auth
*/
public function setAuth(Authenticator $auth): void
{
$this->auth = $auth;

View File

@ -19,7 +19,6 @@ class EngelsystemMailer extends Mailer
protected $subjectPrefix = null;
/**
* @param MailerInterface $mailer
* @param Renderer|null $view
* @param Translator|null $translation
*/
@ -33,13 +32,10 @@ class EngelsystemMailer extends Mailer
/**
* @param string|string[]|User $to
* @param string $subject
* @param string $template
* @param array $data
* @param string|null $locale
*/
public function sendViewTranslated(
$to,
string|array|User $to,
string $subject,
string $template,
array $data = [],
@ -72,11 +68,9 @@ class EngelsystemMailer extends Mailer
* Send a template
*
* @param string|string[] $to
* @param string $subject
* @param string $template
* @param array $data
*/
public function sendView($to, string $subject, string $template, array $data = []): void
public function sendView(string|array $to, string $subject, string $template, array $data = []): void
{
$body = $this->view->render($template, $data);
@ -87,10 +81,8 @@ class EngelsystemMailer extends Mailer
* Send the mail
*
* @param string|string[] $to
* @param string $subject
* @param string $body
*/
public function send($to, string $subject, string $body): void
public function send(string|array $to, string $subject, string $body): void
{
if ($this->subjectPrefix) {
$subject = sprintf('[%s] %s', $this->subjectPrefix, trim($subject));
@ -107,9 +99,6 @@ class EngelsystemMailer extends Mailer
return $this->subjectPrefix;
}
/**
* @param string $subjectPrefix
*/
public function setSubjectPrefix(string $subjectPrefix)
{
$this->subjectPrefix = $subjectPrefix;

View File

@ -25,10 +25,8 @@ class Mailer
* Send the mail
*
* @param string|string[] $to
* @param string $subject
* @param string $body
*/
public function send($to, string $subject, string $body): void
public function send(string|array $to, string $subject, string $body): void
{
$message = (new Email())
->to(...(array)$to)
@ -47,9 +45,6 @@ class Mailer
return $this->fromAddress;
}
/**
* @param string $fromAddress
*/
public function setFromAddress(string $fromAddress)
{
$this->fromAddress = $fromAddress;
@ -63,9 +58,6 @@ class Mailer
return $this->fromName;
}
/**
* @param string $fromName
*/
public function setFromName(string $fromName)
{
$this->fromName = $fromName;

View File

@ -45,11 +45,10 @@ class MailerServiceProvider extends ServiceProvider
}
/**
* @param string|null $transport
* @param array $config
* @return TransportInterface
*/
protected function getTransport($transport, $config)
protected function getTransport(?string $transport, array $config)
{
switch ($transport) {
case 'log':

View File

@ -21,7 +21,6 @@ class LogTransport extends AbstractTransport
/**
* Send the message to log
*
* @param SentMessage $message
*/
protected function doSend(SentMessage $message): void
{

View File

@ -13,9 +13,6 @@ class AddHeaders implements MiddlewareInterface
/** @var Config */
protected $config;
/**
* @param Config $config
*/
public function __construct(Config $config)
{
$this->config = $config;
@ -24,8 +21,6 @@ class AddHeaders implements MiddlewareInterface
/**
* Process an incoming server request and setting the locale if required
*
* @param ServerRequestInterface $request
* @param RequestHandlerInterface $handler
* @return ResponseInterface
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface

View File

@ -20,7 +20,6 @@ class CallableHandler implements MiddlewareInterface, RequestHandlerInterface
/**
* @param callable $callable The callable that should be wrapped
* @param Container $container
*/
public function __construct(callable $callable, Container $container = null)
{
@ -32,8 +31,6 @@ class CallableHandler implements MiddlewareInterface, RequestHandlerInterface
* Process an incoming server request and return a response, optionally delegating
* response creation to a handler.
*
* @param ServerRequestInterface $request
* @param RequestHandlerInterface $handler
* @return ResponseInterface
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
@ -44,7 +41,6 @@ class CallableHandler implements MiddlewareInterface, RequestHandlerInterface
/**
* Handle the request and return a response.
*
* @param ServerRequestInterface $request
* @return ResponseInterface
*/
public function handle(ServerRequestInterface $request): ResponseInterface

View File

@ -27,7 +27,7 @@ class Dispatcher implements MiddlewareInterface, RequestHandlerInterface
* @param MiddlewareInterface[]|string[] $stack
* @param Application|null $container
*/
public function __construct($stack = [], Application $container = null)
public function __construct(array $stack = [], Application $container = null)
{
$this->stack = $stack;
$this->container = $container;
@ -39,8 +39,6 @@ class Dispatcher implements MiddlewareInterface, RequestHandlerInterface
*
* Could be used to group middleware
*
* @param ServerRequestInterface $request
* @param RequestHandlerInterface $handler
* @return ResponseInterface
*/
public function process(
@ -57,7 +55,6 @@ class Dispatcher implements MiddlewareInterface, RequestHandlerInterface
*
* It calls all configured middleware and handles their response
*
* @param ServerRequestInterface $request
* @return ResponseInterface
*/
public function handle(ServerRequestInterface $request): ResponseInterface
@ -80,9 +77,6 @@ class Dispatcher implements MiddlewareInterface, RequestHandlerInterface
return $middleware->process($request, $this);
}
/**
* @param Application $container
*/
public function setContainer(Application $container)
{
$this->container = $container;

View File

@ -38,9 +38,6 @@ class ErrorHandler implements MiddlewareInterface
'_token',
];
/**
* @param TwigLoader $loader
*/
public function __construct(TwigLoader $loader)
{
$this->loader = $loader;
@ -51,8 +48,6 @@ class ErrorHandler implements MiddlewareInterface
*
* Should be added at the beginning
*
* @param ServerRequestInterface $request
* @param RequestHandlerInterface $handler
* @return ResponseInterface
*/
public function process(
@ -105,7 +100,6 @@ class ErrorHandler implements MiddlewareInterface
/**
* Select a view based on the given status code
*
* @param int $statusCode
* @return string
*/
protected function selectView(int $statusCode): string
@ -125,8 +119,6 @@ class ErrorHandler implements MiddlewareInterface
/**
* Create a new response
*
* @param string $content
* @param int $status
* @param array $headers
* @return Response
* @codeCoverageIgnore

View File

@ -15,9 +15,6 @@ class ExceptionHandler implements MiddlewareInterface
/** @var ContainerInterface */
protected $container;
/**
* @param ContainerInterface $container
*/
public function __construct(ContainerInterface $container)
{
$this->container = $container;
@ -28,8 +25,6 @@ class ExceptionHandler implements MiddlewareInterface
*
* Should be added at the beginning
*
* @param ServerRequestInterface $request
* @param RequestHandlerInterface $handler
* @return ResponseInterface
*/
public function process(

View File

@ -35,10 +35,6 @@ class LegacyMiddleware implements MiddlewareInterface
/** @var Authenticator */
protected $auth;
/**
* @param ContainerInterface $container
* @param Authenticator $auth
*/
public function __construct(ContainerInterface $container, Authenticator $auth)
{
$this->container = $container;
@ -50,8 +46,6 @@ class LegacyMiddleware implements MiddlewareInterface
*
* Should be used before a 404 is send
*
* @param ServerRequestInterface $request
* @param RequestHandlerInterface $handler
* @return ResponseInterface
*/
public function process(
@ -89,11 +83,10 @@ class LegacyMiddleware implements MiddlewareInterface
/**
* Get the legacy page content and title
*
* @param string $page
* @return array ['title', 'content']
* @codeCoverageIgnore
*/
protected function loadPage($page)
protected function loadPage(string $page)
{
switch ($page) {
case 'ical':
@ -182,13 +175,10 @@ class LegacyMiddleware implements MiddlewareInterface
/**
* Render the template
*
* @param string $page
* @param string $title
* @param string $content
* @return Response
* @codeCoverageIgnore
*/
protected function renderPage($page, $title, $content)
protected function renderPage(string $page, string $title, string $content)
{
if (!empty($page) && is_int($page)) {
return response($content, (int)$page);

Some files were not shown because too many files have changed in this diff Show More