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 image: composer:latest
stage: validate stage: validate
script: 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" - ./vendor/bin/phpcs -p --no-colors --basepath="$PWD"
phpstan: phpstan:

View File

@ -8,6 +8,7 @@
<file>public/index.php</file> <file>public/index.php</file>
<file>src</file> <file>src</file>
<file>tests</file> <file>tests</file>
<exclude-pattern>/config/config.php</exclude-pattern>
<rule ref="PSR12" /> <rule ref="PSR12" />
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses"> <rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
@ -23,4 +24,19 @@
<rule ref="Generic.Files.LineLength.TooLong"> <rule ref="Generic.Files.LineLength.TooLong">
<exclude-pattern>/includes</exclude-pattern> <exclude-pattern>/includes</exclude-pattern>
</rule> </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> </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"' \; 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 ## Testing
To run the unit tests use To run the unit tests use
```bash ```bash

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,12 +8,9 @@ use Illuminate\Database\Eloquent\Factories\Factory;
class LicenseFactory extends Factory class LicenseFactory extends Factory
{ {
/** @var string */ /** @var string */
protected $model = License::class; protected $model = License::class; // phpcs:ignore
/** public function definition(): array
* @return array
*/
public function definition()
{ {
$drive_car = $this->faker->boolean(.8); $drive_car = $this->faker->boolean(.8);
$drive_3_5t = $drive_car && $this->faker->boolean(.7); $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 class PasswordResetFactory extends Factory
{ {
/** @var string */ /** @var string */
protected $model = PasswordReset::class; protected $model = PasswordReset::class; // phpcs:ignore
/** public function definition(): array
* @return array
*/
public function definition()
{ {
return [ return [
'token' => bin2hex(random_bytes(16)), 'token' => bin2hex(random_bytes(16)),

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,9 +10,9 @@ class CreateLogEntriesTable extends Migration
/** /**
* Run the 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->increments('id');
$table->string('level', 20); $table->string('level', 20);
$table->text('message'); $table->text('message');
@ -32,9 +32,9 @@ class CreateLogEntriesTable extends Migration
/** /**
* Reverse the 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->increments('id');
$table->string('level', 20); $table->string('level', 20);
$table->text('message'); $table->text('message');

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -14,7 +14,7 @@ class UserPersonalDataAddPronounField extends Migration
*/ */
public function up(): void 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) $table->string('pronoun', 15)
->nullable() ->nullable()
->default(null) ->default(null)
@ -27,7 +27,7 @@ class UserPersonalDataAddPronounField extends Migration
*/ */
public function down(): void 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'); $table->dropColumn('pronoun');
}); });
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,9 +10,9 @@ class IncreaseSessionsTablePayloadSize extends Migration
/** /**
* Run the 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(); $table->mediumText('payload')->change();
}); });
} }
@ -20,9 +20,9 @@ class IncreaseSessionsTablePayloadSize extends Migration
/** /**
* Reverse the 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(); $table->text('payload')->change();
}); });
} }

View File

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

View File

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

View File

@ -13,9 +13,9 @@ class IncreaseTshirtFieldWidth extends Migration
/** /**
* Run the 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(); $table->string('shirt_size', 10)->change();
}); });
} }
@ -23,9 +23,9 @@ class IncreaseTshirtFieldWidth extends Migration
/** /**
* Reverse the 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(); $table->string('shirt_size', 4)->change();
}); });
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,9 +12,9 @@ class ChangeApiKeyLength extends Migration
/** /**
* Run the 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(); $table->string('api_key', 64)->change();
}); });
} }
@ -22,9 +22,9 @@ class ChangeApiKeyLength extends Migration
/** /**
* Reverse the 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(); $table->string('api_key', 32)->change();
}); });
} }

View File

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

View File

@ -8,25 +8,11 @@ use Illuminate\Support\Str;
trait Reference trait Reference
{ {
/**
* @param Blueprint $table
* @param bool $setPrimary
* @return ColumnDefinition
*/
protected function referencesUser(Blueprint $table, bool $setPrimary = false): ColumnDefinition protected function referencesUser(Blueprint $table, bool $setPrimary = false): ColumnDefinition
{ {
return $this->references($table, 'users', null, null, $setPrimary); 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( protected function references(
Blueprint $table, Blueprint $table,
string $targetTable, string $targetTable,
@ -47,12 +33,6 @@ trait Reference
return $col; return $col;
} }
/**
* @param Blueprint $table
* @param string $fromColumn
* @param string $targetTable
* @param string|null $targetColumn
*/
protected function addReference( protected function addReference(
Blueprint $table, Blueprint $table,
string $fromColumn, 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 function user_angeltype_confirm_email(User $user, AngelType $angeltype): void
{ {
if (!$user->settings->email_shiftinfo) { 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 function user_angeltype_add_email(User $user, AngelType $angeltype): void
{ {
if (!$user->settings->email_shiftinfo || $user->id == auth()->user()->id) { 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; use Engelsystem\Renderer\Twig\Extensions\Globals;
/**
* @return int
*/
function theme_id(): int function theme_id(): int
{ {
/** @var Globals $globals */ /** @var Globals $globals */
@ -24,9 +21,6 @@ function theme(): array
return config('themes')[$theme_id]; return config('themes')[$theme_id];
} }
/**
* @return string
*/
function theme_type(): string function theme_type(): string
{ {
return theme()['type']; return theme()['type'];

View File

@ -13,34 +13,12 @@ use Symfony\Component\Mailer\Exception\TransportException;
class Shift class Shift
{ {
/** @var LoggerInterface */
protected LoggerInterface $log;
/** @var EngelsystemMailer */
protected EngelsystemMailer $mailer;
/**
* @param LoggerInterface $log
* @param EngelsystemMailer $mailer
*/
public function __construct( public function __construct(
LoggerInterface $log, protected LoggerInterface $log,
EngelsystemMailer $mailer protected EngelsystemMailer $mailer
) { ) {
$this->log = $log;
$this->mailer = $mailer;
} }
/**
* @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( public function deletedEntryCreateWorklog(
User $user, User $user,
Carbon $start, 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( public function deletedEntrySendEmail(
User $user, User $user,
Carbon $start, Carbon $start,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,30 +6,24 @@ use Engelsystem\Application;
abstract class ServiceProvider abstract class ServiceProvider
{ {
/** @var Application */
protected $app;
/** /**
* ServiceProvider constructor. * ServiceProvider constructor.
*
* @param Application $app
*/ */
public function __construct(Application $app) public function __construct(protected Application $app)
{ {
$this->app = $app;
} }
/** /**
* Register container bindings * Register container bindings
*/ */
public function register() public function register(): void
{ {
} }
/** /**
* Called after other services had been registered * 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; use HasUserNotifications;
/** @var LoggerInterface */ /** @var array<string> */
protected $log; protected array $permissions = [
/** @var Faq */
protected $faq;
/** @var Redirector */
protected $redirect;
/** @var Response */
protected $response;
/** @var array */
protected $permissions = [
'faq.view', 'faq.view',
'faq.edit', 'faq.edit',
]; ];
/**
* @param LoggerInterface $log
* @param Faq $faq
* @param Redirector $redirector
* @param Response $response
*/
public function __construct( public function __construct(
LoggerInterface $log, protected LoggerInterface $log,
Faq $faq, protected Faq $faq,
Redirector $redirector, protected Redirector $redirect,
Response $response 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 public function edit(Request $request): Response
{ {
$faqId = $request->getAttribute('faq_id'); // optional $faqId = $request->getAttribute('faq_id'); // optional
@ -64,11 +37,6 @@ class FaqController extends BaseController
return $this->showEdit($faq); return $this->showEdit($faq);
} }
/**
* @param Request $request
*
* @return Response
*/
public function save(Request $request): Response public function save(Request $request): Response
{ {
$faqId = $request->getAttribute('faq_id'); // optional $faqId = $request->getAttribute('faq_id'); // optional
@ -109,11 +77,6 @@ class FaqController extends BaseController
return $this->redirect->to('/faq#faq-' . $faq->id); return $this->redirect->to('/faq#faq-' . $faq->id);
} }
/**
* @param Faq|null $faq
*
* @return Response
*/
protected function showEdit(?Faq $faq): Response protected function showEdit(?Faq $faq): Response
{ {
return $this->response->withView( return $this->response->withView(

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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