Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/clear-config-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

chdir(__DIR__ . '/../');

require 'vendor/autoload.php';
require __DIR__ . '/vendor/autoload.php';

$config = include 'config/config.php';

Expand All @@ -22,7 +22,7 @@
exit(0);
}

if (false === unlink($config['config_cache_path'])) {
if (!unlink($config['config_cache_path'])) {
printf(
"Error removing config cache file '%s'%s",
$config['config_cache_path'],
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@
"roave/psr-container-doctrine": "^3.5"
},
"require-dev": {
"filp/whoops": "^2.14",
"laminas/laminas-development-mode": "^3.10",
"mezzio/mezzio-tooling": "^2.6",
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.15.18",
"roave/security-advisories": "dev-master",
"squizlabs/php_codesniffer": "^3.7",
"filp/whoops": "^2.14",
"vimeo/psalm": "^4.30"
},
"autoload": {
Expand Down
4 changes: 3 additions & 1 deletion config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
// Swoole config to overwrite some services (if installed)
class_exists(\Mezzio\Swoole\ConfigProvider::class)
? \Mezzio\Swoole\ConfigProvider::class
: function(){ return[]; },
: static function () {
return[];
},

// DotKernel packages
\Dot\Session\ConfigProvider::class,
Expand Down
52 changes: 20 additions & 32 deletions config/pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@
/**
* Setup middleware pipeline:
*/
return function (Application $app, MiddlewareFactory $factory, ContainerInterface $container): void {
return static function (Application $application, MiddlewareFactory $middlewareFactory, ContainerInterface $container) : void {
// The error handler should be the first (most outer) middleware to catch
// all Exceptions.
$app->pipe(DebugBarMiddleware::class);
$app->pipe(ErrorHandlerInterface::class);
$app->pipe(SessionMiddleware::class);
$app->pipe(ServerUrlMiddleware::class);
$app->pipe(CorsMiddleware::class);

$application->pipe(DebugBarMiddleware::class);
$application->pipe(ErrorHandlerInterface::class);
$application->pipe(SessionMiddleware::class);
$application->pipe(ServerUrlMiddleware::class);
$application->pipe(CorsMiddleware::class);
// Pipe more middleware here that you want to execute on every request:
// - bootstrapping
// - pre-conditions
Expand All @@ -54,49 +53,38 @@
// - $app->pipe('/api', $apiMiddleware);
// - $app->pipe('/docs', $apiDocMiddleware);
// - $app->pipe('/files', $filesMiddleware);

// Slug Middleware must be triggered before RouteMiddleware!
$app->pipe(SlugMiddleware::class);

$application->pipe(SlugMiddleware::class);
// Register the routing middleware in the middleware pipeline.
// This middleware registers the Mezzio\Router\RouteResult request attribute.
$app->pipe(RouteMiddleware::class);
$app->pipe(ResponseHeaderMiddleware::class);



$application->pipe(RouteMiddleware::class);
$application->pipe(ResponseHeaderMiddleware::class);
// The following handle routing failures for common conditions:
// - HEAD request but no routes answer that method
// - OPTIONS request but no routes answer that method
// - method not allowed
// Order here matters; the MethodNotAllowedMiddleware should be placed
// after the Implicit*Middleware.
$app->pipe(ImplicitHeadMiddleware::class);
$app->pipe(ImplicitOptionsMiddleware::class);
$app->pipe(MethodNotAllowedMiddleware::class);

$application->pipe(ImplicitHeadMiddleware::class);
$application->pipe(ImplicitOptionsMiddleware::class);
$application->pipe(MethodNotAllowedMiddleware::class);
// Seed the UrlHelper with the routing results:
$app->pipe(UrlHelperMiddleware::class);

$application->pipe(UrlHelperMiddleware::class);
// Add more middleware here that needs to introspect the routing results; this
// might include:
//
// - route-based authentication
// - route-based validation
// - etc.

$app->pipe(TranslatorMiddleware::class);
$app->pipe(RememberMeMiddleware::class);
$app->pipe(AuthMiddleware::class);
$app->pipe(ForbiddenHandler::class);
$app->pipe(RbacGuardMiddleware::class);


$application->pipe(TranslatorMiddleware::class);
$application->pipe(RememberMeMiddleware::class);
$application->pipe(AuthMiddleware::class);
$application->pipe(ForbiddenHandler::class);
$application->pipe(RbacGuardMiddleware::class);
// Register the dispatch middleware in the middleware pipeline
$app->pipe(DispatchMiddleware::class);

$application->pipe(DispatchMiddleware::class);
// At this point, if no Response is returned by any middleware, the
// NotFoundHandler kicks in; alternately, you can provide other fallback
// middleware to execute.
$app->pipe(NotFoundHandler::class);
$application->pipe(NotFoundHandler::class);
};
2 changes: 1 addition & 1 deletion config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
use Mezzio\MiddlewareFactory;
use Psr\Container\ContainerInterface;

return function (Application $app, MiddlewareFactory $factory, ContainerInterface $container): void {
return static function (Application $application, MiddlewareFactory $middlewareFactory, ContainerInterface $container) : void {
};
12 changes: 6 additions & 6 deletions data/doctrine/fixtures/RoleLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
* Class RoleLoader
* @package Frontend\Fixtures
*/
class RoleLoader implements FixtureInterface
final class RoleLoader implements FixtureInterface
{
public function load(ObjectManager $manager): void
public function load(ObjectManager $objectManager): void
{
$adminRole = new UserRole();
$adminRole->setName('admin');
Expand All @@ -23,11 +23,11 @@ public function load(ObjectManager $manager): void
$guestRole = new UserRole();
$guestRole->setName('guest');

$manager->persist($adminRole);
$manager->persist($userRole);
$manager->persist($guestRole);
$objectManager->persist($adminRole);
$objectManager->persist($userRole);
$objectManager->persist($guestRole);

$manager->flush();
$objectManager->flush();
}
}

16 changes: 8 additions & 8 deletions data/doctrine/migrations/Version20220817121035.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ public function getDescription(): string
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE contact_message (uuid BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid_binary_ordered_time)\', email VARCHAR(150) NOT NULL, name VARCHAR(150) NOT NULL, subject LONGTEXT NOT NULL, message LONGTEXT NOT NULL, platform LONGTEXT NOT NULL, created DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', updated DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user (uuid BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid_binary_ordered_time)\', identity VARCHAR(191) NOT NULL, password VARCHAR(191) NOT NULL, status ENUM(\'pending\', \'active\'), isDeleted TINYINT(1) NOT NULL, hash VARCHAR(64) NOT NULL, created DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', updated DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', UNIQUE INDEX UNIQ_8D93D6496A95E9C4 (identity), UNIQUE INDEX UNIQ_8D93D649D1B862B8 (hash), PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user_roles (userUuid BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid_binary_ordered_time)\', roleUuid BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid_binary_ordered_time)\', INDEX IDX_54FCD59FD73087E9 (userUuid), INDEX IDX_54FCD59F88446210 (roleUuid), PRIMARY KEY(userUuid, roleUuid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user_avatar (uuid BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid_binary_ordered_time)\', name VARCHAR(191) NOT NULL, created DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', updated DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', userUuid BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid_binary_ordered_time)\', UNIQUE INDEX UNIQ_73256912D73087E9 (userUuid), PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user_detail (uuid BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid_binary_ordered_time)\', firstName VARCHAR(191) DEFAULT NULL, lastName VARCHAR(191) DEFAULT NULL, created DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', updated DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', userUuid BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid_binary_ordered_time)\', UNIQUE INDEX UNIQ_4B5464AED73087E9 (userUuid), PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user_remember_me (uuid BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid_binary_ordered_time)\', rememberMeToken VARCHAR(100) NOT NULL, userAgent TEXT NOT NULL, expireDate DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', updated DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', userUuid BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid_binary_ordered_time)\', UNIQUE INDEX UNIQ_D3E96EBD1BBB86A0 (rememberMeToken), INDEX IDX_D3E96EBDD73087E9 (userUuid), PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user_reset_password (uuid BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid_binary_ordered_time)\', expires DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', hash VARCHAR(64) NOT NULL, status VARCHAR(20) NOT NULL, created DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', updated DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', userUuid BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid_binary_ordered_time)\', UNIQUE INDEX UNIQ_D21DE3BCD1B862B8 (hash), INDEX IDX_D21DE3BCD73087E9 (userUuid), PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user_role (uuid BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid_binary_ordered_time)\', name VARCHAR(30) NOT NULL, created DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', updated DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', UNIQUE INDEX UNIQ_2DE8C6A35E237E06 (name), PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql("CREATE TABLE contact_message (uuid BINARY(16) NOT NULL COMMENT '(DC2Type:uuid_binary_ordered_time)', email VARCHAR(150) NOT NULL, name VARCHAR(150) NOT NULL, subject LONGTEXT NOT NULL, message LONGTEXT NOT NULL, platform LONGTEXT NOT NULL, created DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', updated DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)', PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB");
$this->addSql("CREATE TABLE user (uuid BINARY(16) NOT NULL COMMENT '(DC2Type:uuid_binary_ordered_time)', identity VARCHAR(191) NOT NULL, password VARCHAR(191) NOT NULL, status ENUM('pending', 'active'), isDeleted TINYINT(1) NOT NULL, hash VARCHAR(64) NOT NULL, created DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', updated DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)', UNIQUE INDEX UNIQ_8D93D6496A95E9C4 (identity), UNIQUE INDEX UNIQ_8D93D649D1B862B8 (hash), PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB");
$this->addSql("CREATE TABLE user_roles (userUuid BINARY(16) NOT NULL COMMENT '(DC2Type:uuid_binary_ordered_time)', roleUuid BINARY(16) NOT NULL COMMENT '(DC2Type:uuid_binary_ordered_time)', INDEX IDX_54FCD59FD73087E9 (userUuid), INDEX IDX_54FCD59F88446210 (roleUuid), PRIMARY KEY(userUuid, roleUuid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB");
$this->addSql("CREATE TABLE user_avatar (uuid BINARY(16) NOT NULL COMMENT '(DC2Type:uuid_binary_ordered_time)', name VARCHAR(191) NOT NULL, created DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', updated DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)', userUuid BINARY(16) NOT NULL COMMENT '(DC2Type:uuid_binary_ordered_time)', UNIQUE INDEX UNIQ_73256912D73087E9 (userUuid), PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB");
$this->addSql("CREATE TABLE user_detail (uuid BINARY(16) NOT NULL COMMENT '(DC2Type:uuid_binary_ordered_time)', firstName VARCHAR(191) DEFAULT NULL, lastName VARCHAR(191) DEFAULT NULL, created DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', updated DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)', userUuid BINARY(16) NOT NULL COMMENT '(DC2Type:uuid_binary_ordered_time)', UNIQUE INDEX UNIQ_4B5464AED73087E9 (userUuid), PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB");
$this->addSql("CREATE TABLE user_remember_me (uuid BINARY(16) NOT NULL COMMENT '(DC2Type:uuid_binary_ordered_time)', rememberMeToken VARCHAR(100) NOT NULL, userAgent TEXT NOT NULL, expireDate DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', created DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', updated DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)', userUuid BINARY(16) NOT NULL COMMENT '(DC2Type:uuid_binary_ordered_time)', UNIQUE INDEX UNIQ_D3E96EBD1BBB86A0 (rememberMeToken), INDEX IDX_D3E96EBDD73087E9 (userUuid), PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB");
$this->addSql("CREATE TABLE user_reset_password (uuid BINARY(16) NOT NULL COMMENT '(DC2Type:uuid_binary_ordered_time)', expires DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', hash VARCHAR(64) NOT NULL, status VARCHAR(20) NOT NULL, created DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', updated DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)', userUuid BINARY(16) NOT NULL COMMENT '(DC2Type:uuid_binary_ordered_time)', UNIQUE INDEX UNIQ_D21DE3BCD1B862B8 (hash), INDEX IDX_D21DE3BCD73087E9 (userUuid), PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB");
$this->addSql("CREATE TABLE user_role (uuid BINARY(16) NOT NULL COMMENT '(DC2Type:uuid_binary_ordered_time)', name VARCHAR(30) NOT NULL, created DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', updated DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)', UNIQUE INDEX UNIQ_2DE8C6A35E237E06 (name), PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB");
$this->addSql('ALTER TABLE user_roles ADD CONSTRAINT FK_54FCD59FD73087E9 FOREIGN KEY (userUuid) REFERENCES user (uuid)');
$this->addSql('ALTER TABLE user_roles ADD CONSTRAINT FK_54FCD59F88446210 FOREIGN KEY (roleUuid) REFERENCES user_role (uuid)');
$this->addSql('ALTER TABLE user_avatar ADD CONSTRAINT FK_73256912D73087E9 FOREIGN KEY (userUuid) REFERENCES user (uuid)');
Expand Down
7 changes: 2 additions & 5 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,20 @@
}

chdir(dirname(__DIR__));
require 'vendor/autoload.php';
require __DIR__ . '/vendor/autoload.php';

/**
* Self-called anonymous function that creates its own scope and keep the global namespace clean.
*/
(function () {
(static function () : void {
/** @var ContainerInterface $container */
$container = require 'config/container.php';

/** @var Application $app */
$app = $container->get(Application::class);
$factory = $container->get(MiddlewareFactory::class);

// Execute programmatic/declarative middleware pipeline and routing
// configuration statements
(require 'config/pipeline.php')($app, $factory, $container);
(require 'config/routes.php')($app, $factory, $container);

$app->run();
})();
36 changes: 36 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/bin',
__DIR__ . '/config',
__DIR__ . '/data',
__DIR__ . '/public',
__DIR__ . '/src',
__DIR__ . '/test',
]);

$rectorConfig->skip([
__DIR__ . '/data/cache',
]);

// define sets of rules
$rectorConfig->sets([
SetList::ACTION_INJECTION_TO_CONSTRUCTOR_INJECTION,
SetList::PHP_81,
SetList::PHP_82,
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
SetList::DEAD_CODE,
SetList::EARLY_RETURN,
SetList::NAMING,
SetList::PRIVATIZATION,
SetList::PSR_4,
SetList::TYPE_DECLARATION,
]);
};
4 changes: 2 additions & 2 deletions src/App/src/Common/AbstractEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public function __construct()
/**
* Exchange internal values from provided array
*
* @param array $data
* @return void
*/
public function exchangeArray(array $data): void
{
Expand All @@ -39,6 +37,7 @@ public function exchangeArray(array $data): void
if (!method_exists($this, $method)) {
continue;
}

foreach ($values as $value) {
$this->$method($value);
}
Expand All @@ -47,6 +46,7 @@ public function exchangeArray(array $data): void
if (!method_exists($this, $method)) {
continue;
}

$this->$method($values);
}
}
Expand Down
Loading