Skip to content

Commit 6972229

Browse files
committed
refactor(binary): rename soarBinary to binary for consistency
- Renamed the soarBinary property to binary in multiple files for clarity. - Updated related methods to reflect the new property name. - Ensured backward compatibility in unserialize and set_state methods. Signed-off-by: guanguans <[email protected]>
1 parent 8640903 commit 6972229

File tree

9 files changed

+62
-28
lines changed

9 files changed

+62
-28
lines changed

.github/git-commit-instructions.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Git Commit Message Instructions
2+
3+
[//]: # (https://github.com/github/awesome-copilot)
4+
5+
## Here are some best practices for writing commit messages
6+
7+
- Write clear, concise, and descriptive messages that explain the changes made in the commit.
8+
- Use the present tense and active voice in the message, for example, "Fix bug" instead of "Fixed bug."
9+
- Use the imperative mood, which gives the message a sense of command, e.g. "Add feature" instead of "Added feature"
10+
- Limit the subject line to 72 characters or less.
11+
- Capitalize the subject line.
12+
- Do not end the subject line with a period.
13+
- Limit the body of the message to 256 characters or less.
14+
- Use a blank line between the subject and the body of the message.
15+
- Use the body of the message to provide additional context or explain the reasoning behind the changes.
16+
- Avoid using general terms like "update" or "change" in the subject line, be specific about what was updated or changed.
17+
- Explain, What was done at a glance in the subject line, and provide additional context in the body of the message.
18+
- Why the change was necessary in the body of the message.
19+
- The details about what was done in the body of the message.
20+
- Any useful details concerning the change in the body of the message.
21+
- Use a hyphen (-) for the bullet points in the body of the message.
22+
- Use {locale} language to answer..
23+
- No code blocks.
24+
25+
## Write 1 commit messages that accurately summarizes the changes made in the given `git diff` output, following the best practices listed above and the conventional commit format
26+
27+
The format is as follows:
28+
29+
<type>(<scope>): <subject>
30+
<BODY (bullet points)>
31+
32+
## Here is the output of the `git diff`
33+
34+
{diff}

src/Concerns/ConcreteMagic.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __serialize(): array
2727
{
2828
return [
2929
'options' => $this->options,
30-
'soarBinary' => $this->soarBinary,
30+
'binary' => $this->binary,
3131
];
3232
}
3333

@@ -39,7 +39,7 @@ public function __serialize(): array
3939
public function __unserialize(array $data): void
4040
{
4141
$this->setOptions($data['options']);
42-
$this->withSoarBinary($data['soarBinary']);
42+
$this->withBinary($data['binary']);
4343
}
4444

4545
public function __debugInfo(): array
@@ -54,7 +54,7 @@ public function __debugInfo(): array
5454
*/
5555
public static function __set_state(array $properties): self
5656
{
57-
return new self($properties['options'], $properties['soarBinary']);
57+
return new self($properties['options'], $properties['binary']);
5858
}
5959

6060
/**
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,31 @@
1919
/**
2020
* @mixin \Guanguans\SoarPHP\Soar
2121
*/
22-
trait HasSoarBinary
22+
trait HasBinary
2323
{
24-
protected string $soarBinary;
24+
protected string $binary;
2525

26-
public function getSoarBinary(): string
26+
public function getBinary(): string
2727
{
28-
return $this->soarBinary;
28+
return $this->binary;
2929
}
3030

31-
public function withSoarBinary(string $soarBinary): self
31+
public function withBinary(string $binary): self
3232
{
33-
if (!is_file($soarBinary)) {
34-
throw new InvalidArgumentException("The [$soarBinary] is not a file.");
33+
if (!is_file($binary)) {
34+
throw new InvalidArgumentException("The [$binary] is not a file.");
3535
}
3636

37-
if (!is_executable($soarBinary)) {
38-
throw new InvalidArgumentException("The file [$soarBinary] is not executable.");
37+
if (!is_executable($binary)) {
38+
throw new InvalidArgumentException("The file [$binary] is not executable.");
3939
}
4040

41-
$this->soarBinary = realpath($soarBinary);
41+
$this->binary = realpath($binary);
4242

4343
return $this;
4444
}
4545

46-
public function defaultSoarBinary(): string
46+
public function defaultBinary(): string
4747
{
4848
if (OS::isWindows()) {
4949
return __DIR__.'/../../bin/soar.windows-amd64';

src/Concerns/WithDumpable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function dd(mixed ...$args): void
3535
*/
3636
public function dump(mixed ...$args): self
3737
{
38-
$args[] = $this;
38+
$args = [$this, ...$args];
3939
$varDumperExists = class_exists(VarDumper::class);
4040

4141
foreach ($args as $arg) {

src/Concerns/WithRunable.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
*/
2121
trait WithRunable
2222
{
23-
/** @var null|callable(Process):Process */
23+
/** @var null|callable(Process): Process */
2424
protected $pipe;
2525

26-
/** @var null|callable(Process):void */
26+
/** @var null|callable(Process): void */
2727
protected $tap;
2828

2929
public function withPipe(?callable $pipe): self
@@ -53,7 +53,7 @@ public function run(?callable $callback = null): string
5353
*/
5454
protected function toProcess(): Process
5555
{
56-
$command = [$this->soarBinary, ...$this->clone()->getNormalizedOptions()];
56+
$command = [$this->binary, ...$this->clone()->getNormalizedOptions()];
5757

5858
$process = $this->shouldApplySudoPassword()
5959
? new Process(command: ['sudo', '-S', ...$command], input: $this->getSudoPassword())

src/Soar.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
use Guanguans\SoarPHP\Concerns\ConcreteMagic;
1717
use Guanguans\SoarPHP\Concerns\ConcreteScores;
18+
use Guanguans\SoarPHP\Concerns\HasBinary;
1819
use Guanguans\SoarPHP\Concerns\HasOptions;
19-
use Guanguans\SoarPHP\Concerns\HasSoarBinary;
2020
use Guanguans\SoarPHP\Concerns\HasSudoPassword;
2121
use Guanguans\SoarPHP\Concerns\Makeable;
2222
use Guanguans\SoarPHP\Concerns\WithDumpable;
@@ -27,17 +27,17 @@ class Soar implements \ArrayAccess, \Stringable, Contracts\Soar
2727
{
2828
use ConcreteMagic;
2929
use ConcreteScores;
30+
use HasBinary;
3031
use HasOptions;
31-
use HasSoarBinary;
3232
use HasSudoPassword;
3333
use Makeable;
3434
use WithDumpable;
3535
use WithRunable;
3636

37-
public function __construct(array $options = [], ?string $soarBinary = null)
37+
public function __construct(array $options = [], ?string $binary = null)
3838
{
3939
$this->setOptions($options);
40-
$this->withSoarBinary($soarBinary ?? $this->defaultSoarBinary());
40+
$this->withBinary($binary ?? $this->defaultBinary());
4141
}
4242

4343
/**

tests/Concerns/ConcreteMagicTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
it('can serialize and unserialize', function (): void {
2525
expect(unserialize(serialize(Soar::make(soar_options()))))
2626
->toBeInstanceOf(Soar::class)
27-
->getSoarBinary()->toBeTruthy()
27+
->getBinary()->toBeTruthy()
2828
->getOptions()->toBeTruthy();
2929
})->group(__DIR__, __FILE__);
3030

@@ -42,6 +42,6 @@
4242
PHP
4343
);
4444
expect(require $path)->toBeInstanceOf(Soar::class)
45-
->getSoarBinary()->toBeTruthy()
45+
->getBinary()->toBeTruthy()
4646
->getOptions()->toBeTruthy();
4747
})->group(__DIR__, __FILE__);

tests/Concerns/HasSoarBinaryTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
use Guanguans\SoarPHP\Soar;
2323

2424
it('can get soar binary', function (): void {
25-
expect(Soar::make())->getSoarBinary()->toBeFile();
25+
expect(Soar::make())->getBinary()->toBeFile();
2626
})->group(__DIR__, __FILE__);
2727

2828
it('will throw InvalidArgumentException when set not a file', function (): void {
29-
Soar::make()->withSoarBinary('soar-binary');
29+
Soar::make()->withBinary('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()->withSoarBinary(__FILE__);
33+
Soar::make()->withBinary(__FILE__);
3434
})->group(__DIR__, __FILE__)->throws(InvalidArgumentException::class, \sprintf('The file [%s] is not executable.', __FILE__));

tests/SoarTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
})->group(__DIR__, __FILE__);
2727

2828
it('can get help snapshot', function (): void {
29-
expect(str(Soar::make()->help())->replace(Soar::make()->getSoarBinary(), 'soar-binary'))->toMatchSnapshot();
29+
expect(str(Soar::make()->help())->replace(Soar::make()->getBinary(), 'soar-binary'))->toMatchSnapshot();
3030
})->group(__DIR__, __FILE__)->skip(OS::isWindows());
3131

3232
it('can get version', function (): void {

0 commit comments

Comments
 (0)