Skip to content

Commit 8640903

Browse files
committed
refactor: rename setter methods to use 'with' prefix for clarity
- Changed 'setSoarBinary' to 'withSoarBinary' for consistency. - Updated 'setSudoPassword' to 'withSudoPassword' for clarity. - Renamed 'setPipe' to 'withPipe' to align with new naming convention. - Modified 'setTap' to 'withTap' for improved readability. Signed-off-by: guanguans <[email protected]>
1 parent 7be4788 commit 8640903

File tree

9 files changed

+12
-12
lines changed

9 files changed

+12
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ array:9 [
509509

510510
```php
511511
// Fatal error: Uncaught Symfony\Component\Process\Exception\ProcessFailedException: The command "'/Users/yaozm/Documents/develop/soar-php/bin/soar.darwin-arm64' '-report-type=json' '-query=SELECT * FROM `foo`;'" failed. Exit Code: 2(Misuse of shell builtins) Working directory: /Users/yaozm/Documents/develop/soar-php Output: ================ Error Output: ================ panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x104d22798] goroutine 1 [running]: github.com/pingcap/tidb/util/memory.MemTotalNormal() pkg/mod/github.com/pingcap/[email protected]/util/memory/meminfo.go:41 +0x68 github.com/pingcap/tidb/util/memory.init.0() pkg/mod/github.com/pingcap/[email protected]/util/memory/meminfo.go:134 +0x184 in /Users/yaozm/Documents/develop/soar-php/vendor/symfony/process/Process.php:273
512-
$soar->setSudoPassword('your sudo password'); // Set a sudo password to run the soar command with sudo to avoid the above errors.
512+
$soar->withSudoPassword('your sudo password'); // With a sudo password to run the soar command with sudo to avoid the above errors.
513513
```
514514
</details>
515515

src/Concerns/ConcreteMagic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __serialize(): array
3939
public function __unserialize(array $data): void
4040
{
4141
$this->setOptions($data['options']);
42-
$this->setSoarBinary($data['soarBinary']);
42+
$this->withSoarBinary($data['soarBinary']);
4343
}
4444

4545
public function __debugInfo(): array

src/Concerns/HasSoarBinary.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function getSoarBinary(): string
2828
return $this->soarBinary;
2929
}
3030

31-
public function setSoarBinary(string $soarBinary): self
31+
public function withSoarBinary(string $soarBinary): self
3232
{
3333
if (!is_file($soarBinary)) {
3434
throw new InvalidArgumentException("The [$soarBinary] is not a file.");

src/Concerns/HasSudoPassword.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function getSudoPassword(): ?string
2727
return $this->sudoPassword;
2828
}
2929

30-
public function setSudoPassword(
30+
public function withSudoPassword(
3131
#[\SensitiveParameter]
3232
?string $sudoPassword
3333
): self {

src/Concerns/WithRunable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ trait WithRunable
2626
/** @var null|callable(Process):void */
2727
protected $tap;
2828

29-
public function setPipe(?callable $pipe): self
29+
public function withPipe(?callable $pipe): self
3030
{
3131
$this->pipe = $pipe;
3232

3333
return $this;
3434
}
3535

36-
public function setTap(?callable $tap): self
36+
public function withTap(?callable $tap): self
3737
{
3838
$this->tap = $tap;
3939

src/Soar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Soar implements \ArrayAccess, \Stringable, Contracts\Soar
3737
public function __construct(array $options = [], ?string $soarBinary = null)
3838
{
3939
$this->setOptions($options);
40-
$this->setSoarBinary($soarBinary ?? $this->defaultSoarBinary());
40+
$this->withSoarBinary($soarBinary ?? $this->defaultSoarBinary());
4141
}
4242

4343
/**

tests/Concerns/HasSoarBinaryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
})->group(__DIR__, __FILE__);
2727

2828
it('will throw InvalidArgumentException when set not a file', function (): void {
29-
Soar::make()->setSoarBinary('soar-binary');
29+
Soar::make()->withSoarBinary('soar-binary');
3030
})->group(__DIR__, __FILE__)->throws(InvalidArgumentException::class, 'The [soar-binary] is not a file.');
3131

3232
it('will throw InvalidArgumentException when set not a executable file', function (): void {
33-
Soar::make()->setSoarBinary(__FILE__);
33+
Soar::make()->withSoarBinary(__FILE__);
3434
})->group(__DIR__, __FILE__)->throws(InvalidArgumentException::class, \sprintf('The file [%s] is not executable.', __FILE__));

tests/Concerns/HasSudoPasswordTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222

2323
it('can set sudo password', function (): void {
2424
expect(Soar::make())
25-
->setSudoPassword($sudoPassword = 'foo')
25+
->withSudoPassword($sudoPassword = 'foo')
2626
->getSudoPassword()->toBe($sudoPassword);
2727
})->group(__DIR__, __FILE__);

tests/Concerns/WithRunableTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected function shouldApplySudoPassword(): bool
4646
{
4747
return OS::isUnix();
4848
}
49-
})->setSudoPassword('foo')->help();
49+
})->withSudoPassword('foo')->help();
5050
})
5151
->group(__DIR__, __FILE__)
5252
->throws(ProcessFailedException::class, implode(\PHP_EOL, [
@@ -61,7 +61,7 @@ protected function shouldApplySudoPassword(): bool
6161
it('can run soar process with tapper', function (): void {
6262
expect(Soar::make())
6363
->withVersion(true)
64-
->setTap(static function (Process $process): void {
64+
->withTap(static function (Process $process): void {
6565
$process->setTimeout(3);
6666
})
6767
->run(static function (string $type, string $line): void {

0 commit comments

Comments
 (0)