Skip to content

Commit b2ebce6

Browse files
author
dmitriy
committed
refactoring
1 parent bb330a6 commit b2ebce6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+316
-263
lines changed

composer.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@
8888
"ergebnis/composer-normalize": "^2.3",
8989
"roave/security-advisories": "dev-master",
9090
"symfony/debug-pack": "*",
91-
"symfony/maker-bundle": "^1.14",
92-
"symfony/profiler-pack": "*",
91+
"symfony/maker-bundle": "^1.15",
9392
"symfony/requirements-checker": "^1.1"
9493
},
9594
"config": {
@@ -119,7 +118,6 @@
119118
"psr-4": {
120119
"App\\Tests\\": "tests/",
121120
"PHPUnit\\": "tools/01_phpunit/vendor/phpunit/phpunit/src/",
122-
"PHPUnit\\Framework\\MockObject\\": "tools/01_phpunit/vendor/phpunit/phpunit/src/Framework/MockObject/ForwardCompatibility",
123121
"Symfony\\Component\\BrowserKit\\": "tools/01_phpunit/vendor/symfony/browser-kit",
124122
"Symfony\\Bridge\\PhpUnit\\": "tools/01_phpunit/vendor/symfony/phpunit-bridge"
125123
}

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/services.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
66
parameters:
77
locale: 'en'
8-
app.uuid_regex: '^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-1[0-9a-fA-F]{3}\-[89ab][0-9a-f]{3}\-[0-9a-fA-F]{12}$'
8+
app.uuid_v1_regex: '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-1[0-9a-fA-F]{3}-[89abAB][0-9a-f]{3}-[0-9a-fA-F]{12}$'
9+
app.uuid_v4_regex: '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-f]{3}-[0-9a-fA-F]{12}$'
910

1011
services:
1112
# default configuration for services in *this* file
@@ -18,7 +19,8 @@ services:
1819
bind:
1920
$projectDir: '%kernel.project_dir%'
2021
$environment: '%kernel.environment%'
21-
$uuidRegex: '%app.uuid_regex%'
22+
$uuidV1Regex: '%app.uuid_v1_regex%'
23+
$uuidV4Regex: '%app.uuid_v4_regex%'
2224
$locale: '%locale%'
2325
_instanceof:
2426
App\Rest\Interfaces\ControllerInterface:

docker/dev/nginx.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ server {
5252
}
5353

5454
location ~ \.php$ {
55+
proxy_set_header X-Real-IP $remote_addr;
56+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
5557
try_files $uri =404;
5658
fastcgi_split_path_info ^(.+\.php)(/.+)$;
5759
fastcgi_pass symfony:9000;

docker/prod/nginx.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ server {
5252
}
5353

5454
location ~ \.php$ {
55+
proxy_set_header X-Real-IP $remote_addr;
56+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
5557
try_files $uri =404;
5658
fastcgi_split_path_info ^(.+\.php)(/.+)$;
5759
fastcgi_pass symfony:9000;

docker/test/nginx.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ server {
5252
}
5353

5454
location ~ \.php$ {
55+
proxy_set_header X-Real-IP $remote_addr;
56+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
5557
try_files $uri =404;
5658
fastcgi_split_path_info ^(.+\.php)(/.+)$;
5759
fastcgi_pass symfony:9000;

src/Collection/Traits/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function getAll(): IteratorAggregate
8181
*/
8282
public function has(?string $className = null): bool
8383
{
84-
return $className === null ? false : $this->getFilteredItem($className) !== null;
84+
return $this->getFilteredItem($className ?? '') !== null;
8585
}
8686

8787
/**

src/Command/Traits/ExecuteMultipleCommand.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ trait ExecuteMultipleCommand
2222
// Traits
2323
use GetApplication;
2424

25+
/**
26+
* @var array<int|string, string>
27+
*/
2528
private array $choices = [];
2629
/**
2730
* @psalm-suppress PropertyNotSetInConstructor
@@ -31,14 +34,13 @@ trait ExecuteMultipleCommand
3134
/**
3235
* Setter method for choices to use.
3336
*
34-
* @param array $choices
37+
* @param array<int|string, string> $choices
3538
*/
3639
protected function setChoices(array $choices): void
3740
{
3841
$this->choices = $choices;
3942
}
4043

41-
/** @noinspection PhpMissingParentCallCommonInspection */
4244
/**
4345
* Executes the current command.
4446
*
@@ -53,30 +55,31 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5355
{
5456
$this->io = new SymfonyStyle($input, $output);
5557
$this->io->write("\033\143");
58+
$command = $this->ask();
5659

57-
/** @noinspection PhpAssignmentInConditionInspection */
58-
while ($command = $this->ask()) {
60+
while ($command !== null) {
5961
$arguments = [
6062
'command' => $command,
6163
];
6264
$input = new ArrayInput($arguments);
63-
$cmd = $this->getApplication()->find((string)$command);
64-
$cmd->run($input, $output);
65+
$cmd = $this->getApplication()->find($command);
66+
$outputValue = $cmd->run($input, $output);
67+
$command = $this->ask();
6568
}
6669

6770
if ($input->isInteractive()) {
6871
$this->io->success('Have a nice day');
6972
}
7073

71-
return 0;
74+
return $outputValue ?? 0;
7275
}
7376

7477
/**
7578
* Method to ask user to make choose one of defined choices.
7679
*
77-
* @return string|bool
80+
* @return string|null
7881
*/
79-
private function ask()
82+
private function ask(): ?string
8083
{
8184
$index = array_search(
8285
$this->io->choice('What you want to do', array_values($this->choices)),
@@ -85,6 +88,6 @@ private function ask()
8588
);
8689
$choice = (string)array_values(array_flip($this->choices))[(int)$index];
8790

88-
return $choice === '0' ? false : $choice;
91+
return $choice === '0' ? null : $choice;
8992
}
9093
}

src/Command/Traits/GetApplication.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ trait GetApplication
2525
public function getApplication(): Application
2626
{
2727
if (!($this instanceof Command)) {
28-
throw new \RuntimeException('This trait ' . __TRAIT__ . ' is only mentioned to use with console commands.');
28+
throw new RuntimeException('This trait ' . __TRAIT__ . ' is only mentioned to use with console commands.');
2929
}
3030

3131
/** @noinspection PhpUndefinedClassInspection */

src/Command/Utils/CheckDependencies.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
namespace App\Command\Utils;
88

99
use Symfony\Component\Console\Command\Command;
10+
use Symfony\Component\Console\Exception\RuntimeException;
1011
use App\Command\Traits\StyleSymfony;
1112
use LogicException;
1213
use Symfony\Component\Console\Input\InputInterface;
1314
use Symfony\Component\Console\Output\OutputInterface;
1415
use InvalidArgumentException;
15-
use RuntimeException;
1616
use SplFileInfo;
1717
use stdClass;
1818
use Symfony\Component\Console\Helper\ProgressBar;

0 commit comments

Comments
 (0)