Use native types where possible + ctor prop promotion 💣

This commit is contained in:
Igor Scheller 2022-12-21 12:46:40 +01:00 committed by GitHub
commit 98a3187899
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
438 changed files with 1759 additions and 4885 deletions

10
.git-blame-ignore-revs Normal file
View File

@ -0,0 +1,10 @@
# Set native parameter types
2b88322c0c1dcab3b0dd064ad880b0f31645da49
# Set native return types
aff8826c9941d3f18984dcd4f220dd25ad547f42
# Set native property types
b004f865b42886738d90f9915c1cccfcc3599322
# Use constructor property promotion
984f8038d3ab096b6018a2df084fd158644bc080
# Add useless comment phpcs sniff
c1d350f2b122ff7dff0c3a0ed2b3c0a515c176f6

View File

@ -126,6 +126,9 @@ phpcs:
image: composer:latest
stage: validate
script:
# tell phpcs the PHP version to check against
# we are using the min suppported version here
- ./vendor/bin/phpcs --config-set php_version 80100
- ./vendor/bin/phpcs -p --no-colors --basepath="$PWD"
phpstan:

View File

@ -8,6 +8,7 @@
<file>public/index.php</file>
<file>src</file>
<file>tests</file>
<exclude-pattern>/config/config.php</exclude-pattern>
<rule ref="PSR12" />
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
@ -19,8 +20,23 @@
<properties>
<property name="ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach" value="true" />
</properties>
</rule>
<rule ref="Generic.Files.LineLength.TooLong">
<exclude-pattern>/includes</exclude-pattern>
</rule>
</rule>
<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.TypeHints.ReturnTypeHint">
<exclude-pattern>/includes</exclude-pattern>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification" />
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<exclude-pattern>/includes</exclude-pattern>
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification" />
</rule>
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion" />
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment" />
<rule ref="SlevomatCodingStandard.Commenting.UselessFunctionDocComment" />
</ruleset>

View File

@ -38,6 +38,13 @@ The following instructions explain how to get, build and run the latest Engelsys
find resources/lang/ -type f -name '*.po' -exec sh -c 'file="{}"; msgfmt "${file%.*}.po" -o "${file%.*}.mo"' \;
```
## Git setup (optional, recommended)
Ignore mass-changes like code formatting in Git blame:
```bash
git config blame.ignoreRevsFile .git-blame-ignore-revs
```
## Testing
To run the unit tests use
```bash

View File

