Skip to content

Commit

Permalink
Merge pull request #24 from wayofdev/refactor/structure
Browse files Browse the repository at this point in the history
  • Loading branch information
lotyp authored Aug 1, 2024
2 parents b4144e0 + bc20e70 commit 46b1cea
Show file tree
Hide file tree
Showing 47 changed files with 219 additions and 49 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion app/.php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
18 changes: 9 additions & 9 deletions app/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -30,4 +29,5 @@
}

$code = (int) $app->serve();

exit($code);
2 changes: 1 addition & 1 deletion app/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"prefer-stable": true,
"autoload": {
"psr-4": {
"App\\": "app/src"
"App\\": "src"
}
},
"autoload-dev": {
Expand Down
22 changes: 11 additions & 11 deletions app/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/app/config/cache.php → app/config/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
'file' => [
// Alias for FileStorage type
'type' => 'file',
'path' => directory('runtime') . 'cache',
'path' => directory('runtime') . 'Cache',
],
],

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/app/config/session.php → app/config/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
'handler' => new Autowire(
FileHandler::class,
[
'directory' => directory('runtime') . 'session',
'directory' => directory('runtime') . 'Session',
'lifetime' => (int) env('SESSION_LIFETIME', 86400),
]
),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/pest.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</testsuites>
<source>
<include>
<directory>app/src</directory>
<directory>src</directory>
</include>
</source>
<php>
Expand Down
131 changes: 131 additions & 0 deletions app/phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions app/phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -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/
2 changes: 1 addition & 1 deletion app/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</logging>
<source>
<include>
<directory>app/src</directory>
<directory>src</directory>
</include>
</source>
<php>
Expand Down
Loading

0 comments on commit 46b1cea

Please sign in to comment.