Skip to content

Commit dfa22a7

Browse files
committedApr 21, 2023
Update Style
1 parent 9209a08 commit dfa22a7

22 files changed

+178
-211
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@
2828
/app/phpunit.xml
2929
/composer.phar
3030
/coverage/
31+
/.phpunit.result.cache

‎.php-cs-fixer.dist.php

+45-23
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,60 @@
22

33
declare(strict_types=1);
44

5-
$finder = PhpCsFixer\Finder::create()
5+
/*
6+
* @see https://mlocati.github.io/php-cs-fixer-configurator/#version:3.15
7+
* @see https://cs.symfony.com/doc/rules/index.html
8+
* @see https://cs.symfony.com/doc/ruleSets/index.html
9+
*/
10+
11+
$finder = \PhpCsFixer\Finder::create()
612
->exclude('vendor')
713
->exclude('mock')
814
->exclude('DNC')
15+
->notPath('phpstan-baseline.php')
916
->in(__DIR__);
1017

11-
$config = new PhpCsFixer\Config();
18+
$config = new \PhpCsFixer\Config();
1219
$config->setRiskyAllowed(true)
13-
->setRules( // @see https://mlocati.github.io/php-cs-fixer-configurator/#version:3.2
20+
->setRules(
1421
[
15-
'@PSR2' => true,
16-
'@Symfony' => true,
17-
'@PhpCsFixer' => true,
18-
'@PhpCsFixer:risky' => true,
19-
'@PHPUnit75Migration:risky' => true,
20-
'@PHP73Migration' => true,
21-
'@PHP71Migration:risky' => true,
22-
'php_unit_dedicate_assert' => ['target' => '5.6'],
23-
'array_syntax' => ['syntax' => 'short'],
24-
'no_superfluous_phpdoc_tags' => true,
25-
'native_function_invocation' => false,
26-
'concat_space' => ['spacing' => 'one'],
27-
'phpdoc_types_order' => ['null_adjustment' => 'always_first', 'sort_algorithm' => 'alpha'],
28-
'single_line_comment_style' => [
29-
'comment_types' => ['hash'],
30-
],
31-
'phpdoc_summary' => false,
32-
'cast_spaces' => ['space' => 'none'],
33-
'binary_operator_spaces' => ['default' => null, 'operators' => ['=' => 'align_single_space_minimal', '=>' => 'align_single_space_minimal']],
34-
'php_unit_test_class_requires_covers' => false,
22+
'@PER' => true,
23+
'@Symfony' => true,
24+
'@PhpCsFixer' => true,
25+
'@PhpCsFixer:risky' => true,
26+
'@PHPUnit100Migration:risky' => true,
27+
// '@PHP80Migration:risky' => true,
28+
'@PHP82Migration' => true,
29+
'no_superfluous_phpdoc_tags' => true,
30+
'native_function_invocation' => false,
31+
'concat_space' => ['spacing' => 'one'],
32+
'phpdoc_types_order' => ['null_adjustment' => 'always_first', 'sort_algorithm' => 'alpha'],
33+
'single_line_comment_style' => ['comment_types' => [ /* 'hash' */],],
34+
'phpdoc_summary' => false,
35+
'cast_spaces' => ['space' => 'none'],
36+
'binary_operator_spaces' => ['default' => null, 'operators' => ['=' => 'align_single_space_minimal', '=>' => 'align_single_space_minimal_by_scope']],
37+
'no_unused_imports' => true,
38+
'ordered_imports' => ['sort_algorithm' => 'alpha', 'imports_order' => ['const', 'class', 'function']],
39+
'control_structure_braces' => true,
40+
'control_structure_continuation_position' => true,
41+
'date_time_create_from_format_call' => true,
42+
'date_time_immutable' => true,
43+
'nullable_type_declaration_for_default_null_value' => true,
44+
'phpdoc_line_span' => ['const' => 'single', 'method' => 'single', 'property' => 'single'],
45+
'simplified_null_return' => true,
46+
'statement_indentation' => true,
47+
'blank_line_before_statement' => ['statements' => ['continue', 'declare', 'default', 'exit', 'goto', 'include', 'include_once', 'require', 'require_once', 'return', 'switch']],
3548
]
3649
)
3750
->setFinder($finder);
3851

52+
if (false) {
53+
$resolver = new \PhpCsFixer\Console\ConfigurationResolver($config, [], '', new \PhpCsFixer\ToolInfo());
54+
echo "\n\n# DUMPING EFFECTIVE RULES #################\n";
55+
var_export($resolver->getRules());
56+
echo "\n\n###########################################\n";
57+
58+
die();
59+
}
60+
3961
return $config;

‎src/Adapter/BodyStreamHook.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace brnc\Symfony1\Message\Adapter;
66

77
use Psr\Http\Message\StreamInterface;
8-
use ReflectionObject;
98

109
class BodyStreamHook
1110
{
@@ -18,9 +17,7 @@ public function __construct(\sfWebResponse $sfWebResponse)
1817
$this->connect($sfWebResponse);
1918
}
2019

21-
/**
22-
* picks the specified Response's BodyStream to be send when sfWebResponse->send() or ->sendContent() is called
23-
*/
20+
/** picks the specified Response's BodyStream to be send when sfWebResponse->send() or ->sendContent() is called */
2421
public function distinguishResponse(Response $response): void
2522
{
2623
$distinguishedId = $this->getObjectIdentifier($response);
@@ -67,7 +64,7 @@ private function getObjectIdentifier(Response $response): string
6764
private function connect(\sfWebResponse $sfWebResponse): void
6865
{
6966
// Use reflection
70-
$reflexiveWebResponse = new ReflectionObject($sfWebResponse);
67+
$reflexiveWebResponse = new \ReflectionObject($sfWebResponse);
7168
$dispatcherRetriever = $reflexiveWebResponse->getProperty('dispatcher');
7269
$dispatcherRetriever->setAccessible(true);
7370
/** @var null|\sfEventDispatcher $dispatcher */

‎src/Adapter/CommonAdapterTrait.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ trait CommonAdapterTrait
2929
* @param string $name
3030
* @param string|string[] $value
3131
*
32+
* @return static
33+
*
3234
* @throws \InvalidArgumentException
3335
* @throws \ReflectionException
34-
*
35-
* @return static
3636
*/
3737
public function withAddedHeader($name, $value)
3838
{
@@ -61,10 +61,10 @@ public function withAddedHeader($name, $value)
6161
* @param string $name
6262
* @param string|string[] $value
6363
*
64+
* @return static
65+
*
6466
* @throws \InvalidArgumentException
6567
* @throws \ReflectionException
66-
*
67-
* @return static
6868
*/
6969
public function withHeader($name, $value)
7070
{
@@ -76,9 +76,7 @@ public function withHeader($name, $value)
7676
return $new;
7777
}
7878

79-
/**
80-
* @throws \InvalidArgumentException
81-
*/
79+
/** @throws \InvalidArgumentException */
8280
public function getBody(): StreamInterface
8381
{
8482
return $this->body ?? Utils::streamFor();

‎src/Adapter/Request.php

+29-48
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Psr\Http\Message\ServerRequestInterface;
1616
use Psr\Http\Message\StreamInterface;
1717
use Psr\Http\Message\UriInterface;
18-
use ReflectionObject;
1918

2019
/**
2120
* TODO
@@ -92,8 +91,6 @@ public function __clone()
9291
* @param array<string, bool> $options
9392
*
9493
* @throws \InvalidArgumentException
95-
*
96-
* @return Request
9794
*/
9895
public static function fromSfWebRequest(\sfWebRequest $sfWebRequest, array $options = []): self
9996
{
@@ -118,9 +115,7 @@ public static function fromSfWebRequest(\sfWebRequest $sfWebRequest, array $opti
118115
return $new;
119116
}
120117

121-
/**
122-
* @deprecated Avoid this at all costs! It only serves as a last resort!
123-
*/
118+
/** @deprecated Avoid this at all costs! It only serves as a last resort! */
124119
public function getSfWebRequest(): \sfWebRequest
125120
{
126121
return $this->sfWebRequest;
@@ -137,10 +132,10 @@ public function getProtocolVersion(): string
137132
/**
138133
* @param string $version
139134
*
140-
* @throws \ReflectionException
141-
*
142135
* @return static
143136
*
137+
* @throws \ReflectionException
138+
*
144139
* @deprecated Will modify sfWebRequest even though it has no intrinsic support for this
145140
*/
146141
public function withProtocolVersion($version): self
@@ -154,9 +149,7 @@ public function withProtocolVersion($version): self
154149
return $new;
155150
}
156151

157-
/**
158-
* @return string[][]
159-
*/
152+
/** @return string[][] */
160153
public function getHeaders(): array
161154
{
162155
$headers = [];
@@ -197,9 +190,9 @@ public function hasHeader($name): bool
197190
/**
198191
* @param string $name
199192
*
200-
* @throws \InvalidArgumentException
201-
*
202193
* @return string[]
194+
*
195+
* @throws \InvalidArgumentException
203196
*/
204197
public function getHeader($name): array
205198
{
@@ -225,11 +218,11 @@ public function getHeaderLine($name): string
225218
/**
226219
* @param string $name
227220
*
221+
* @return static
222+
*
228223
* @throws \InvalidArgumentException
229224
* @throws \ReflectionException
230225
*
231-
* @return static
232-
*
233226
* @deprecated Will modify sfWebRequest even though it has no intrinsic support for this
234227
*/
235228
public function withoutHeader($name): self
@@ -289,9 +282,7 @@ public function withRequestTarget($requestTarget): self
289282
return $new;
290283
}
291284

292-
/**
293-
* {@inheritdoc}
294-
*/
285+
/** {@inheritdoc} */
295286
public function getMethod(): string
296287
{
297288
$method = $this->sfWebRequest->getMethod();
@@ -307,9 +298,9 @@ public function getMethod(): string
307298
*
308299
* @psalm-param mixed $method
309300
*
310-
* @throws InvalidTypeException
311-
*
312301
* @return static
302+
*
303+
* @throws InvalidTypeException
313304
*/
314305
public function withMethod($method): self
315306
{
@@ -329,12 +320,12 @@ public function getUri(): UriInterface
329320
/**
330321
* @param bool $preserveHost
331322
*
323+
* @return static
324+
*
332325
* @throws LogicException
333326
* @throws \InvalidArgumentException
334327
* @throws \ReflectionException
335328
*
336-
* @return static
337-
*
338329
* @deprecated Will not alter sfWebRequest! Will crash on Symfony compatibility mode if `$preserveHost === true`!
339330
*/
340331
public function withUri(UriInterface $uri, $preserveHost = false): self
@@ -376,10 +367,10 @@ public function getCookieParams(): array
376367
/**
377368
* @param array<array-key, mixed>|string[] $cookies
378369
*
379-
* @throws LogicException
380-
*
381370
* @return static
382371
*
372+
* @throws LogicException
373+
*
383374
* @deprecated Will not alter sfWebRequest! Will crash on Symfony compatibility mode!
384375
*/
385376
public function withCookieParams(array $cookies): self
@@ -390,9 +381,7 @@ public function withCookieParams(array $cookies): self
390381
return $new;
391382
}
392383

393-
/**
394-
* @return array<array-key, array<array-key, mixed>|mixed|string>
395-
*/
384+
/** @return array<array-key, array<array-key, mixed>|mixed|string> */
396385
public function getQueryParams(): array
397386
{
398387
return $this->queryParams ?? $this->sfWebRequest->getGetParameters();
@@ -401,10 +390,10 @@ public function getQueryParams(): array
401390
/**
402391
* @param array<array-key, mixed> $query
403392
*
404-
* @throws LogicException
405-
*
406393
* @return static
407394
*
395+
* @throws LogicException
396+
*
408397
* @deprecated Will not alter sfWebRequest! Will crash on Symfony compatibility mode!
409398
*/
410399
public function withQueryParams(array $query): self
@@ -416,9 +405,9 @@ public function withQueryParams(array $query): self
416405
}
417406

418407
/**
419-
* @throws \LogicException
420-
*
421408
* @return array<array-key, mixed>
409+
*
410+
* @throws \LogicException
422411
*/
423412
public function getUploadedFiles(): array
424413
{
@@ -443,9 +432,7 @@ public function withUploadedFiles(array $uploadedFiles): self
443432
return $new;
444433
}
445434

446-
/**
447-
* @return null|array<array-key, mixed>|object
448-
*/
435+
/** @return null|array<array-key, mixed>|object */
449436
public function getParsedBody()
450437
{
451438
if (false === $this->parsedBody) {
@@ -458,9 +445,9 @@ public function getParsedBody()
458445
/**
459446
* @param null|array<array-key, mixed>|object $data
460447
*
461-
* @throws InvalidTypeException
462-
*
463448
* @return static
449+
*
450+
* @throws InvalidTypeException
464451
*/
465452
public function withParsedBody($data): self
466453
{
@@ -474,9 +461,7 @@ public function withParsedBody($data): self
474461
return $new;
475462
}
476463

477-
/**
478-
* @return mixed[]
479-
*/
464+
/** @return mixed[] */
480465
public function getAttributes(): array
481466
{
482467
return $this->attributes;
@@ -530,7 +515,7 @@ public function withoutAttribute($name): self
530515
private function retroducePathInfoArray(array $pathInfo): void
531516
{
532517
if (null === $this->reflexPathInfoArray) {
533-
$reflexiveWebRequest = new ReflectionObject($this->sfWebRequest);
518+
$reflexiveWebRequest = new \ReflectionObject($this->sfWebRequest);
534519
$this->reflexPathInfoArray = $reflexiveWebRequest->getProperty('pathInfoArray');
535520
$this->reflexPathInfoArray->setAccessible(true);
536521
}
@@ -554,9 +539,7 @@ private function setHeader(string $name, $value): void
554539
$this->retroducePathInfoArray($pathInfoArray);
555540
}
556541

557-
/**
558-
* get the array key resp. to pathInfoArray from the header field name
559-
*/
542+
/** get the array key resp. to pathInfoArray from the header field name */
560543
private function getPathInfoKey(string $name): string
561544
{
562545
$keyName = strtoupper(str_replace('-', '_', $name));
@@ -615,9 +598,9 @@ private function addUploadedFiles(array $files, array $keys): void
615598
}
616599

617600
/**
618-
* @throws LogicException
619-
*
620601
* @return static
602+
*
603+
* @throws LogicException
621604
*/
622605
private function getCloneOrDie(): self
623606
{
@@ -628,9 +611,7 @@ private function getCloneOrDie(): self
628611
return clone $this;
629612
}
630613

631-
/**
632-
* @return static
633-
*/
614+
/** @return static */
634615
private function getThisOrClone(): self
635616
{
636617
if ($this->isImmutable) {

0 commit comments

Comments
 (0)