@ -14,8 +14,15 @@
}
],
"scripts": {
"phpcs": "phpcs -p --cache",
"phpcbf": "phpcbf -p",
"phpcs:setup": "phpcs --config-set php_version 80100",
"phpcs": [
"composer phpcs:setup",
"phpcs -p --cache"
],
"phpcbf": [
"composer phpcs:setup",
"phpcbf -p"
],
"phpstan": "phpstan"
},
"require": {

View File

@ -17,7 +17,7 @@ $route->get('/logout', 'AuthController@logout');
// OAuth
$route->addGroup(
'/oauth/{provider}',
function (RouteCollector $route) {
function (RouteCollector $route): void {
$route->get('', 'OAuthController@index');
$route->post('/connect', 'OAuthController@connect');
$route->post('/disconnect', 'OAuthController@disconnect');
@ -27,7 +27,7 @@ $route->addGroup(
// User settings
$route->addGroup(
'/settings',
function (RouteCollector $route) {
function (RouteCollector $route): void {
$route->get('/profile', 'SettingsController@profile');
$route->post('/profile', 'SettingsController@saveProfile');
$route->get('/password', 'SettingsController@password');
@ -43,7 +43,7 @@ $route->addGroup(
// Password recovery
$route->addGroup(
'/password/reset',
function (RouteCollector $route) {
function (RouteCollector $route): void {
$route->get('', 'PasswordResetController@reset');
$route->post('', 'PasswordResetController@postReset');
$route->get('/{token:.+}', 'PasswordResetController@resetPassword');
@ -59,7 +59,7 @@ $route->get('/stats', 'Metrics\\Controller@stats');
$route->get('/meetings', 'NewsController@meetings');
$route->addGroup(
'/news',
function (RouteCollector $route) {
function (RouteCollector $route): void {
$route->get('', 'NewsController@index');
$route->get('/{news_id:\d+}', 'NewsController@show');
$route->post('/{news_id:\d+}', 'NewsController@comment');
@ -73,7 +73,7 @@ $route->get('/faq', 'FaqController@index');
// Questions
$route->addGroup(
'/questions',
function (RouteCollector $route) {
function (RouteCollector $route): void {
$route->get('', 'QuestionsController@index');
$route->post('', 'QuestionsController@delete');
$route->get('/new', 'QuestionsController@add');
@ -84,7 +84,7 @@ $route->addGroup(
// Messages
$route->addGroup(
'/messages',
function (RouteCollector $route) {
function (RouteCollector $route): void {
$route->get('', 'MessagesController@index');
$route->post('', 'MessagesController@redirectToConversation');
$route->get('/{user_id:\d+}', 'MessagesController@messagesOfConversation');
@ -102,11 +102,11 @@ $route->get('/design', 'DesignController@index');
// Administration
$route->addGroup(
'/admin',
function (RouteCollector $route) {
function (RouteCollector $route): void {
// FAQ
$route->addGroup(
'/faq',
function (RouteCollector $route) {
function (RouteCollector $route): void {
$route->get('[/{faq_id:\d+}]', 'Admin\\FaqController@edit');
$route->post('[/{faq_id:\d+}]', 'Admin\\FaqController@save');
}
@ -115,7 +115,7 @@ $route->addGroup(
// Log
$route->addGroup(
'/logs',
function (RouteCollector $route) {
function (RouteCollector $route): void {
$route->get('', 'Admin\\LogsController@index');
$route->post('', 'Admin\\LogsController@index');
}
@ -124,7 +124,7 @@ $route->addGroup(
// Schedule
$route->addGroup(
'/schedule',
function (RouteCollector $route) {
function (RouteCollector $route): void {
$route->get('', 'Admin\\Schedule\\ImportSchedule@index');
$route->get('/edit[/{schedule_id:\d+}]', 'Admin\\Schedule\\ImportSchedule@edit');
$route->post('/edit[/{schedule_id:\d+}]', 'Admin\\Schedule\\ImportSchedule@save');
@ -136,7 +136,7 @@ $route->addGroup(
// Questions
$route->addGroup(
'/questions',
function (RouteCollector $route) {
function (RouteCollector $route): void {
$route->get('', 'Admin\\QuestionsController@index');
$route->post('', 'Admin\\QuestionsController@delete');
$route->get('/{question_id:\d+}', 'Admin\\QuestionsController@edit');
@ -147,11 +147,11 @@ $route->addGroup(
// User
$route->addGroup(
'/user/{user_id:\d+}',
function (RouteCollector $route) {
function (RouteCollector $route): void {
// Shirts
$route->addGroup(
'/shirt',
function (RouteCollector $route) {
function (RouteCollector $route): void {
$route->get('', 'Admin\\UserShirtController@editShirt');
$route->post('', 'Admin\\UserShirtController@saveShirt');
}
@ -160,7 +160,7 @@ $route->addGroup(
// Worklogs
$route->addGroup(
'/worklog',
function (RouteCollector $route) {
function (RouteCollector $route): void {
$route->get('[/{worklog_id:\d+}]', 'Admin\\UserWorkLogController@editWorklog');
$route->post('[/{worklog_id:\d+}]', 'Admin\\UserWorkLogController@saveWorklog');
$route->get(
@ -179,7 +179,7 @@ $route->addGroup(
// News
$route->addGroup(
'/news',
function (RouteCollector $route) {
function (RouteCollector $route): void {
$route->get('[/{news_id:\d+}]', 'Admin\\NewsController@edit');
$route->post('[/{news_id:\d+}]', 'Admin\\NewsController@save');
}

View File

@ -8,11 +8,8 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class AngelTypeFactory extends Factory
{
/** @var string */
protected $model = AngelType::class;
protected $model = AngelType::class; // phpcs:ignore
/**
* @return array
*/
public function definition(): array
{
return [

View File

@ -8,12 +8,9 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class FaqFactory extends Factory
{
/** @var string */
protected $model = Faq::class;
protected $model = Faq::class; // phpcs:ignore
/**
* @return array
*/
public function definition()
public function definition(): array
{
return [
'question' => $this->faker->text(100),

View File

@ -8,12 +8,9 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class GroupFactory extends Factory
{
/** @var string */
protected $model = Group::class;
protected $model = Group::class; // phpcs:ignore
/**
* @return array
*/
public function definition()
public function definition(): array
{
return [
'name' => $this->faker->unique()->word(),

View File

@ -9,12 +9,9 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class MessageFactory extends Factory
{
/** @var string */
protected $model = Message::class;
protected $model = Message::class; // phpcs:ignore
/**
* @return array
*/
public function definition()
public function definition(): array
{
return [
'user_id' => User::factory(),

View File

@ -10,12 +10,9 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class NewsCommentFactory extends Factory
{
/** @var string */
protected $model = NewsComment::class;
protected $model = NewsComment::class; // phpcs:ignore
/**
* @return array
*/
public function definition()
public function definition(): array
{
return [
'news_id' => News::factory(),

View File

@ -9,12 +9,9 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class NewsFactory extends Factory
{
/** @var string */
protected $model = News::class;
protected $model = News::class; // phpcs:ignore
/**
* @return array
*/
public function definition()
public function definition(): array
{
return [
'title' => $this->faker->text(50),

View File

@ -8,12 +8,9 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class PrivilegeFactory extends Factory
{
/** @var string */
protected $model = Privilege::class;
protected $model = Privilege::class; // phpcs:ignore
/**
* @return array
*/
public function definition()
public function definition(): array
{
return [
'name' => $this->faker->unique()->word(),

View File

@ -10,12 +10,9 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class QuestionFactory extends Factory
{
/** @var string */
protected $model = Question::class;
protected $model = Question::class; // phpcs:ignore
/**
* @return array
*/
public function definition()
public function definition(): array
{
return [
'user_id' => User::factory(),

View File

@ -8,12 +8,9 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class RoomFactory extends Factory
{
/** @var string */
protected $model = Room::class;
protected $model = Room::class; // phpcs:ignore
/**
* @return array
*/
public function definition()
public function definition(): array
{
return [
'name' => $this->faker->unique()->firstName(),

View File

@ -8,12 +8,9 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class ScheduleFactory extends Factory
{
/** @var string */
protected $model = Schedule::class;
protected $model = Schedule::class; // phpcs:ignore
/**
* @return array
*/
public function definition()
public function definition(): array
{
return [
'name' => $this->faker->unique()->words(4, true),

View File

@ -8,11 +8,8 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class ShiftTypeFactory extends Factory
{
/** @var string */
protected $model = ShiftType::class;
protected $model = ShiftType::class; // phpcs:ignore
/**
* @return array
*/
public function definition(): array
{
return [

View File

@ -8,12 +8,9 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class ContactFactory extends Factory
{
/** @var string */
protected $model = Contact::class;
protected $model = Contact::class; // phpcs:ignore
/**
* @return array
*/
public function definition()
public function definition(): array
{
return [
'dect' => $this->faker->optional()->numberBetween(1000, 9999),

View File

@ -8,12 +8,9 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class LicenseFactory extends Factory
{
/** @var string */
protected $model = License::class;
protected $model = License::class; // phpcs:ignore
/**
* @return array
*/
public function definition()
public function definition(): array
{
$drive_car = $this->faker->boolean(.8);
$drive_3_5t = $drive_car && $this->faker->boolean(.7);

View File

@ -8,12 +8,9 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class PasswordResetFactory extends Factory
{
/** @var string */
protected $model = PasswordReset::class;
protected $model = PasswordReset::class; // phpcs:ignore
/**
* @return array
*/
public function definition()
public function definition(): array
{
return [
'token' => bin2hex(random_bytes(16)),

View File

@ -9,12 +9,9 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class PersonalDataFactory extends Factory
{
/** @var string */
protected $model = PersonalData::class;
protected $model = PersonalData::class; // phpcs:ignore
/**
* @return array
*/
public function definition()
public function definition(): array
{
$arrival = $this->faker->optional()->dateTimeThisMonth('2 weeks');
$departure = $this->faker->optional()->dateTimeThisMonth('2 weeks');

View File

@ -8,12 +8,9 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class SettingsFactory extends Factory
{
/** @var string */
protected $model = Settings::class;
protected $model = Settings::class; // phpcs:ignore
/**
* @return array
*/
public function definition()
public function definition(): array
{
return [
'language' => $this->faker->locale(),

View File

@ -9,12 +9,9 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class StateFactory extends Factory
{
/** @var string */
protected $model = State::class;
protected $model = State::class; // phpcs:ignore
/**
* @return array
*/
public function definition()
public function definition(): array
{
$arrival = $this->faker->optional()->dateTimeThisMonth();
@ -30,10 +27,8 @@ class StateFactory extends Factory
/**
* Indicate that the user is arrived
*
* @return self
*/
public function arrived()
public function arrived(): self
{
return $this->state(
function (array $attributes) {

View File

@ -8,12 +8,9 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class UserFactory extends Factory
{
/** @var string */
protected $model = User::class;
protected $model = User::class; // phpcs:ignore
/**
* @return array
*/
public function definition()
public function definition(): array
{
return [
'name' => $this->faker->unique()->userName(),

View File

@ -10,11 +10,8 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class UserAngelTypeFactory extends Factory
{
/** @var string */
protected $model = UserAngelType::class;
protected $model = UserAngelType::class; // phpcs:ignore
/**
* @return array
*/
public function definition(): array
{
return [

View File

@ -9,12 +9,9 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class WorklogFactory extends Factory
{
/** @var string */
protected $model = Worklog::class;
protected $model = Worklog::class; // phpcs:ignore
/**
* @return array
*/
public function definition()
public function definition(): array
{
return [
'user_id' => User::factory(),

View File

@ -6,7 +6,8 @@ use Engelsystem\Database\Migration\Migration;
class ImportInstallSql extends Migration
{
protected $oldTables = [
/** @var array<string> */
protected array $oldTables = [
'AngelTypes',
'EventConfig',
'GroupPrivileges',
@ -31,7 +32,7 @@ class ImportInstallSql extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
foreach ($this->oldTables as $table) {
if ($this->schema->hasTable($table)) {
@ -47,7 +48,7 @@ class ImportInstallSql extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$this->schema->getConnection()->statement('SET FOREIGN_KEY_CHECKS=0;');

View File

@ -9,7 +9,7 @@ class ImportUpdateSql extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
if ($this->schema->hasTable('UserWorkLog')) {
return;
@ -22,7 +22,7 @@ class ImportUpdateSql extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$this->schema->dropIfExists('UserWorkLog');
}

View File

@ -10,7 +10,7 @@ class FixOldTables extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$connection = $this->schema->getConnection();
@ -29,7 +29,7 @@ class FixOldTables extends Migration
->where($column, '<', '0001-01-01 00:00:00')
->update([$column => '0001-01-01 00:00:00']);
$this->schema->table($table, function (Blueprint $table) use ($column) {
$this->schema->table($table, function (Blueprint $table) use ($column): void {
$table->dateTime($column)->default('0001-01-01 00:00:00')->change();
});
}
@ -38,7 +38,7 @@ class FixOldTables extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
}
}

View File

@ -9,7 +9,7 @@ class CleanupGroupPrivileges extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
if (!$this->schema->hasTable('GroupPrivileges')) {
return;
@ -43,7 +43,7 @@ class CleanupGroupPrivileges extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
if (!$this->schema->hasTable('GroupPrivileges')) {
return;

View File

@ -7,7 +7,7 @@ use Engelsystem\Database\Migration\Migration;
class AddAngelSupporterPermissions extends Migration
{
/** @var string[] */
protected $data = [
protected array $data = [
'2-Engel',
'shiftentry_edit_angeltype_supporter',
];
@ -15,7 +15,7 @@ class AddAngelSupporterPermissions extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
if (!$this->schema->hasTable('GroupPrivileges')) {
return;
@ -39,7 +39,7 @@ class AddAngelSupporterPermissions extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
if (!$this->schema->hasTable('GroupPrivileges')) {
return;
@ -52,11 +52,7 @@ class AddAngelSupporterPermissions extends Migration
);
}
/**
* @param string $type
* @return string
*/
protected function getQuery($type)
protected function getQuery(string $type): string
{
return sprintf('
%s FROM GroupPrivileges

View File

@ -10,9 +10,9 @@ class CreateLogEntriesTable extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$this->schema->create('log_entries', function (Blueprint $table) {
$this->schema->create('log_entries', function (Blueprint $table): void {
$table->increments('id');
$table->string('level', 20);
$table->text('message');
@ -32,9 +32,9 @@ class CreateLogEntriesTable extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$this->schema->create('LogEntries', function (Blueprint $table) {
$this->schema->create('LogEntries', function (Blueprint $table): void {
$table->increments('id');
$table->string('level', 20);
$table->text('message');

View File

@ -10,9 +10,9 @@ class CreateSessionsTable extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$this->schema->create('sessions', function (Blueprint $table) {
$this->schema->create('sessions', function (Blueprint $table): void {
$table->string('id')->unique();
$table->text('payload');
$table->dateTime('last_activity')->useCurrent();
@ -22,7 +22,7 @@ class CreateSessionsTable extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$this->schema->dropIfExists('sessions');
}

View File

@ -20,11 +20,11 @@ class CreateEventConfigTable extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
foreach (['json', 'text'] as $type) {
try {
$this->schema->create('event_config', function (Blueprint $table) use ($type) {
$this->schema->create('event_config', function (Blueprint $table) use ($type): void {
$table->string('name')->index()->unique();
$table->{$type}('value');
$table->timestamps();
@ -69,11 +69,11 @@ class CreateEventConfigTable extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$connection = $this->schema->getConnection();
$this->schema->create('EventConfig', function (Blueprint $table) {
$this->schema->create('EventConfig', function (Blueprint $table): void {
$table->string('event_name')->nullable();
$table->integer('buildup_start_date')->nullable();
$table->integer('event_start_date')->nullable();
@ -112,12 +112,7 @@ class CreateEventConfigTable extends Migration
$this->schema->dropIfExists('event_config');
}
/**
* @param Collection $config
* @param string $name
* @return mixed|null
*/
protected function getConfigValue(Collection $config, string $name)
protected function getConfigValue(Collection $config, string $name): mixed
{
$value = $config->where('name', $name)->first('value', (object)['value' => null])->value;

View File

@ -15,9 +15,9 @@ class CreateUsersTables extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$this->schema->create('users', function (Blueprint $table) {
$this->schema->create('users', function (Blueprint $table): void {
$table->increments('id');
$table->string('name', 24)->unique();
@ -29,7 +29,7 @@ class CreateUsersTables extends Migration
$table->timestamps();
});
$this->schema->create('users_personal_data', function (Blueprint $table) {
$this->schema->create('users_personal_data', function (Blueprint $table): void {
$this->referencesUser($table, true);
$table->string('first_name', 64)->nullable();
@ -40,7 +40,7 @@ class CreateUsersTables extends Migration
$table->date('planned_departure_date')->nullable();
});
$this->schema->create('users_contact', function (Blueprint $table) {
$this->schema->create('users_contact', function (Blueprint $table): void {
$this->referencesUser($table, true);
$table->string('dect', 5)->nullable();
@ -48,7 +48,7 @@ class CreateUsersTables extends Migration
$table->string('email', 254)->nullable();
});
$this->schema->create('users_settings', function (Blueprint $table) {
$this->schema->create('users_settings', function (Blueprint $table): void {
$this->referencesUser($table, true);
$table->string('language', 64);
@ -57,7 +57,7 @@ class CreateUsersTables extends Migration
$table->boolean('email_shiftinfo')->default(false);
});
$this->schema->create('users_state', function (Blueprint $table) {
$this->schema->create('users_state', function (Blueprint $table): void {
$this->referencesUser($table, true);
$table->boolean('arrived')->default(false);
@ -68,7 +68,7 @@ class CreateUsersTables extends Migration
$table->integer('got_voucher')->default(0);
});
$this->schema->create('password_resets', function (Blueprint $table) {
$this->schema->create('password_resets', function (Blueprint $table): void {
$this->referencesUser($table, true);
$table->text('token');
@ -155,11 +155,11 @@ class CreateUsersTables extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$connection = $this->schema->getConnection();
$this->schema->create('User', function (Blueprint $table) {
$this->schema->create('User', function (Blueprint $table): void {
$table->integer('UID', true);
$table->string('Nick', 23)->unique()->default('');

View File

@ -8,7 +8,7 @@ use Illuminate\Database\Schema\Blueprint;
class ChangeUsersContactDectFieldSize extends Migration
{
/** @var array */
protected $tables = [
protected array $tables = [
'AngelTypes' => 'contact_dect',
'users_contact' => 'dect',
];
@ -16,7 +16,7 @@ class ChangeUsersContactDectFieldSize extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$this->changeDectTo(40);
}
@ -24,22 +24,19 @@ class ChangeUsersContactDectFieldSize extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$this->changeDectTo(5);
}
/**
* @param int $length
*/
protected function changeDectTo(int $length)
protected function changeDectTo(int $length): void
{
foreach ($this->tables as $table => $column) {
if (!$this->schema->hasTable($table)) {
continue;
}
$this->schema->table($table, function (Blueprint $table) use ($column, $length) {
$this->schema->table($table, function (Blueprint $table) use ($column, $length): void {
$table->string($column, $length)->change();
});
}

View File

@ -10,7 +10,7 @@ class FixMissingArrivalDates extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$connection = $this->schema->getConnection();
@ -36,7 +36,7 @@ class FixMissingArrivalDates extends Migration
/**
* Down is not possible and not needed since this is a bugfix.
*/
public function down()
public function down(): void
{
}
}

View File

@ -9,7 +9,7 @@ class FixUserLanguages extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$connection = $this->schema->getConnection();
$connection
@ -22,7 +22,7 @@ class FixUserLanguages extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$connection = $this->schema->getConnection();
$connection

View File

@ -9,7 +9,7 @@ class MigrateAdminSchedulePermissions extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
if (!$this->schema->hasTable('Privileges')) {
return;
@ -29,7 +29,7 @@ class MigrateAdminSchedulePermissions extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
if (!$this->schema->hasTable('Privileges')) {
return;

View File

@ -12,11 +12,11 @@ class CreateScheduleShiftTable extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$this->schema->create(
'schedules',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->increments('id');
$table->string('url');
}
@ -24,7 +24,7 @@ class CreateScheduleShiftTable extends Migration
$this->schema->create(
'schedule_shift',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->integer('shift_id')->index()->unique();
if ($this->schema->hasTable('Shifts')) {
// Legacy table access
@ -42,7 +42,7 @@ class CreateScheduleShiftTable extends Migration
if ($this->schema->hasTable('Shifts')) {
$this->schema->table(
'Shifts',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->dropColumn('PSID');
}
);
@ -51,7 +51,7 @@ class CreateScheduleShiftTable extends Migration
if ($this->schema->hasTable('Room')) {
$this->schema->table(
'Room',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->dropColumn('from_frab');
}
);
@ -61,12 +61,12 @@ class CreateScheduleShiftTable extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
if ($this->schema->hasTable('Room')) {
$this->schema->table(
'Room',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->boolean('from_frab')
->default(false);
}
@ -76,7 +76,7 @@ class CreateScheduleShiftTable extends Migration
if ($this->schema->hasTable('Shifts')) {
$this->schema->table(
'Shifts',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->integer('PSID')
->nullable()->default(null)
->unique();

View File

@ -64,12 +64,9 @@ class CreateNewsTable extends Migration
$this->schema->drop('new_news');
}
/**
* @return void
*/
private function createNewNewsTable(): void
{
$this->schema->create('news', function (Blueprint $table) {
$this->schema->create('news', function (Blueprint $table): void {
$table->increments('id');
$table->string('title', 150);
$table->text('text');
@ -79,9 +76,6 @@ class CreateNewsTable extends Migration
});
}
/**
* @return void
*/
private function copyPreviousToNewNewsTable(): void
{
$connection = $this->schema->getConnection();
@ -104,12 +98,9 @@ class CreateNewsTable extends Migration
}
}
/**
* @return void
*/
private function createPreviousNewsTable(): void
{
$this->schema->create('News', function (Blueprint $table) {
$this->schema->create('News', function (Blueprint $table): void {
$table->increments('ID');
$table->integer('Datum');
$table->string('Betreff', 150)
@ -120,9 +111,6 @@ class CreateNewsTable extends Migration
});
}
/**
* @return void
*/
private function copyNewToPreviousNewsTable(): void
{
$connection = $this->schema->getConnection();

View File

@ -53,12 +53,9 @@ class CreateNewsCommentsTable extends Migration
$this->schema->drop('news_comments');
}
/**
* @return void
*/
private function createNewNewsCommentsTable(): void
{
$this->schema->create('news_comments', function (Blueprint $table) {
$this->schema->create('news_comments', function (Blueprint $table): void {
$table->increments('id');
$this->references($table, 'news', 'news_id');
$table->text('text');
@ -67,9 +64,6 @@ class CreateNewsCommentsTable extends Migration
});
}
/**
* @return void
*/
private function copyPreviousToNewNewsCommentsTable(): void
{
$connection = $this->schema->getConnection();
@ -90,12 +84,9 @@ class CreateNewsCommentsTable extends Migration
}
}
/**
* @return void
*/
private function createPreviousNewsCommentsTable(): void
{
$this->schema->create('NewsComments', function (Blueprint $table) {
$this->schema->create('NewsComments', function (Blueprint $table): void {
$table->increments('ID');
$this->references($table, 'news', 'Refid');
$table->dateTime('Datum');
@ -104,9 +95,6 @@ class CreateNewsCommentsTable extends Migration
});
}
/**
* @return void
*/
private function copyNewToPreviousNewsCommentsTable(): void
{
$connection = $this->schema->getConnection();

View File

@ -64,14 +64,11 @@ class CreateMessagesTable extends Migration
$this->schema->drop('new_messages');
}
/**
* @return void
*/
private function createNewMessagesTable(): void
{
$this->schema->create(
'messages',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->increments('id');
$this->referencesUser($table);
$this->references($table, 'users', 'receiver_id');
@ -82,9 +79,6 @@ class CreateMessagesTable extends Migration
);
}
/**
* @return void
*/
private function copyPreviousToNewMessagesTable(): void
{
$connection = $this->schema->getConnection();
@ -109,14 +103,11 @@ class CreateMessagesTable extends Migration
}
}
/**
* @return void
*/
private function createPreviousMessagesTable(): void
{
$this->schema->create(
'Messages',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->increments('id');
$table->integer('Datum');
$this->references($table, 'users', 'SUID');
@ -128,9 +119,6 @@ class CreateMessagesTable extends Migration
);
}
/**
* @return void
*/
private function copyNewToPreviousMessagesTable(): void
{
$connection = $this->schema->getConnection();

View File

@ -17,9 +17,6 @@ class CreateQuestionsTable extends Migration
use ChangesReferences;
use Reference;
/**
* @return void
*/
public function up(): void
{
$hasPreviousQuestionsTable = $this->schema->hasTable('Questions');
@ -43,9 +40,6 @@ class CreateQuestionsTable extends Migration
}
}
/**
* @return void
*/
public function down(): void
{
// Rename as some SQL DBMS handle identifiers case insensitive
@ -63,14 +57,11 @@ class CreateQuestionsTable extends Migration
$this->schema->drop('new_questions');
}
/**
* @return void
*/
private function createNewQuestionsTable(): void
{
$this->schema->create(
'questions',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->increments('id');
$this->referencesUser($table);
$table->text('text');
@ -82,9 +73,6 @@ class CreateQuestionsTable extends Migration
);
}
/**
* @return void
*/
private function copyPreviousToNewQuestionsTable(): void
{
$connection = $this->schema->getConnection();
@ -104,14 +92,11 @@ class CreateQuestionsTable extends Migration
}
}
/**
* @return void
*/
private function createPreviousQuestionsTable(): void
{
$this->schema->create(
'Questions',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->increments('QID');
$this->references($table, 'users', 'UID');
$table->text('Question');
@ -123,9 +108,6 @@ class CreateQuestionsTable extends Migration
);
}
/**
* @return void
*/
private function copyNewToPreviousQuestionsTable(): void
{
$connection = $this->schema->getConnection();

View File

@ -14,7 +14,7 @@ class UserPersonalDataAddPronounField extends Migration
*/
public function up(): void
{
$this->schema->table('users_personal_data', function (Blueprint $table) {
$this->schema->table('users_personal_data', function (Blueprint $table): void {
$table->string('pronoun', 15)
->nullable()
->default(null)
@ -27,7 +27,7 @@ class UserPersonalDataAddPronounField extends Migration
*/
public function down(): void
{
$this->schema->table('users_personal_data', function (Blueprint $table) {
$this->schema->table('users_personal_data', function (Blueprint $table): void {
$table->dropColumn('pronoun');
});
}

View File

@ -18,7 +18,7 @@ class CreateRoomsTable extends Migration
*/
public function up(): void
{
$this->schema->create('rooms', function (Blueprint $table) {
$this->schema->create('rooms', function (Blueprint $table): void {
$table->increments('id');
$table->string('name', 35)->unique();
$table->string('map_url', 300)->nullable();
@ -61,7 +61,7 @@ class CreateRoomsTable extends Migration
{
$connection = $this->schema->getConnection();
$this->schema->create('Room', function (Blueprint $table) {
$this->schema->create('Room', function (Blueprint $table): void {
$table->increments('RID');
$table->string('Name', 35)->unique();
$table->string('map_url', 300)->nullable();

View File

@ -19,7 +19,7 @@ class CreateWorklogsTable extends Migration
*/
public function up(): void
{
$this->schema->create('worklogs', function (Blueprint $table) {
$this->schema->create('worklogs', function (Blueprint $table): void {
$table->increments('id');
$this->referencesUser($table);
$this->references($table, 'users', 'creator_id');
@ -70,7 +70,7 @@ class CreateWorklogsTable extends Migration
{
$connection = $this->schema->getConnection();
$this->schema->create('UserWorkLog', function (Blueprint $table) {
$this->schema->create('UserWorkLog', function (Blueprint $table): void {
$table->increments('id');
$this->referencesUser($table);
$table->integer('work_timestamp');

View File

@ -9,7 +9,7 @@ class CreateWelcomeAngelPermissionsGroup extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
if (!$this->schema->hasTable('Groups')) {
return;
@ -38,7 +38,7 @@ class CreateWelcomeAngelPermissionsGroup extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
if (!$this->schema->hasTable('Groups')) {
return;

View File

@ -18,7 +18,7 @@ class AddTimestampsToQuestions extends Migration
$connection = $this->schema->getConnection();
$now = Carbon::now();
$this->schema->table('questions', function (Blueprint $table) {
$this->schema->table('questions', function (Blueprint $table): void {
$table->timestamp('answered_at')->after('answerer_id')->nullable();
$table->timestamps();
});
@ -40,7 +40,7 @@ class AddTimestampsToQuestions extends Migration
*/
public function down(): void
{
$this->schema->table('questions', function (Blueprint $table) {
$this->schema->table('questions', function (Blueprint $table): void {
$table->dropColumn('answered_at');
$table->dropTimestamps();
});

View File

@ -10,9 +10,9 @@ class CreateFaqTableAndPermissions extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$this->schema->create('faq', function (Blueprint $table) {
$this->schema->create('faq', function (Blueprint $table): void {
$table->increments('id');
$table->string('question');
$table->text('text');
@ -46,7 +46,7 @@ class CreateFaqTableAndPermissions extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$this->schema->drop('faq');

View File

@ -9,7 +9,7 @@ class CreateQuestionsPermissions extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
if ($this->schema->hasTable('Privileges')) {
$db = $this->schema->getConnection();
@ -36,7 +36,7 @@ class CreateQuestionsPermissions extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
if (!$this->schema->hasTable('Privileges')) {
return;

View File

@ -16,7 +16,7 @@ class CreateOauthTable extends Migration
*/
public function up(): void
{
$this->schema->create('oauth', function (Blueprint $table) {
$this->schema->create('oauth', function (Blueprint $table): void {
$table->increments('id');
$this->referencesUser($table);
$table->string('provider');

View File

@ -13,13 +13,13 @@ class AddNameMinutesAndTimestampsToSchedules extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$connection = $this->schema->getConnection();
$this->schema->table(
'schedules',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->string('name')->default('')->after('id');
$table->integer('shift_type')->default(0)->after('name');
$table->integer('minutes_before')->default(0)->after('shift_type');
@ -37,7 +37,7 @@ class AddNameMinutesAndTimestampsToSchedules extends Migration
$this->schema->table(
'schedules',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->string('name')->default(null)->change();
$table->integer('shift_type')->default(null)->change();
$table->integer('minutes_before')->default(null)->change();
@ -61,7 +61,7 @@ class AddNameMinutesAndTimestampsToSchedules extends Migration
$this->schema->table(
'schedules',
function (Blueprint $table) {
function (Blueprint $table): void {
$this->addReference($table, 'shift_type', 'ShiftTypes');
}
);
@ -71,11 +71,11 @@ class AddNameMinutesAndTimestampsToSchedules extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$this->schema->table(
'schedules',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->dropForeign('schedules_shift_type_foreign');
$table->dropColumn('name');
$table->dropColumn('shift_type');

View File

@ -12,11 +12,11 @@ class AddEmailNewsToUsersSettings extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$this->schema->table(
'users_settings',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->boolean('email_news')->default(false)->after('email_shiftinfo');
}
);
@ -25,11 +25,11 @@ class AddEmailNewsToUsersSettings extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$this->schema->table(
'users_settings',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->dropColumn('email_news');
}
);

View File

@ -12,11 +12,11 @@ class OauthAddTokens extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$this->schema->table(
'oauth',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->string('access_token')->nullable()->default(null)->after('identifier');
$table->string('refresh_token')->nullable()->default(null)->after('access_token');
$table->dateTime('expires_at')->nullable()->default(null)->after('refresh_token');
@ -27,11 +27,11 @@ class OauthAddTokens extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$this->schema->table(
'oauth',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->dropColumn('access_token');
$table->dropColumn('refresh_token');
$table->dropColumn('expires_at');

View File

@ -12,11 +12,11 @@ class NewsAddIsPinned extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$this->schema->table(
'news',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->boolean('is_pinned')->default(false)->after('is_meeting');
}
);
@ -25,11 +25,11 @@ class NewsAddIsPinned extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$this->schema->table(
'news',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->dropColumn('is_pinned');
}
);

View File

@ -12,11 +12,11 @@ class OauthChangeTokensToText extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$this->schema->table(
'oauth',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->text('access_token')->change();
$table->text('refresh_token')->change();
}
@ -26,11 +26,11 @@ class OauthChangeTokensToText extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$this->schema->table(
'oauth',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->string('access_token')->change();
$table->string('refresh_token')->change();
}

View File

@ -11,29 +11,15 @@ class SetAdminPassword extends Migration
{
use Reference;
/** @var Authenticator */
protected Authenticator $auth;
/** @var Config */
protected Config $config;
/**
* @param SchemaBuilder $schemaBuilder
* @param Authenticator $auth
* @param Config $config
*/
public function __construct(SchemaBuilder $schemaBuilder, Authenticator $auth, Config $config)
public function __construct(SchemaBuilder $schemaBuilder, protected Authenticator $auth, protected Config $config)
{
parent::__construct($schemaBuilder);
$this->auth = $auth;
$this->config = $config;
}
/**
* Run the migration
*/
public function up()
public function up(): void
{
$admin = $this->auth->authenticate('admin', 'asdfasdf');
$setupPassword = $this->config->get('setup_admin_password');

View File

@ -9,7 +9,7 @@ class AddShirtEditPermissions extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
if (!$this->schema->hasTable('GroupPrivileges')) {
return;
@ -40,7 +40,7 @@ class AddShirtEditPermissions extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
if (!$this->schema->hasTable('GroupPrivileges')) {
return;

View File

@ -12,7 +12,7 @@ class AddShiftsDescription extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
if (!$this->schema->hasTable('Shifts')) {
return;
@ -20,7 +20,7 @@ class AddShiftsDescription extends Migration
$this->schema->table(
'Shifts',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->text('description')->nullable()->after('shifttype_id');
}
);
@ -29,7 +29,7 @@ class AddShiftsDescription extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
if (!$this->schema->hasTable('Shifts')) {
return;
@ -37,7 +37,7 @@ class AddShiftsDescription extends Migration
$this->schema->table(
'Shifts',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->dropColumn('description');
}
);

View File

@ -16,7 +16,7 @@ class CreateUserLicensesTable extends Migration
*/
public function up(): void
{
$this->schema->create('users_licenses', function (Blueprint $table) {
$this->schema->create('users_licenses', function (Blueprint $table): void {
$this->referencesUser($table, true);
$table->boolean('has_car')->default(false);
$table->boolean('drive_forklift')->default(false);
@ -54,7 +54,7 @@ class CreateUserLicensesTable extends Migration
*/
public function down(): void
{
$this->schema->create('UserDriverLicenses', function (Blueprint $table) {
$this->schema->create('UserDriverLicenses', function (Blueprint $table): void {
$this->referencesUser($table, true);
$table->boolean('has_car');
$table->boolean('has_license_car');

View File

@ -10,9 +10,9 @@ class IncreaseSessionsTablePayloadSize extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$this->schema->table('sessions', function (Blueprint $table) {
$this->schema->table('sessions', function (Blueprint $table): void {
$table->mediumText('payload')->change();
});
}
@ -20,9 +20,9 @@ class IncreaseSessionsTablePayloadSize extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$this->schema->table('sessions', function (Blueprint $table) {
$this->schema->table('sessions', function (Blueprint $table): void {
$table->text('payload')->change();
});
}

View File

@ -12,13 +12,13 @@ class UsersSettingsAddEmailGoody extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$connection = $this->schema->getConnection();
$this->schema->table(
'users_settings',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->boolean('email_goody')->default(false)->after('email_human');
}
);
@ -31,11 +31,11 @@ class UsersSettingsAddEmailGoody extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$this->schema->table(
'users_settings',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->dropColumn('email_goody');
}
);

View File

@ -9,7 +9,7 @@ class RemoveAdminNewsHtmlPrivilege extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
if (!$this->schema->hasTable('GroupPrivileges')) {
return;
@ -27,7 +27,7 @@ class RemoveAdminNewsHtmlPrivilege extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
if (!$this->schema->hasTable('GroupPrivileges')) {
return;

View File

@ -13,9 +13,9 @@ class IncreaseTshirtFieldWidth extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$this->schema->table('users_personal_data', function (Blueprint $table) {
$this->schema->table('users_personal_data', function (Blueprint $table): void {
$table->string('shirt_size', 10)->change();
});
}
@ -23,9 +23,9 @@ class IncreaseTshirtFieldWidth extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$this->schema->table('users_personal_data', function (Blueprint $table) {
$this->schema->table('users_personal_data', function (Blueprint $table): void {
$table->string('shirt_size', 4)->change();
});
}

View File

@ -9,7 +9,7 @@ class CreateVoucherEditPermission extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
if (!$this->schema->hasTable('Privileges')) {
return;
@ -36,7 +36,7 @@ class CreateVoucherEditPermission extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
if (!$this->schema->hasTable('Privileges')) {
return;

View File

@ -18,7 +18,7 @@ class ShiftsAddTransactionId extends Migration
return;
}
$this->schema->table('Shifts', function (Blueprint $table) {
$this->schema->table('Shifts', function (Blueprint $table): void {
$table->uuid('transaction_id')->index()->nullable()->default(null);
});
}
@ -32,7 +32,7 @@ class ShiftsAddTransactionId extends Migration
return;
}
$this->schema->table('Shifts', function (Blueprint $table) {
$this->schema->table('Shifts', function (Blueprint $table): void {
$table->dropColumn('transaction_id');
});
}

View File

@ -32,7 +32,7 @@ class FixOldGroupsTableIdAndName extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$this->migrate($this->naming, $this->ids);
}
@ -40,7 +40,7 @@ class FixOldGroupsTableIdAndName extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$this->migrate(array_flip($this->naming), array_flip($this->ids));
}
@ -49,7 +49,7 @@ class FixOldGroupsTableIdAndName extends Migration
* @param string[] $naming
* @param int[] $ids
*/
protected function migrate(array $naming, array $ids)
protected function migrate(array $naming, array $ids): void
{
if (!$this->schema->hasTable('Groups')) {
return;

View File

@ -10,11 +10,11 @@ class AddMobileShowToUsersSettings extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$this->schema->table(
'users_settings',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->boolean('mobile_show')->default(false)->after('email_news');
}
);
@ -23,11 +23,11 @@ class AddMobileShowToUsersSettings extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$this->schema->table(
'users_settings',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->dropColumn('mobile_show');
}
);

View File

@ -10,11 +10,11 @@ class AddDectToRooms extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$this->schema->table(
'rooms',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->text('dect')->nullable()->after('description');
}
);
@ -23,11 +23,11 @@ class AddDectToRooms extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$this->schema->table(
'rooms',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->dropColumn('dect');
}
);

View File

@ -10,7 +10,7 @@ class AddHideRegisterToAngeltypes extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
if (!$this->schema->hasTable('AngelTypes')) {
return;
@ -18,7 +18,7 @@ class AddHideRegisterToAngeltypes extends Migration
$this->schema->table(
'AngelTypes',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->boolean('hide_register')->default(false)->after('show_on_dashboard');
}
);
@ -27,7 +27,7 @@ class AddHideRegisterToAngeltypes extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
if (!$this->schema->hasTable('AngelTypes')) {
return;
@ -35,7 +35,7 @@ class AddHideRegisterToAngeltypes extends Migration
$this->schema->table(
'AngelTypes',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->dropColumn('hide_register');
}
);

View File

@ -108,59 +108,53 @@ class CreatePrivilegesAndGroupsRelatedTables extends Migration
$this->schema->drop('privileges_new');
}
/**
* @return void
*/
protected function createNew(): void
{
$this->schema->create('groups', function (Blueprint $table) {
$this->schema->create('groups', function (Blueprint $table): void {
$table->increments('id');
$table->string('name', 35)->unique();
});
$this->schema->create('privileges', function (Blueprint $table) {
$this->schema->create('privileges', function (Blueprint $table): void {
$table->increments('id');
$table->string('name', 128)->unique();
$table->string('description', 1024);
});
$this->schema->create('users_groups', function (Blueprint $table) {
$this->schema->create('users_groups', function (Blueprint $table): void {
$table->increments('id');
$this->referencesUser($table)->index();
$this->references($table, 'groups')->index();
});
$this->schema->create('group_privileges', function (Blueprint $table) {
$this->schema->create('group_privileges', function (Blueprint $table): void {
$table->increments('id');
$this->references($table, 'groups')->index();
$this->references($table, 'privileges')->index();
});
}
/**
* @return void
*/
protected function createOldTable(): void
{
$this->schema->create('Groups', function (Blueprint $table) {
$this->schema->create('Groups', function (Blueprint $table): void {
$table->string('Name', 35);
$table->integer('UID')->primary();
});
$this->schema->create('Privileges', function (Blueprint $table) {
$this->schema->create('Privileges', function (Blueprint $table): void {
$table->increments('id');
$table->string('name', 128)->unique();
$table->string('desc', 1024);
});
$this->schema->create('UserGroups', function (Blueprint $table) {
$this->schema->create('UserGroups', function (Blueprint $table): void {
$table->increments('id');
$this->references($table, 'users', 'uid');
$this->references($table, 'Groups', 'group_id', 'UID', false, 'integer')->index();
$table->index(['uid', 'group_id']);
});
$this->schema->create('GroupPrivileges', function (Blueprint $table) {
$this->schema->create('GroupPrivileges', function (Blueprint $table): void {
$table->increments('id');
$this->references($table, 'Groups', 'group_id', 'UID', false, 'integer');
$this->references($table, 'Privileges', 'privilege_id')->index();
@ -168,9 +162,6 @@ class CreatePrivilegesAndGroupsRelatedTables extends Migration
});
}
/**
* @return void
*/
protected function copyOldToNew(): void
{
$connection = $this->schema->getConnection();
@ -220,9 +211,6 @@ class CreatePrivilegesAndGroupsRelatedTables extends Migration
}
}
/**
* @return void
*/
protected function copyNewToOld(): void
{
$connection = $this->schema->getConnection();

View File

@ -20,7 +20,7 @@ class ShifttypeRemoveAngeltype extends Migration
$this->schema->table(
'ShiftTypes',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->dropForeign('shifttypes_ibfk_1');
$table->dropColumn('angeltype_id');
}
@ -38,7 +38,7 @@ class ShifttypeRemoveAngeltype extends Migration
$this->schema->table(
'ShiftTypes',
function (Blueprint $table) {
function (Blueprint $table): void {
$table->integer('angeltype_id')
->after('name')
->index()

View File

@ -18,7 +18,7 @@ class CreateShiftTypesTable extends Migration
public function up(): void
{
$connection = $this->schema->getConnection();
$this->schema->create('shift_types', function (Blueprint $table) {
$this->schema->create('shift_types', function (Blueprint $table): void {
$table->increments('id');
$table->string('name')->unique();
$table->text('description');
@ -56,7 +56,7 @@ class CreateShiftTypesTable extends Migration
public function down(): void
{
$connection = $this->schema->getConnection();
$this->schema->create('ShiftTypes', function (Blueprint $table) {
$this->schema->create('ShiftTypes', function (Blueprint $table): void {
$table->increments('id');
$table->string('name', 255);
$table->mediumText('description');

View File

@ -19,7 +19,7 @@ class CreateAngelTypesTable extends Migration
public function up(): void
{
$connection = $this->schema->getConnection();
$this->schema->create('angel_types', function (Blueprint $table) {
$this->schema->create('angel_types', function (Blueprint $table): void {
$table->increments('id');
$table->string('name')->unique();
$table->text('description')->default('');
@ -77,7 +77,7 @@ class CreateAngelTypesTable extends Migration
public function down(): void
{
$connection = $this->schema->getConnection();
$this->schema->create('AngelTypes', function (Blueprint $table) {
$this->schema->create('AngelTypes', function (Blueprint $table): void {
$table->integer('id', true);
$table->string('name', 50)->default('')->unique();
$table->boolean('restricted');

View File

@ -20,7 +20,7 @@ class CreateUserAngelTypesTable extends Migration
{
$connection = $this->schema->getConnection();
$this->schema->create('user_angel_type', function (Blueprint $table) {
$this->schema->create('user_angel_type', function (Blueprint $table): void {
$table->increments('id');
$this->referencesUser($table);
$this->references($table, 'angel_types')->index();
@ -65,7 +65,7 @@ class CreateUserAngelTypesTable extends Migration
{
$connection = $this->schema->getConnection();
$this->schema->create('UserAngelTypes', function (Blueprint $table) {
$this->schema->create('UserAngelTypes', function (Blueprint $table): void {
$table->increments('id');
$this->referencesUser($table);
$this->references($table, 'angel_types', 'angeltype_id')->index('angeltype_id');

View File

@ -12,9 +12,9 @@ class ChangeApiKeyLength extends Migration
/**
* Run the migration
*/
public function up()
public function up(): void
{
$this->schema->table('users', function (Blueprint $table) {
$this->schema->table('users', function (Blueprint $table): void {
$table->string('api_key', 64)->change();
});
}
@ -22,9 +22,9 @@ class ChangeApiKeyLength extends Migration
/**
* Reverse the migration
*/
public function down()
public function down(): void
{
$this->schema->table('users', function (Blueprint $table) {
$this->schema->table('users', function (Blueprint $table): void {
$table->string('api_key', 32)->change();
});
}

View File

@ -7,31 +7,24 @@ 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,
string $targetTable,
string $targetColumn,
string $type = 'unsignedInteger'
) {
): void {
$references = $this->getReferencingTables($fromTable, $fromColumn);
foreach ($references as $reference) {
/** @var stdClass $reference */
$this->schema->table($reference->table, function (Blueprint $table) use ($reference) {
$this->schema->table($reference->table, function (Blueprint $table) use ($reference): void {
$table->dropForeign($reference->constraint);
});
$this->schema->table(
$reference->table,
function (Blueprint $table) use ($reference, $targetTable, $targetColumn, $type) {
function (Blueprint $table) use ($reference, $targetTable, $targetColumn, $type): void {
$table->{$type}($reference->column)->change();
$table->foreign($reference->column)
@ -43,12 +36,6 @@ trait ChangesReferences
}
}
/**
* @param string $table
* @param string $column
*
* @return array
*/
protected function getReferencingTables(string $table, string $column): array
{
return $this->schema

View File

@ -8,25 +8,11 @@ use Illuminate\Support\Str;
trait Reference
{
/**
* @param Blueprint $table
* @param bool $setPrimary
* @return ColumnDefinition
*/
protected function referencesUser(Blueprint $table, bool $setPrimary = false): ColumnDefinition
{
return $this->references($table, 'users', null, null, $setPrimary);
}
/**
* @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(
Blueprint $table,
string $targetTable,
@ -47,12 +33,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

@ -186,11 +186,6 @@ function user_angeltype_confirm_controller(): array
];
}
/**
* @param User $user
* @param AngelType $angeltype
* @return void
*/
function user_angeltype_confirm_email(User $user, AngelType $angeltype): void
{
if (!$user->settings->email_shiftinfo) {
@ -216,11 +211,6 @@ function user_angeltype_confirm_email(User $user, AngelType $angeltype): void
}
}
/**
* @param User $user
* @param AngelType $angeltype
* @return void
*/
function user_angeltype_add_email(User $user, AngelType $angeltype): void
{
if (!$user->settings->email_shiftinfo || $user->id == auth()->user()->id) {

View File

@ -4,9 +4,6 @@ declare(strict_types=1);
use Engelsystem\Renderer\Twig\Extensions\Globals;
/**
* @return int
*/
function theme_id(): int
{
/** @var Globals $globals */
@ -24,9 +21,6 @@ function theme(): array
return config('themes')[$theme_id];
}
/**
* @return string
*/
function theme_type(): string
{
return theme()['type'];

View File

@ -13,34 +13,12 @@ use Symfony\Component\Mailer\Exception\TransportException;
class Shift
{
/** @var LoggerInterface */
protected LoggerInterface $log;
/** @var EngelsystemMailer */
protected EngelsystemMailer $mailer;
/**
* @param LoggerInterface $log
* @param EngelsystemMailer $mailer
*/
public function __construct(
LoggerInterface $log,
EngelsystemMailer $mailer
protected LoggerInterface $log,
protected EngelsystemMailer $mailer
) {
$this->log = $log;
$this->mailer = $mailer;
}
/**
* @param User $user
* @param Carbon $start
* @param Carbon $end
* @param string $name
* @param string $title
* @param string $type
* @param Room $room
* @return void
*/
public function deletedEntryCreateWorklog(
User $user,
Carbon $start,
@ -79,16 +57,6 @@ class Shift
);
}
/**
* @param User $user
* @param Carbon $start
* @param Carbon $end
* @param string $name
* @param string $title
* @param string $type
* @param Room $room
* @return void
*/
public function deletedEntrySendEmail(
User $user,
Carbon $start,

View File

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

View File

@ -29,9 +29,6 @@ class ShiftsFilter
/** @var int[] */
private $filled;
/** @var int[] */
private $rooms;
/** @var int[] */
private $types;
@ -48,9 +45,8 @@ class ShiftsFilter
* @param int[] $rooms
* @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->filled = [

View File

@ -8,20 +8,12 @@ namespace Engelsystem;
*/
class ValidationResult
{
/** @var bool */
private $valid;
/** @var mixed */
private $value;
/**
* @param boolean $valid Is the value valid?
* @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

@ -511,9 +511,6 @@ function admin_shifts()
);
}
/**
* @return string
*/
function admin_shifts_history_title(): string
{
return __('Shifts history');

View File

@ -40,8 +40,7 @@ class ImportSchedule extends BaseController
/** @var LoggerInterface */
protected $log;
/** @var array */
protected $permissions = [
protected array $permissions = [
'schedule.import',
];
@ -60,14 +59,6 @@ class ImportSchedule extends BaseController
/** @var GuzzleClient */
protected $guzzle;
/**
* @param Response $response
* @param SessionInterface $session
* @param GuzzleClient $guzzle
* @param XmlParser $parser
* @param DatabaseConnection $db
* @param LoggerInterface $log
*/
public function __construct(
Response $response,
SessionInterface $session,
@ -84,9 +75,6 @@ class ImportSchedule extends BaseController
$this->log = $log;
}
/**
* @return Response
*/
public function index(): Response
{
return $this->response->withView(
@ -98,11 +86,6 @@ class ImportSchedule extends BaseController
);
}
/**
* @param Request $request
*
* @return Response
*/
public function edit(Request $request): Response
{
$scheduleId = $request->getAttribute('schedule_id'); // optional
@ -118,11 +101,6 @@ class ImportSchedule extends BaseController
);
}
/**
* @param Request $request
*
* @return Response
*/
public function save(Request $request): Response
{
$scheduleId = $request->getAttribute('schedule_id'); // optional
@ -166,10 +144,6 @@ class ImportSchedule extends BaseController
return redirect('/admin/schedule/load/' . $schedule->id);
}
/**
* @param Request $request
* @return Response
*/
public function loadSchedule(Request $request): Response
{
try {
@ -215,11 +189,6 @@ class ImportSchedule extends BaseController
);
}
/**
* @param Request $request
*
* @return Response
*/
public function importSchedule(Request $request): Response
{
try {
@ -284,9 +253,6 @@ class ImportSchedule extends BaseController
->with('messages', ['schedule.import.success']);
}
/**
* @param Room $room
*/
protected function createRoom(Room $room): void
{
$roomModel = new RoomModel();
@ -296,9 +262,6 @@ class ImportSchedule extends BaseController
$this->log('Created schedule room "{room}"', ['room' => $room->getName()]);
}
/**
* @param Event $event
*/
protected function fireDeleteShiftEntryEvents(Event $event): void
{
$shiftEntries = $this->db
@ -329,12 +292,6 @@ class ImportSchedule extends BaseController
}
}
/**
* @param Event $shift
* @param int $shiftTypeId
* @param RoomModel $room
* @param ScheduleUrl $scheduleUrl
*/
protected function createEvent(Event $shift, int $shiftTypeId, RoomModel $room, ScheduleUrl $scheduleUrl): void
{
$user = auth()->user();
@ -374,11 +331,6 @@ class ImportSchedule extends BaseController
);
}
/**
* @param Event $shift
* @param int $shiftTypeId
* @param RoomModel $room
*/
protected function updateEvent(Event $shift, int $shiftTypeId, RoomModel $room): void
{
$user = auth()->user();
@ -412,9 +364,6 @@ class ImportSchedule extends BaseController
);
}
/**
* @param Event $shift
*/
protected function deleteEvent(Event $shift): void
{
$this->db
@ -564,10 +513,6 @@ class ImportSchedule extends BaseController
return [$newEvents, $changeEvents, $deleteEvents];
}
/**
* @param ScheduleShift $scheduleShift
* @return Event
*/
protected function eventFromScheduleShift(ScheduleShift $scheduleShift): Event
{
$shift = $this->loadShift($scheduleShift->shift_id);

View File

@ -9,15 +9,6 @@ use Exception;
*/
class ShiftCalendarLane
{
/** @var int */
private $firstBlockStartTime;
/** @var int */
private $blockCount;
/** @var string */
private $header;
/** @var array[] */
private $shifts = [];
@ -28,11 +19,8 @@ class ShiftCalendarLane
* @param int $firstBlockStartTime Unix timestamp
* @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 */
private $blocksPerSlot = null;
/** @var array[] */
private $needed_angeltypes;
/** @var array[] */
private $shift_entries;
/**
* ShiftCalendarRenderer constructor.
*
@ -56,14 +50,12 @@ class ShiftCalendarRenderer
* @param array[] $shift_entries
* @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->firstBlockStartTime = $this->calcFirstBlockStartTime($shifts);
$this->lastBlockEndTime = $this->calcLastBlockEndTime($shifts);
$this->lanes = $this->assignShiftsToLanes($shifts);
$this->needed_angeltypes = $needed_angeltypes;
$this->shift_entries = $shift_entries;
}
/**

View File

@ -12,28 +12,22 @@ use Psr\Http\Server\MiddlewareInterface;
class Application extends Container
{
/** @var string|null */
protected $appPath = null;
protected ?string $appPath = null;
/** @var bool */
protected $isBootstrapped = false;
protected bool $isBootstrapped = false;
/** @var MiddlewareInterface[]|string[] */
protected $middleware;
protected array $middleware;
/**
* Registered service providers
*
* @var array
*/
protected $serviceProviders = [];
protected array $serviceProviders = [];
/**
* Application constructor.
*
* @param string $appPath
*/
public function __construct($appPath = null)
public function __construct(string $appPath = null)
{
if (!is_null($appPath)) {
$this->setAppPath($appPath);
@ -42,7 +36,7 @@ class Application extends Container
$this->registerBaseBindings();
}
protected function registerBaseBindings()
protected function registerBaseBindings(): void
{
static::setInstance($this);
Container::setInstance($this);
@ -55,11 +49,7 @@ class Application extends Container
$this->bind(ContainerInterface::class, self::class);
}
/**
* @param string|ServiceProvider $provider
* @return ServiceProvider
*/
public function register($provider)
public function register(string|ServiceProvider $provider): ServiceProvider
{
if (is_string($provider)) {
$provider = $this->make($provider);
@ -81,7 +71,7 @@ class Application extends Container
*
* @param Config|null $config
*/
public function bootstrap(Config $config = null)
public function bootstrap(Config $config = null): void
{
if ($this->isBootstrapped) {
return;
@ -102,7 +92,7 @@ class Application extends Container
$this->isBootstrapped = true;
}
protected function registerPaths()
protected function registerPaths(): void
{
$appPath = $this->appPath;
@ -124,10 +114,9 @@ class Application extends Container
/**
* Set app base path
*
* @param string $appPath
* @return static
*/
public function setAppPath($appPath)
public function setAppPath(string $appPath): static
{
$appPath = realpath($appPath);
$appPath = rtrim($appPath, DIRECTORY_SEPARATOR);
@ -139,18 +128,12 @@ class Application extends Container
return $this;
}
/**
* @return string|null
*/
public function path()
public function path(): ?string
{
return $this->appPath;
}
/**
* @return bool
*/
public function isBooted()
public function isBooted(): bool
{
return $this->isBootstrapped;
}
@ -158,7 +141,7 @@ class Application extends Container
/**
* @return MiddlewareInterface[]|string[]
*/
public function getMiddleware()
public function getMiddleware(): array
{
return $this->middleware;
}

View File

@ -8,17 +8,13 @@ class Config extends Fluent
{
/**
* The config values
*
* @var array
*/
protected $attributes = [];
protected $attributes = []; // phpcs:ignore
/**
* @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): mixed
{
if (is_null($key)) {
return $this->attributes;
@ -33,9 +29,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): void
{
if (is_array($key)) {
foreach ($key as $configKey => $configValue) {
@ -50,9 +45,8 @@ class Config extends Fluent
/**
* @param string $key
* @return bool
*/
public function has($key)
public function has(mixed $key): bool
{
return $this->offsetExists($key);
}
@ -60,7 +54,7 @@ class Config extends Fluent
/**
* @param string $key
*/
public function remove($key)
public function remove(mixed $key): void
{
$this->offsetUnset($key);
}

View File

@ -10,24 +10,14 @@ use Illuminate\Database\QueryException;
class ConfigServiceProvider extends ServiceProvider
{
/** @var array */
protected $configFiles = ['app.php', 'config.default.php', 'config.php'];
protected array $configFiles = ['app.php', 'config.default.php', 'config.php'];
/** @var EventConfig */
protected $eventConfig;
/**
* @param Application $app
* @param EventConfig $eventConfig
*/
public function __construct(Application $app, EventConfig $eventConfig = null)
public function __construct(Application $app, protected ?EventConfig $eventConfig = null)
{
parent::__construct($app);
$this->eventConfig = $eventConfig;
}
public function register()
public function register(): void
{
$config = $this->app->make(Config::class);
$this->app->instance(Config::class, $config);
@ -52,7 +42,7 @@ class ConfigServiceProvider extends ServiceProvider
}
}
public function boot()
public function boot(): void
{
if (!$this->eventConfig) {
return;
@ -83,11 +73,8 @@ 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

@ -6,30 +6,24 @@ use Engelsystem\Application;
abstract class ServiceProvider
{
/** @var Application */
protected $app;
/**
* ServiceProvider constructor.
*
* @param Application $app
*/
public function __construct(Application $app)
public function __construct(protected Application $app)
{
$this->app = $app;
}
/**
* Register container bindings
*/
public function register()
public function register(): void
{
}
/**
* Called after other services had been registered
*/
public function boot()
public function boot(): void
{
}
}

View File

@ -14,47 +14,20 @@ class FaqController extends BaseController
{
use HasUserNotifications;
/** @var LoggerInterface */
protected $log;
/** @var Faq */
protected $faq;
/** @var Redirector */
protected $redirect;
/** @var Response */
protected $response;
/** @var array */
protected $permissions = [
/** @var array<string> */
protected array $permissions = [
'faq.view',
'faq.edit',
];
/**
* @param LoggerInterface $log
* @param Faq $faq
* @param Redirector $redirector
* @param Response $response
*/
public function __construct(
LoggerInterface $log,
Faq $faq,
Redirector $redirector,
Response $response
protected LoggerInterface $log,
protected Faq $faq,
protected Redirector $redirect,
protected Response $response
) {
$this->log = $log;
$this->faq = $faq;
$this->redirect = $redirector;
$this->response = $response;
}
/**
* @param Request $request
*
* @return Response
*/
public function edit(Request $request): Response
{
$faqId = $request->getAttribute('faq_id'); // optional
@ -64,11 +37,6 @@ class FaqController extends BaseController
return $this->showEdit($faq);
}
/**
* @param Request $request
*
* @return Response
*/
public function save(Request $request): Response
{
$faqId = $request->getAttribute('faq_id'); // optional
@ -109,11 +77,6 @@ class FaqController extends BaseController
return $this->redirect->to('/faq#faq-' . $faq->id);
}
/**
* @param Faq|null $faq
*
* @return Response
*/
protected function showEdit(?Faq $faq): Response
{
return $this->response->withView(

View File

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

View File

@ -15,52 +15,20 @@ class NewsController extends BaseController
{
use HasUserNotifications;
/** @var Authenticator */
protected $auth;
/** @var LoggerInterface */
protected $log;
/** @var News */
protected $news;
/** @var Redirector */
protected $redirect;
/** @var Response */
protected $response;
/** @var array */
protected $permissions = [
/** @var array<string> */
protected array $permissions = [
'admin_news',
];
/**
* @param Authenticator $auth
* @param LoggerInterface $log
* @param News $news
* @param Redirector $redirector
* @param Response $response
*/
public function __construct(
Authenticator $auth,
LoggerInterface $log,
News $news,
Redirector $redirector,
Response $response
protected Authenticator $auth,
protected LoggerInterface $log,
protected News $news,
protected Redirector $redirect,
protected Response $response
) {
$this->auth = $auth;
$this->log = $log;
$this->news = $news;
$this->redirect = $redirector;
$this->response = $response;
}
/**
* @param Request $request
*
* @return Response
*/
public function edit(Request $request): Response
{
$newsId = $request->getAttribute('news_id'); // optional
@ -71,12 +39,6 @@ class NewsController extends BaseController
return $this->showEdit($news, $isMeeting);
}
/**
* @param News|null $news
* @param bool $isMeetingDefault
*
* @return Response
*/
protected function showEdit(?News $news, bool $isMeetingDefault = false): Response
{
return $this->response->withView(
@ -89,11 +51,6 @@ class NewsController extends BaseController
);
}
/**
* @param Request $request
*
* @return Response
*/
public function save(Request $request): Response
{
$newsId = $request->getAttribute('news_id'); // optional

View File

@ -16,51 +16,21 @@ class QuestionsController extends BaseController
{
use HasUserNotifications;
/** @var Authenticator */
protected $auth;
/** @var LoggerInterface */
protected $log;
/** @var Question */
protected $question;
/** @var Redirector */
protected $redirect;
/** @var Response */
protected $response;
/** @var array */
protected $permissions = [
/** @var array<string> */
protected array $permissions = [
'question.add',
'question.edit',
];
/**
* @param Authenticator $auth
* @param LoggerInterface $log
* @param Question $question
* @param Redirector $redirector
* @param Response $response
*/
public function __construct(
Authenticator $auth,
LoggerInterface $log,
Question $question,
Redirector $redirector,
Response $response
protected Authenticator $auth,
protected LoggerInterface $log,
protected Question $question,
protected Redirector $redirect,
protected Response $response
) {
$this->auth = $auth;
$this->log = $log;
$this->question = $question;
$this->redirect = $redirector;
$this->response = $response;
}
/**
* @return Response
*/
public function index(): Response
{
$questions = $this->question
@ -74,11 +44,6 @@ class QuestionsController extends BaseController
);
}
/**
* @param Request $request
*
* @return Response
*/
public function delete(Request $request): Response
{
$data = $this->validate($request, [
@ -95,11 +60,6 @@ class QuestionsController extends BaseController
return $this->redirect->to('/admin/questions');
}
/**
* @param Request $request
*
* @return Response
*/
public function edit(Request $request): Response
{
$questionId = (int)$request->getAttribute('question_id');
@ -109,11 +69,6 @@ class QuestionsController extends BaseController
return $this->showEdit($questions);
}
/**
* @param Request $request
*
* @return Response
*/
public function save(Request $request): Response
{
$questionId = (int)$request->getAttribute('question_id');
@ -159,11 +114,6 @@ class QuestionsController extends BaseController
return $this->redirect->to('/admin/questions');
}
/**
* @param Question|null $question
*
* @return Response
*/
protected function showEdit(?Question $question): Response
{
return $this->response->withView(

View File

@ -16,59 +16,22 @@ class UserShirtController extends BaseController
{
use HasUserNotifications;
/** @var Authenticator */
protected $auth;
/** @var Config */
protected $config;
/** @var LoggerInterface */
protected $log;
/** @var Redirector */
protected $redirect;
/** @var Response */
protected $response;
/** @var User */
protected $user;
/** @var array */
protected $permissions = [
/** @var array<string, string> */
protected array $permissions = [
'editShirt' => 'user.edit.shirt',
'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,
LoggerInterface $log,
Redirector $redirector,
Response $response,
User $user
protected Authenticator $auth,
protected Config $config,
protected LoggerInterface $log,
protected Redirector $redirect,
protected Response $response,
protected User $user
) {
$this->auth = $auth;
$this->config = $config;
$this->log = $log;
$this->redirect = $redirector;
$this->response = $response;
$this->user = $user;
}
/**
* @param Request $request
*
* @return Response
*/
public function editShirt(Request $request): Response
{
$userId = (int)$request->getAttribute('user_id');
@ -81,11 +44,6 @@ class UserShirtController extends BaseController
);
}
/**
* @param Request $request
*
* @return Response
*/
public function saveShirt(Request $request): Response
{
$userId = (int)$request->getAttribute('user_id');

View File

@ -19,63 +19,22 @@ class UserWorkLogController extends BaseController
{
use HasUserNotifications;
/** @var Authenticator */
protected $auth;
/** @var Config */
protected $config;
/** @var LoggerInterface */
protected $log;
/** @var Worklog */
protected $worklog;
/** @var Redirector */
protected $redirect;
/** @var Response */
protected $response;
/** @var User */
protected $user;
/** @var array */
protected $permissions = [
/** @var array<string> */
protected array $permissions = [
'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,
LoggerInterface $log,
Worklog $worklog,
Redirector $redirector,
Response $response,
User $user
protected Authenticator $auth,
protected Config $config,
protected LoggerInterface $log,
protected Worklog $worklog,
protected Redirector $redirect,
protected Response $response,
protected User $user
) {
$this->auth = $auth;
$this->config = $config;
$this->log = $log;
$this->worklog = $worklog;
$this->redirect = $redirector;
$this->response = $response;
$this->user = $user;
}
/**
* @param Request $request
* @return Response
*/
public function editWorklog(Request $request): Response
{
$userId = (int)$request->getAttribute('user_id');
@ -95,10 +54,6 @@ class UserWorkLogController extends BaseController
}
}
/**
* @param Request $request
* @return Response
*/
public function saveWorklog(Request $request): Response
{
$userId = (int)$request->getAttribute('user_id');
@ -134,10 +89,6 @@ class UserWorkLogController extends BaseController
// TODO Once User_view.php gets removed, change this to withView + getNotifications
}
/**
* @param Request $request
* @return Response
*/
public function showDeleteWorklog(Request $request): Response
{
$userId = (int)$request->getAttribute('user_id');
@ -156,10 +107,6 @@ class UserWorkLogController extends BaseController
);
}
/**
* @param Request $request
* @return Response
*/
public function deleteWorklog(Request $request): Response
{
$userId = (int)$request->getAttribute('user_id');
@ -197,9 +144,6 @@ class UserWorkLogController extends BaseController
);
}
/**
* @return Carbon
*/
private function getWorkDateSuggestion(): Carbon
{
$buildup_start = config('buildup_start');

View File

@ -6,21 +6,11 @@ use Engelsystem\Http\Response;
class ApiController extends BaseController
{
/** @var Response */
protected $response;
/**
* @param Response $response
*/
public function __construct(Response $response)
public function __construct(protected Response $response)
{
$this->response = $response;
}
/**
* @return Response
*/
public function index()
public function index(): Response
{
return $this->response
->setStatusCode(501)

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