Skip to content

Commit 3156847

Browse files
committed
refactor: Simplify withSudoPassword method signature
- Combine parameters into a single line for better readability - Maintain functionality while improving code clarity
1 parent d0bef39 commit 3156847

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
php-version: ${{ matrix.php }}
3131
coverage: xdebug
3232
# extensions: amqp,apcu,brotli,igbinary,intl,mbstring,memcached,redis,relay,zstd,:php-psr
33+
extensions: intl,sodium
3334
env:
3435
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3536

rector.dist.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
use Rector\CodingStyle\Rector\Enum_\EnumCaseToPascalCaseRector;
3535
use Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector;
3636
use Rector\Config\RectorConfig;
37+
use Rector\DeadCode\Rector\ClassLike\RemoveAnnotationRector;
3738
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
3839
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector;
3940
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
@@ -135,6 +136,10 @@
135136
ArrowFunctionDelegatingCallToFirstClassCallableRector::class => [
136137
__DIR__.'/tests/Concerns/HasOptionsTest.php',
137138
],
139+
RemoveAnnotationRector::class => [
140+
__DIR__.'/src/Concerns/HasBinary.php',
141+
__DIR__.'/src/Concerns/WithDumpable.php',
142+
],
138143
SortAssociativeArrayByKeyRector::class => [
139144
__DIR__.'/benchmarks/',
140145
__DIR__.'/examples/',

src/Concerns/HasBinary.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public function withBinary(string $binary): self
4343
return $this;
4444
}
4545

46+
/**
47+
* @codeCoverageIgnore
48+
*/
4649
public function defaultBinary(): string
4750
{
4851
if (OsHelper::isWindows()) {

src/Concerns/HasSudoPassword.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ public function withoutSudoPassword(): self
3232
return $this->withSudoPassword(null);
3333
}
3434

35-
public function withSudoPassword(
36-
#[\SensitiveParameter]
37-
?string $sudoPassword
38-
): self {
35+
public function withSudoPassword(#[\SensitiveParameter] ?string $sudoPassword): self
36+
{
3937
$this->sudoPassword = $sudoPassword;
4038

4139
return $this;

src/Concerns/WithDumpable.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
trait WithDumpable
2222
{
2323
/**
24+
* @codeCoverageIgnore
25+
*
2426
* @noinspection PhpNoReturnAttributeCanBeAddedInspection
2527
*/
2628
public function dd(mixed ...$args): void
@@ -35,11 +37,8 @@ public function dd(mixed ...$args): void
3537
*/
3638
public function dump(mixed ...$args): self
3739
{
38-
$args = [$this, ...$args];
39-
$varDumperExists = class_exists(VarDumper::class);
40-
41-
foreach ($args as $arg) {
42-
$varDumperExists ? VarDumper::dump($arg) : var_dump($arg);
40+
foreach ([$this, ...$args] as $arg) {
41+
class_exists(VarDumper::class) ? VarDumper::dump($arg) : var_dump($arg);
4342
}
4443

4544
return $this;

src/Concerns/WithRunnable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ protected function toProcess(): Process
5656
$command = [$this->binary, ...$this->clone()->getNormalizedOptions()];
5757

5858
$process = $this->shouldApplySudoPassword()
59-
? new Process(command: ['sudo', '-S', ...$command], input: $this->getSudoPassword())
59+
? new Process(command: ['sudo', '-S', ...$command], input: $this->getSudoPassword()) // @codeCoverageIgnore
6060
: new Process($command);
6161

6262
if ($this->tap instanceof \Closure) {

0 commit comments

Comments
 (0)