Skip to content

Commit dc95d05

Browse files
committed
Upgrade PHP CS Fixer
1 parent 0e9cad7 commit dc95d05

Some content is hidden

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

41 files changed

+396
-377
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
/.gitignore export-ignore
55
/.travis.yml export-ignore
66
/phpunit.xml.dist export-ignore
7-
/php_cs.dist export-ignore
7+
/.php-cs-fixer.dist.php export-ignore

.github/workflows/test-unit.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
php: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
18+
php: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3', 'latest']
1919
type: ['Phpunit']
2020
include:
21-
- php: '8.0'
21+
- php: 'latest'
2222
type: 'CodingStyle'
23-
- php: '8.3'
23+
- php: 'latest'
2424
type: 'StaticAnalysis'
2525
steps:
2626
- name: Checkout

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/.idea
2-
/.php_cs
3-
/.phpunit.result.cache
41
/vendor
52
/composer.lock
63
/phpunit.xml
4+
/.phpunit.result.cache

.php-cs-fixer.dist.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PhpCsFixer\Config;
6+
use PhpCsFixer\Finder;
7+
8+
$finder = Finder::create()
9+
->in([__DIR__])
10+
->exclude(['vendor']);
11+
12+
return (new Config())
13+
->setRiskyAllowed(true)
14+
->setRules([
15+
'@PhpCsFixer' => true,
16+
'@PhpCsFixer:risky' => true,
17+
'@PHP71Migration' => true,
18+
'@PHP71Migration:risky' => true,
19+
20+
// required by PSR-12
21+
'concat_space' => [
22+
'spacing' => 'one',
23+
],
24+
25+
// disable some too strict rules
26+
'phpdoc_types_order' => [
27+
'null_adjustment' => 'always_last',
28+
'sort_algorithm' => 'none',
29+
],
30+
'single_line_throw' => false,
31+
'yoda_style' => [
32+
'equal' => false,
33+
'identical' => false,
34+
],
35+
'native_constant_invocation' => true,
36+
'native_function_invocation' => false,
37+
'void_return' => false,
38+
'blank_line_before_statement' => [
39+
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'exit'],
40+
],
41+
'final_internal_class' => false,
42+
'combine_consecutive_issets' => false,
43+
'combine_consecutive_unsets' => false,
44+
'multiline_whitespace_before_semicolons' => false,
45+
'no_superfluous_elseif' => false,
46+
'ordered_class_elements' => false,
47+
'php_unit_internal_class' => false,
48+
'php_unit_test_class_requires_covers' => false,
49+
'phpdoc_add_missing_param_annotation' => false,
50+
'return_assignment' => false,
51+
'comment_to_phpdoc' => false,
52+
'general_phpdoc_annotation_remove' => [
53+
'annotations' => ['author', 'copyright', 'throws'],
54+
],
55+
56+
// fn => without curly brackets is less readable,
57+
// also prevent bounding of unwanted variables for GC
58+
'use_arrow_functions' => false,
59+
60+
// TODO disable too strict rules for now - remove once the CS is updated
61+
'declare_strict_types' => false,
62+
'fully_qualified_strict_types' => false,
63+
'general_phpdoc_annotation_remove' => false,
64+
'global_namespace_import' => false,
65+
'increment_style' => false,
66+
'native_constant_invocation' => false,
67+
'no_useless_else' => false,
68+
'php_unit_data_provider_name' => false,
69+
'php_unit_data_provider_return_type' => false,
70+
'php_unit_data_provider_static' => false,
71+
'php_unit_strict' => false,
72+
'php_unit_test_case_static_method_calls' => false,
73+
'phpdoc_to_comment' => false,
74+
'static_lambda' => false,
75+
'strict_comparison' => false,
76+
])
77+
->setFinder($finder)
78+
->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer.' . md5(__DIR__) . '.cache');

.php_cs.dist

Lines changed: 0 additions & 60 deletions
This file was deleted.

composer.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,13 @@
4646
"ext-sysvsem": "*",
4747
"eloquent/liberator": "^2.0",
4848
"ergebnis/composer-normalize": "^2.13",
49-
"friendsofphp/php-cs-fixer": "^2.16",
50-
"johnkary/phpunit-speedtrap": "^3.0",
49+
"friendsofphp/php-cs-fixer": "^3.0",
5150
"mikey179/vfsstream": "^1.6.7",
5251
"php-mock/php-mock-phpunit": "^2.1",
5352
"phpstan/phpstan": "^0.12.58",
5453
"phpunit/phpunit": "^9.4",
5554
"predis/predis": "^1.1",
56-
"spatie/async": "^1.5",
57-
"squizlabs/php_codesniffer": "^3.3"
55+
"spatie/async": "^1.5"
5856
},
5957
"suggest": {
6058
"ext-igbinary": "To use this library with PHP Redis igbinary serializer enabled.",
@@ -82,8 +80,5 @@
8280
"phpstan/extension-installer": true
8381
},
8482
"sort-packages": true
85-
},
86-
"scripts": {
87-
"fix-cs": "vendor/bin/phpcbf --standard=PSR2 src/ tests/"
8883
}
8984
}

phpunit.xml.dist

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,4 @@
1515
<directory suffix="Test.php">./tests</directory>
1616
</testsuite>
1717
</testsuites>
18-
<listeners>
19-
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener" />
20-
</listeners>
2118
</phpunit>

src/exception/DeadlineException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,4 @@
99
/**
1010
* Deadline exception.
1111
*/
12-
class DeadlineException extends RuntimeException implements PhpLockException
13-
{
14-
}
12+
class DeadlineException extends RuntimeException implements PhpLockException {}

