diff --git a/Makefile b/Makefile index c015ee0..92e1163 100644 --- a/Makefile +++ b/Makefile @@ -175,6 +175,10 @@ purge: ## Stops and removes containers, volumes, networks and images restart: down up ## Runs down and up commands .PHONY: restart +restart-app: ## Restarts app container + $(DOCKER_COMPOSE) restart app +.PHONY: restart-app + clean: ## Stops and removes containers of this project together with volumes $(DOCKER_COMPOSE) rm --force --stop --volumes .PHONY: clean diff --git a/app/.php-cs-fixer.dist.php b/app/.php-cs-fixer.dist.php index 5284167..0d088a9 100644 --- a/app/.php-cs-fixer.dist.php +++ b/app/.php-cs-fixer.dist.php @@ -8,12 +8,15 @@ require_once 'vendor/autoload.php'; $config = ConfigBuilder::createFromRuleSet(new DefaultSet(['static_lambda' => false])) - ->inDir(__DIR__ . '/app') + ->inDir(__DIR__ . '/config') + ->inDir(__DIR__ . '/migrations') + ->inDir(__DIR__ . '/src') ->inDir(__DIR__ . '/tests') ->addFiles([ __FILE__, __DIR__ . '/functions.php', __DIR__ . '/app.php', + __DIR__ . '/rector.php', ]) ->useParallelConfig() ->getConfig() diff --git a/app/app.php b/app/app.php index b47893b..de48676 100644 --- a/app/app.php +++ b/app/app.php @@ -5,23 +5,22 @@ use App\Application\Exception\Handler; use App\Application\Kernel; -// If you forgot to configure some of this in your php.ini file, -// then don't worry, we will set the standard environment -// settings for you. - mb_internal_encoding('UTF-8'); error_reporting((E_ALL | E_STRICT) ^ E_DEPRECATED); ini_set('display_errors', 'stderr'); -// Application helper functions. Must be included before the composer autoloader. require __DIR__ . '/functions.php'; - -// Register Composer's auto loader. require __DIR__ . '/vendor/autoload.php'; -// Initialize shared container, bindings, directories and etc. $app = Kernel::create( - directories: ['root' => __DIR__], + directories: [ + 'root' => __DIR__, + 'app' => __DIR__ . '/src', + 'config' => __DIR__ . '/config', + 'public' => __DIR__ . '/public', + 'runtime' => __DIR__ . '/runtime', + 'views' => __DIR__ . '/views', + ], exceptionHandler: Handler::class, )->run(); @@ -30,4 +29,5 @@ } $code = (int) $app->serve(); + exit($code); diff --git a/app/composer.json b/app/composer.json index de2ce95..da4526a 100644 --- a/app/composer.json +++ b/app/composer.json @@ -84,7 +84,7 @@ "prefer-stable": true, "autoload": { "psr-4": { - "App\\": "app/src" + "App\\": "src" } }, "autoload-dev": { diff --git a/app/composer.lock b/app/composer.lock index e744431..b61a057 100644 --- a/app/composer.lock +++ b/app/composer.lock @@ -10815,16 +10815,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.61.0", + "version": "v3.61.1", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "737a24b6d531db9c034ac97524ac3a3bde0c20c0" + "reference": "94a87189f55814e6cabca2d9a33b06de384a2ab8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/737a24b6d531db9c034ac97524ac3a3bde0c20c0", - "reference": "737a24b6d531db9c034ac97524ac3a3bde0c20c0", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/94a87189f55814e6cabca2d9a33b06de384a2ab8", + "reference": "94a87189f55814e6cabca2d9a33b06de384a2ab8", "shasum": "" }, "require": { @@ -10906,7 +10906,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.61.0" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.61.1" }, "funding": [ { @@ -10914,7 +10914,7 @@ "type": "github" } ], - "time": "2024-07-31T08:18:16+00:00" + "time": "2024-07-31T14:33:15+00:00" }, { "name": "hamcrest/hamcrest-php", @@ -12373,16 +12373,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.11.8", + "version": "1.11.9", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "6adbd118e6c0515dd2f36b06cde1d6da40f1b8ec" + "reference": "e370bcddadaede0c1716338b262346f40d296f82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/6adbd118e6c0515dd2f36b06cde1d6da40f1b8ec", - "reference": "6adbd118e6c0515dd2f36b06cde1d6da40f1b8ec", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e370bcddadaede0c1716338b262346f40d296f82", + "reference": "e370bcddadaede0c1716338b262346f40d296f82", "shasum": "" }, "require": { @@ -12427,7 +12427,7 @@ "type": "github" } ], - "time": "2024-07-24T07:01:22+00:00" + "time": "2024-08-01T16:25:18+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", diff --git a/app/app/config/cache.php b/app/config/cache.php similarity index 95% rename from app/app/config/cache.php rename to app/config/cache.php index 9ee13ff..615b8ca 100644 --- a/app/app/config/cache.php +++ b/app/config/cache.php @@ -44,7 +44,7 @@ 'file' => [ // Alias for FileStorage type 'type' => 'file', - 'path' => directory('runtime') . 'cache', + 'path' => directory('runtime') . 'Cache', ], ], diff --git a/app/app/config/cycle.php b/app/config/cycle.php similarity index 100% rename from app/app/config/cycle.php rename to app/config/cycle.php diff --git a/app/app/config/database.php b/app/config/database.php similarity index 100% rename from app/app/config/database.php rename to app/config/database.php diff --git a/app/app/config/mailer.php b/app/config/mailer.php similarity index 100% rename from app/app/config/mailer.php rename to app/config/mailer.php diff --git a/app/app/config/migration.php b/app/config/migration.php similarity index 100% rename from app/app/config/migration.php rename to app/config/migration.php diff --git a/app/app/config/queue.php b/app/config/queue.php similarity index 100% rename from app/app/config/queue.php rename to app/config/queue.php diff --git a/app/app/config/scaffolder.php b/app/config/scaffolder.php similarity index 100% rename from app/app/config/scaffolder.php rename to app/config/scaffolder.php diff --git a/app/app/config/session.php b/app/config/session.php similarity index 89% rename from app/app/config/session.php rename to app/config/session.php index 5d90ecc..ac2756e 100644 --- a/app/app/config/session.php +++ b/app/config/session.php @@ -18,7 +18,7 @@ 'handler' => new Autowire( FileHandler::class, [ - 'directory' => directory('runtime') . 'session', + 'directory' => directory('runtime') . 'Session', 'lifetime' => (int) env('SESSION_LIFETIME', 86400), ] ), diff --git a/app/app/config/storage.php b/app/config/storage.php similarity index 100% rename from app/app/config/storage.php rename to app/config/storage.php diff --git a/app/app/config/temporal.php b/app/config/temporal.php similarity index 100% rename from app/app/config/temporal.php rename to app/config/temporal.php diff --git a/app/app/migrations/.gitignore b/app/migrations/.gitignore similarity index 100% rename from app/app/migrations/.gitignore rename to app/migrations/.gitignore diff --git a/app/app/migrations/20230222.132457_0_0_default_create_users.php b/app/migrations/20230222.132457_0_0_default_create_users.php similarity index 100% rename from app/app/migrations/20230222.132457_0_0_default_create_users.php rename to app/migrations/20230222.132457_0_0_default_create_users.php diff --git a/app/pest.xml.dist b/app/pest.xml.dist index 71d3a8a..db1d89a 100644 --- a/app/pest.xml.dist +++ b/app/pest.xml.dist @@ -20,7 +20,7 @@ - app/src + src diff --git a/app/phpstan-baseline.neon b/app/phpstan-baseline.neon new file mode 100644 index 0000000..55dd25f --- /dev/null +++ b/app/phpstan-baseline.neon @@ -0,0 +1,131 @@ +parameters: + ignoreErrors: + - + message: "#^Parameter \\$port of class Cycle\\\\Database\\\\Config\\\\MySQL\\\\TcpConnectionConfig constructor expects int\\<1, max\\>\\|numeric\\-string, int given\\.$#" + count: 1 + path: config/database.php + + - + message: "#^Parameter \\$port of class Cycle\\\\Database\\\\Config\\\\Postgres\\\\TcpConnectionConfig constructor expects int\\<1, max\\>\\|numeric\\-string, int given\\.$#" + count: 1 + path: config/database.php + + - + message: "#^Method App\\\\Application\\\\Bootloader\\\\LoggingBootloader\\:\\:__construct\\(\\) has parameter \\$config with generic interface Spiral\\\\Config\\\\ConfiguratorInterface but does not specify its types\\: TClass$#" + count: 1 + path: src/Application/Bootloader/LoggingBootloader.php + + - + message: "#^Property App\\\\Application\\\\Bootloader\\\\LoggingBootloader\\:\\:\\$config is never read, only written\\.$#" + count: 1 + path: src/Application/Bootloader/LoggingBootloader.php + + - + message: "#^Method App\\\\Application\\\\Bootloader\\\\RoutesBootloader\\:\\:middlewareGroups\\(\\) return type with generic class Spiral\\\\Core\\\\Container\\\\Autowire does not specify its types\\: TObject$#" + count: 1 + path: src/Application/Bootloader/RoutesBootloader.php + + - + message: "#^Class App\\\\Domain\\\\User\\\\Entity\\\\User has an uninitialized readonly property \\$id\\. Assign it in the constructor\\.$#" + count: 1 + path: src/Domain/User/Entity/User.php + + - + message: "#^Property App\\\\Domain\\\\User\\\\Entity\\\\User\\:\\:\\$id is never written, only read\\.$#" + count: 1 + path: src/Domain/User/Entity/User.php + + - + message: "#^Class App\\\\Endpoint\\\\Console\\\\CreateUserCommand has an uninitialized readonly property \\$email\\. Assign it in the constructor\\.$#" + count: 1 + path: src/Endpoint/Console/CreateUserCommand.php + + - + message: "#^Class App\\\\Endpoint\\\\Console\\\\CreateUserCommand has an uninitialized readonly property \\$username\\. Assign it in the constructor\\.$#" + count: 1 + path: src/Endpoint/Console/CreateUserCommand.php + + - + message: "#^Property App\\\\Endpoint\\\\Console\\\\CreateUserCommand\\:\\:\\$email is never written, only read\\.$#" + count: 1 + path: src/Endpoint/Console/CreateUserCommand.php + + - + message: "#^Property App\\\\Endpoint\\\\Console\\\\CreateUserCommand\\:\\:\\$username is never written, only read\\.$#" + count: 1 + path: src/Endpoint/Console/CreateUserCommand.php + + - + message: "#^Class App\\\\Endpoint\\\\Console\\\\DoNothing has an uninitialized readonly property \\$name\\. Assign it in the constructor\\.$#" + count: 1 + path: src/Endpoint/Console/DoNothing.php + + - + message: "#^Property App\\\\Endpoint\\\\Console\\\\DoNothing\\:\\:\\$name is never written, only read\\.$#" + count: 1 + path: src/Endpoint/Console/DoNothing.php + + - + message: "#^Class App\\\\Endpoint\\\\Console\\\\PingCommand has an uninitialized readonly property \\$site\\. Assign it in the constructor\\.$#" + count: 1 + path: src/Endpoint/Console/PingCommand.php + + - + message: "#^Property App\\\\Endpoint\\\\Console\\\\PingCommand\\:\\:\\$site is never written, only read\\.$#" + count: 1 + path: src/Endpoint/Console/PingCommand.php + + - + message: "#^Method Spiral\\\\Logger\\\\LogsInterface\\:\\:getLogger\\(\\) invoked with 0 parameters, 1 required\\.$#" + count: 1 + path: src/Endpoint/Job/Ping.php + + - + message: "#^Method App\\\\Infrastructure\\\\CycleORM\\\\Typecaster\\\\UuidTypecast\\:\\:cast\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php + + - + message: "#^Method App\\\\Infrastructure\\\\CycleORM\\\\Typecaster\\\\UuidTypecast\\:\\:cast\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php + + - + message: "#^Method App\\\\Infrastructure\\\\CycleORM\\\\Typecaster\\\\UuidTypecast\\:\\:uncast\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php + + - + message: "#^Method App\\\\Infrastructure\\\\CycleORM\\\\Typecaster\\\\UuidTypecast\\:\\:uncast\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php + + - + message: "#^Property App\\\\Infrastructure\\\\CycleORM\\\\Typecaster\\\\UuidTypecast\\:\\:\\$database is never read, only written\\.$#" + count: 1 + path: src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php + + - + message: "#^Property App\\\\Infrastructure\\\\CycleORM\\\\Typecaster\\\\UuidTypecast\\:\\:\\$rules type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php + + - + message: "#^Method Spiral\\\\Logger\\\\LogsInterface\\:\\:getLogger\\(\\) invoked with 0 parameters, 1 required\\.$#" + count: 1 + path: src/Temporal/PaymentActivity.php + + - + message: "#^Method App\\\\Temporal\\\\PaymentWorkflowInterface\\:\\:start\\(\\) has no return type specified\\.$#" + count: 1 + path: src/Temporal/PaymentWorkflowInterface.php + + - + message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFalse\\(\\) with false will always evaluate to true\\.$#" + count: 1 + path: tests/Unit/DemoTest.php + + - + message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertTrue\\(\\) with true will always evaluate to true\\.$#" + count: 1 + path: tests/Unit/DemoTest.php diff --git a/app/phpstan.neon.dist b/app/phpstan.neon.dist new file mode 100644 index 0000000..ec081f3 --- /dev/null +++ b/app/phpstan.neon.dist @@ -0,0 +1,13 @@ +includes: + - phpstan-baseline.neon +parameters: + # The level 9 is the highest level + level: 8 + paths: + - config/ + - migrations/ + - src/ + - tests/ + excludePaths: + - tests/src/Arch + tmpDir: .build/phpstan/ diff --git a/app/phpunit.xml.dist b/app/phpunit.xml.dist index 4e47d9e..fbe2024 100644 --- a/app/phpunit.xml.dist +++ b/app/phpunit.xml.dist @@ -33,7 +33,7 @@ - app/src + src diff --git a/app/psalm-baseline.xml b/app/psalm-baseline.xml index e436083..bb3ba94 100644 --- a/app/psalm-baseline.xml +++ b/app/psalm-baseline.xml @@ -1,18 +1,26 @@ - + + + + + + dump((new VarCloner())->cloneVar($var), true)]]> + + + - + - + @@ -21,37 +29,37 @@ - + - + - + - + - + - + - + @@ -60,12 +68,12 @@ - + - + @@ -82,7 +90,7 @@ - + @@ -91,12 +99,12 @@ - + - + @@ -104,18 +112,19 @@ - - - - - - dump((new VarCloner())->cloneVar($var), true)]]> - + + + + + + + + @@ -123,6 +132,9 @@ + + + diff --git a/app/psalm.xml b/app/psalm.xml index f32bdf0..68b4e34 100644 --- a/app/psalm.xml +++ b/app/psalm.xml @@ -16,7 +16,7 @@ - + diff --git a/app/app/src/Application/Bootloader/AppBootloader.php b/app/src/Application/Bootloader/AppBootloader.php similarity index 100% rename from app/app/src/Application/Bootloader/AppBootloader.php rename to app/src/Application/Bootloader/AppBootloader.php diff --git a/app/app/src/Application/Bootloader/ExceptionHandlerBootloader.php b/app/src/Application/Bootloader/ExceptionHandlerBootloader.php similarity index 100% rename from app/app/src/Application/Bootloader/ExceptionHandlerBootloader.php rename to app/src/Application/Bootloader/ExceptionHandlerBootloader.php diff --git a/app/app/src/Application/Bootloader/LoggingBootloader.php b/app/src/Application/Bootloader/LoggingBootloader.php similarity index 100% rename from app/app/src/Application/Bootloader/LoggingBootloader.php rename to app/src/Application/Bootloader/LoggingBootloader.php diff --git a/app/app/src/Application/Bootloader/PersistenceBootloader.php b/app/src/Application/Bootloader/PersistenceBootloader.php similarity index 100% rename from app/app/src/Application/Bootloader/PersistenceBootloader.php rename to app/src/Application/Bootloader/PersistenceBootloader.php diff --git a/app/app/src/Application/Bootloader/RoutesBootloader.php b/app/src/Application/Bootloader/RoutesBootloader.php similarity index 100% rename from app/app/src/Application/Bootloader/RoutesBootloader.php rename to app/src/Application/Bootloader/RoutesBootloader.php diff --git a/app/app/src/Application/Exception/Handler.php b/app/src/Application/Exception/Handler.php similarity index 100% rename from app/app/src/Application/Exception/Handler.php rename to app/src/Application/Exception/Handler.php diff --git a/app/app/src/Application/Kernel.php b/app/src/Application/Kernel.php similarity index 100% rename from app/app/src/Application/Kernel.php rename to app/src/Application/Kernel.php diff --git a/app/app/src/Domain/User/Entity/User.php b/app/src/Domain/User/Entity/User.php similarity index 100% rename from app/app/src/Domain/User/Entity/User.php rename to app/src/Domain/User/Entity/User.php diff --git a/app/app/src/Domain/User/Exception/UserNotFoundException.php b/app/src/Domain/User/Exception/UserNotFoundException.php similarity index 100% rename from app/app/src/Domain/User/Exception/UserNotFoundException.php rename to app/src/Domain/User/Exception/UserNotFoundException.php diff --git a/app/app/src/Domain/User/Repository/UserRepositoryInterface.php b/app/src/Domain/User/Repository/UserRepositoryInterface.php similarity index 100% rename from app/app/src/Domain/User/Repository/UserRepositoryInterface.php rename to app/src/Domain/User/Repository/UserRepositoryInterface.php diff --git a/app/app/src/Domain/User/Service/CreateUserService.php b/app/src/Domain/User/Service/CreateUserService.php similarity index 100% rename from app/app/src/Domain/User/Service/CreateUserService.php rename to app/src/Domain/User/Service/CreateUserService.php diff --git a/app/app/src/Endpoint/Console/CreateUserCommand.php b/app/src/Endpoint/Console/CreateUserCommand.php similarity index 100% rename from app/app/src/Endpoint/Console/CreateUserCommand.php rename to app/src/Endpoint/Console/CreateUserCommand.php diff --git a/app/app/src/Endpoint/Console/DoNothing.php b/app/src/Endpoint/Console/DoNothing.php similarity index 100% rename from app/app/src/Endpoint/Console/DoNothing.php rename to app/src/Endpoint/Console/DoNothing.php diff --git a/app/app/src/Endpoint/Console/PingCommand.php b/app/src/Endpoint/Console/PingCommand.php similarity index 100% rename from app/app/src/Endpoint/Console/PingCommand.php rename to app/src/Endpoint/Console/PingCommand.php diff --git a/app/app/src/Endpoint/Job/Ping.php b/app/src/Endpoint/Job/Ping.php similarity index 100% rename from app/app/src/Endpoint/Job/Ping.php rename to app/src/Endpoint/Job/Ping.php diff --git a/app/app/src/Endpoint/Web/HomeController.php b/app/src/Endpoint/Web/HomeController.php similarity index 100% rename from app/app/src/Endpoint/Web/HomeController.php rename to app/src/Endpoint/Web/HomeController.php diff --git a/app/app/src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php b/app/src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php similarity index 100% rename from app/app/src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php rename to app/src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php diff --git a/app/app/src/Infrastructure/Persistence/CycleORMUserRepository.php b/app/src/Infrastructure/Persistence/CycleORMUserRepository.php similarity index 100% rename from app/app/src/Infrastructure/Persistence/CycleORMUserRepository.php rename to app/src/Infrastructure/Persistence/CycleORMUserRepository.php diff --git a/app/app/src/Temporal/PaymentActivity.php b/app/src/Temporal/PaymentActivity.php similarity index 100% rename from app/app/src/Temporal/PaymentActivity.php rename to app/src/Temporal/PaymentActivity.php diff --git a/app/app/src/Temporal/PaymentActivityInterface.php b/app/src/Temporal/PaymentActivityInterface.php similarity index 100% rename from app/app/src/Temporal/PaymentActivityInterface.php rename to app/src/Temporal/PaymentActivityInterface.php diff --git a/app/app/src/Temporal/PaymentWorkflow.php b/app/src/Temporal/PaymentWorkflow.php similarity index 100% rename from app/app/src/Temporal/PaymentWorkflow.php rename to app/src/Temporal/PaymentWorkflow.php diff --git a/app/app/src/Temporal/PaymentWorkflowInterface.php b/app/src/Temporal/PaymentWorkflowInterface.php similarity index 100% rename from app/app/src/Temporal/PaymentWorkflowInterface.php rename to app/src/Temporal/PaymentWorkflowInterface.php diff --git a/app/tests/TestCase.php b/app/tests/TestCase.php index f8737be..4d125a4 100644 --- a/app/tests/TestCase.php +++ b/app/tests/TestCase.php @@ -36,6 +36,8 @@ protected function setUp(): void protected function tearDown(): void { + parent::tearDown(); + // Uncomment this line if you want to clean up runtime directory. // $this->cleanUpRuntimeDirectory(); } @@ -62,6 +64,11 @@ public function defineDirectories(string $root): array { return [ 'root' => $root, + 'app' => $root . '/src', + 'config' => $root . '/config', + 'public' => $root . '/public', + 'runtime' => $root . '/runtime', + 'views' => $root . '/views', ]; } } diff --git a/app/app/views/home.php b/app/views/home.php similarity index 100% rename from app/app/views/home.php rename to app/views/home.php