diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7201ec81..75ad2d92 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -83,11 +83,11 @@ check-style: stage: test before_script: - curl -sS https://getcomposer.org/installer | php -- --no-ansi --install-dir /usr/local/bin/ --filename composer - - cp -R tests/ "${DOCROOT}" + - cp -R tests/ .phpcs.xml "${DOCROOT}" - cd "${DOCROOT}" - composer --no-ansi install script: - - ./vendor/bin/phpcs --no-colors --basepath="$PWD" -p --standard=PSR12 config/ db/ public/index.php src/ tests/ + - composer phpcs -- --no-colors --basepath="$PWD" release-image: <<: *docker_definition diff --git a/src/Mail/Mailer.php b/src/Mail/Mailer.php index ed800986..5f0091c1 100644 --- a/src/Mail/Mailer.php +++ b/src/Mail/Mailer.php @@ -2,7 +2,6 @@ namespace Engelsystem\Mail; -use Engelsystem\Renderer\Renderer; use Swift_Mailer as SwiftMailer; use Swift_Message as SwiftMessage; @@ -11,9 +10,6 @@ class Mailer /** @var SwiftMailer */ protected $mailer; - /** @var Renderer|null */ - protected $view; - /** @var string */ protected $fromAddress = ''; diff --git a/src/Middleware/ExceptionHandler.php b/src/Middleware/ExceptionHandler.php index a5db0337..a22e895f 100644 --- a/src/Middleware/ExceptionHandler.php +++ b/src/Middleware/ExceptionHandler.php @@ -8,6 +8,7 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; +use Throwable; class ExceptionHandler implements MiddlewareInterface { @@ -37,7 +38,7 @@ class ExceptionHandler implements MiddlewareInterface ): ResponseInterface { try { return $handler->handle($request); - } catch (\Throwable $e) { + } catch (Throwable $e) { /** @var ExceptionsHandler $handler */ $handler = $this->container->get('error.handler'); $content = $handler->exceptionHandler($e, true); diff --git a/src/Middleware/RouteDispatcherServiceProvider.php b/src/Middleware/RouteDispatcherServiceProvider.php index 193510f3..89e1294c 100644 --- a/src/Middleware/RouteDispatcherServiceProvider.php +++ b/src/Middleware/RouteDispatcherServiceProvider.php @@ -8,6 +8,8 @@ use FastRoute\Dispatcher as FastRouteDispatcher; use FastRoute\RouteCollector; use Psr\Http\Server\MiddlewareInterface; +use function FastRoute\cachedDispatcher as FRCashedDispatcher; + class RouteDispatcherServiceProvider extends ServiceProvider { public function register() @@ -57,7 +59,7 @@ class RouteDispatcherServiceProvider extends ServiceProvider unlink($routesCacheFile); } - return \FastRoute\cachedDispatcher(function (RouteCollector $route) { + return FRCashedDispatcher(function (RouteCollector $route) { require config_path('routes.php'); }, $options); } diff --git a/src/Models/LogEntry.php b/src/Models/LogEntry.php index 8a73d305..de6784ec 100644 --- a/src/Models/LogEntry.php +++ b/src/Models/LogEntry.php @@ -6,6 +6,7 @@ use Carbon\Carbon; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Query\Builder as QueryBuilder; +use Illuminate\Support\Collection as SupportCollection; /** * @property int $id @@ -38,7 +39,7 @@ class LogEntry extends BaseModel /** * @param $keyword - * @return Builder[]|Collection|LogEntry[] + * @return Builder[]|Collection|SupportCollection|LogEntry[] */ public static function filter($keyword = null) { diff --git a/src/Models/Message.php b/src/Models/Message.php index cf1a6160..f865c873 100644 --- a/src/Models/Message.php +++ b/src/Models/Message.php @@ -13,9 +13,9 @@ use Illuminate\Support\Carbon; /** * This class represents a message send trough the system. * - * @property integer $id - * @property integer $receiver_id - * @property boolean $read + * @property int $id + * @property int $receiver_id + * @property bool $read * @property string $text * @property Carbon|null $created_at * @property Carbon|null $updated_at diff --git a/src/Models/Question.php b/src/Models/Question.php index eccf7fe6..ead2d991 100644 --- a/src/Models/Question.php +++ b/src/Models/Question.php @@ -8,12 +8,13 @@ use Engelsystem\Models\User\User; use Engelsystem\Models\User\UsesUserModel; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Query\Builder as QueryBuilder; /** - * @property integer $id + * @property int $id * @property string $text * @property string $answer - * @property integer $answerer_id + * @property int $answerer_id * @property-read User $answerer * @method static Builder|Question whereAnswer($value) * @method static Builder|Question whereAnswererId($value) @@ -55,7 +56,7 @@ class Question extends BaseModel } /** - * @return Builder + * @return Builder|QueryBuilder */ public static function answered(): Builder { diff --git a/src/Models/User/User.php b/src/Models/User/User.php index c4bc1fcb..30d57c83 100644 --- a/src/Models/User/User.php +++ b/src/Models/User/User.php @@ -14,7 +14,7 @@ use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Query\Builder as QueryBuilder; /** - * @property integer $id + * @property int $id * @property string $name * @property string $email * @property string $password @@ -157,7 +157,7 @@ class User extends BaseModel } /** - * @return HasMany + * @return HasMany|QueryBuilder */ public function messagesReceived(): HasMany { diff --git a/src/Models/User/UsesUserModel.php b/src/Models/User/UsesUserModel.php index ff33e968..5d07589a 100644 --- a/src/Models/User/UsesUserModel.php +++ b/src/Models/User/UsesUserModel.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Query\Builder as QueryBuilder; /** - * @property integer $user_id + * @property int $user_id * * @property-read QueryBuilder|User $user * diff --git a/tests/Feature/Logger/LoggerTest.php b/tests/Feature/Logger/LoggerTest.php index c855bb7b..aac5aee8 100644 --- a/tests/Feature/Logger/LoggerTest.php +++ b/tests/Feature/Logger/LoggerTest.php @@ -31,7 +31,7 @@ class LoggerTest extends ApplicationFeatureTest } /** - * @return string[] + * @return string[][] */ public function provideLogLevels() { @@ -80,7 +80,7 @@ class LoggerTest extends ApplicationFeatureTest } /** - * @return string[] + * @return mixed[][] */ public function provideContextReplaceValues() { diff --git a/tests/Feature/Model/RoomModelTest.php b/tests/Feature/Model/RoomModelTest.php index f86359e0..0fe767a2 100644 --- a/tests/Feature/Model/RoomModelTest.php +++ b/tests/Feature/Model/RoomModelTest.php @@ -28,7 +28,7 @@ class RoomModelTest extends ApplicationFeatureTest $this->assertNotEmpty($room); $this->assertNotNull($room); - $this->assertEquals($room['Name'], 'test'); + $this->assertEquals('test', $room['Name']); $this->assertEmpty(Room(-1)); } diff --git a/tests/Unit/ApplicationTest.php b/tests/Unit/ApplicationTest.php index a36610cb..aa2f28eb 100644 --- a/tests/Unit/ApplicationTest.php +++ b/tests/Unit/ApplicationTest.php @@ -173,11 +173,9 @@ class ApplicationTest extends TestCase */ protected function mockServiceProvider(Application $app, $methods = []) { - $serviceProvider = $this->getMockBuilder(ServiceProvider::class) + return $this->getMockBuilder(ServiceProvider::class) ->setConstructorArgs([$app]) ->onlyMethods($methods) ->getMockForAbstractClass(); - - return $serviceProvider; } } diff --git a/tests/Unit/Controllers/PasswordResetControllerTest.php b/tests/Unit/Controllers/PasswordResetControllerTest.php index f237ff66..2dfc2083 100644 --- a/tests/Unit/Controllers/PasswordResetControllerTest.php +++ b/tests/Unit/Controllers/PasswordResetControllerTest.php @@ -229,6 +229,7 @@ class PasswordResetControllerTest extends TestCase $controller->setValidator(new Validator()); if ($view) { + /** @var array|mixed[] $args */ $args = [$view]; if ($data) { $args[] = $data; diff --git a/tests/Unit/Database/Migration/MigrateTest.php b/tests/Unit/Database/Migration/MigrateTest.php index 6dd4ecb9..345a4999 100644 --- a/tests/Unit/Database/Migration/MigrateTest.php +++ b/tests/Unit/Database/Migration/MigrateTest.php @@ -1,6 +1,6 @@