src/exception/ExecutionOutsideLockException.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ class ExecutionOutsideLockException extends LockReleaseException
2121
/**
2222
* Creates a new instance of the ExecutionOutsideLockException class.
2323
*
24-
* @param float $elapsedTime Total elapsed time of the synchronized code
25-
* callback execution.
26-
* @param float $timeout The lock timeout in seconds.
27-
* @return self Execution outside lock exception.
24+
* @param float $elapsedTime total elapsed time of the synchronized code
25+
* callback execution
26+
* @param float $timeout the lock timeout in seconds
27+
*
28+
* @return self execution outside lock exception
2829
*/
2930
public static function create(float $elapsedTime, float $timeout): self
3031
{

src/exception/LockAcquireException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,4 @@
1010
* Used when the lock could not be acquired. This exception implies that the
1111
* critical code was not executed, or at least had no side effects.
1212
*/
13-
class LockAcquireException extends MutexException
14-
{
15-
}
13+
class LockAcquireException extends MutexException {}

src/exception/LockReleaseException.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class LockReleaseException extends MutexException
3333
* Gets the result that has been returned during the critical code
3434
* execution.
3535
*
36-
* @return mixed The return value of the executed code block.
36+
* @return mixed the return value of the executed code block
3737
*/
3838
public function getCodeResult()
3939
{
@@ -44,8 +44,9 @@ public function getCodeResult()
4444
* Sets the result that has been returned during the critical code
4545
* execution.
4646
*
47-
* @param mixed $codeResult The return value of the executed code block.
48-
* @return self Current lock release exception instance.
47+
* @param mixed $codeResult the return value of the executed code block
48+
*
49+
* @return self current lock release exception instance
4950
*/
5051
public function setCodeResult($codeResult): self
5152
{
@@ -58,8 +59,8 @@ public function setCodeResult($codeResult): self
5859
* Gets the exception that has happened during the synchronized code
5960
* execution.
6061
*
61-
* @return \Throwable|null The exception thrown by the code block or null
62-
* when there has been no exception.
62+
* @return \Throwable|null the exception thrown by the code block or null
63+
* when there has been no exception
6364
*/
6465
public function getCodeException(): ?Throwable
6566
{
@@ -70,8 +71,9 @@ public function getCodeException(): ?Throwable
7071
* Sets the exception that has happened during the critical code
7172
* execution.
7273
*
73-
* @param \Throwable $codeException The exception thrown by the code block.
74-
* @return self Current lock release exception instance.
74+
* @param \Throwable $codeException the exception thrown by the code block
75+
*
76+
* @return self current lock release exception instance
7577
*/
7678
public function setCodeException(Throwable $codeException): self
7779
{

src/exception/MutexException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class MutexException extends RuntimeException implements PhpLockException
1616
{
1717
/**
18-
* @var int Not enough redis servers.
18+
* @var int not enough redis servers
1919
*/
2020
public const REDIS_NOT_ENOUGH_SERVERS = 1;
2121
}

src/exception/PhpLockException.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@
77
/**
88
* Common php-lock/lock exception interface.
99
*
10-
* @method string getMessage()
11-
* @method int getCode()
12-
* @method string getFile()
13-
* @method int getLine()
14-
* @method array getTrace()
15-
* @method string getTraceAsString()
10+
* @method string getMessage()
11+
* @method int getCode()
12+
* @method string getFile()
13+
* @method int getLine()
14+
* @method array getTrace()
15+
* @method string getTraceAsString()
1616
* @method \Throwable|null getPrevious()
17-
* @method string __toString()
17+
* @method string __toString()
1818
*/
19-
interface PhpLockException
20-
{
21-
}
19+
interface PhpLockException {}

src/exception/TimeoutException.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ class TimeoutException extends LockAcquireException
1515
/**
1616
* Creates a new instance of the TimeoutException class.
1717
*
18-
* @param float $timeout The timeout in seconds.
19-
* @return self A timeout has been exceeded exception.
18+
* @param float $timeout the timeout in seconds
19+
*
20+
* @return self a timeout has been exceeded exception
2021
*/
2122
public static function create(float $timeout): self
2223
{

src/mutex/CASMutex.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class CASMutex extends Mutex
1919
{
2020
/**
21-
* @var Loop The loop.
21+
* @var Loop the loop
2222
*/
2323
private $loop;
2424

@@ -27,8 +27,9 @@ class CASMutex extends Mutex
2727
*
2828
* The default is 3 seconds.
2929
*
30-
* @param float $timeout The timeout in seconds.
31-
* @throws \LengthException The timeout must be greater than 0.
30+
* @param float $timeout the timeout in seconds
31+
*
32+
* @throws \LengthException the timeout must be greater than 0
3233
*/
3334
public function __construct(float $timeout = 3)
3435
{
@@ -69,11 +70,13 @@ public function notify(): void
6970
* </code>
7071
*
7172
* @template T
72-
* @param callable(): T $code The synchronized execution block.
73-
* @throws \Exception The execution block threw an exception.
74-
* @throws TimeoutException The timeout was reached.
75-
* @return T The return value of the execution block.
7673
*
74+
* @param callable(): T $code the synchronized execution block
75+
*
76+
* @return T the return value of the execution block
77+
*
78+
* @throws \Exception the execution block threw an exception
79+
* @throws TimeoutException the timeout was reached
7780
*/
7881
public function synchronized(callable $code)
7982
{

0 commit comments

Comments
 (0)