Skip to content

Commit 9d5bd28

Browse files
committed
Merge branch 'mutator-cleanup'
2 parents c695555 + ea26fc2 commit 9d5bd28

Some content is hidden

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

42 files changed

+463
-180
lines changed

phpstan.neon.dist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ parameters:
2626
paths:
2727
- tests/fixtures/Toolkit/PHPStan/Utility/Rules/GetCoalesceRuleFailures.php
2828
- tests/fixtures/Toolkit/PHPStan/Utility/Type/GetCoalesceReturnTypeExtensionAssertions.php
29+
-
30+
identifier: salient.property.notFound
31+
paths:
32+
- tests/fixtures/Toolkit/PHPStan/Core/Rules/TypesAssignedByHasMutatorRuleFailures.php
33+
-
34+
identifier: salient.property.type
35+
paths:
36+
- tests/fixtures/Toolkit/PHPStan/Core/Rules/TypesAssignedByHasMutatorRuleFailures.php
2937
-
3038
identifier: arguments.count
3139
paths:

src/Toolkit/Cli/CliHelpStyle.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Salient\Contract\Cli\CliHelpTarget;
1212
use Salient\Contract\Cli\CliOptionVisibility;
1313
use Salient\Contract\Console\ConsoleFormatterInterface as FormatterInterface;
14-
use Salient\Core\Concern\HasImmutableProperties;
14+
use Salient\Core\Concern\HasMutator;
1515
use Salient\Core\Facade\Console;
1616
use Salient\Utility\Regex;
1717
use LogicException;
@@ -23,7 +23,7 @@
2323
*/
2424
final class CliHelpStyle implements CliHelpStyleInterface
2525
{
26-
use HasImmutableProperties;
26+
use HasMutator;
2727

2828
private ?int $Width;
2929
private FormatterInterface $Formatter;
@@ -213,7 +213,7 @@ public function getVisibility(): int
213213
*/
214214
public function withCollapseSynopsis(bool $value = true)
215215
{
216-
return $this->withPropertyValue('CollapseSynopsis', $value);
216+
return $this->with('CollapseSynopsis', $value);
217217
}
218218

219219
public function prepareHelp(string $text, string $indent = ''): string

src/Toolkit/Collection/ImmutableCollectionTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Salient\Contract\Collection\CollectionInterface;
66
use Salient\Contract\Core\Immutable;
7-
use Salient\Core\Concern\HasImmutableProperties;
7+
use Salient\Core\Concern\HasMutator;
88
use Salient\Core\Concern\ImmutableArrayAccessTrait;
99

1010
/**
@@ -31,13 +31,13 @@ trait ImmutableCollectionTrait
3131
ImmutableArrayAccessTrait::offsetSet insteadof CollectionTrait;
3232
ImmutableArrayAccessTrait::offsetUnset insteadof CollectionTrait;
3333
}
34-
use HasImmutableProperties;
34+
use HasMutator;
3535

3636
/**
3737
* @return static
3838
*/
3939
protected function maybeClone()
4040
{
41-
return $this->clone();
41+
return clone $this;
4242
}
4343
}

src/Toolkit/Collection/ImmutableListTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Salient\Contract\Collection\ListInterface;
66
use Salient\Contract\Core\Immutable;
7-
use Salient\Core\Concern\HasImmutableProperties;
7+
use Salient\Core\Concern\HasMutator;
88
use Salient\Core\Concern\ImmutableArrayAccessTrait;
99

1010
/**
@@ -30,13 +30,13 @@ trait ImmutableListTrait
3030
ImmutableArrayAccessTrait::offsetSet insteadof ListTrait;
3131
ImmutableArrayAccessTrait::offsetUnset insteadof ListTrait;
3232
}
33-
use HasImmutableProperties;
33+
use HasMutator;
3434

3535
/**
3636
* @return static
3737
*/
3838
protected function maybeClone()
3939
{
40-
return $this->clone();
40+
return clone $this;
4141
}
4242
}

src/Toolkit/Console/Concept/ConsoleStreamTarget.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@ protected function createTagFormats(): TagFormats
6767
$yellowUnderline = Format::ttyUnderline(Colour::YELLOW);
6868

6969
return (new TagFormats())
70-
->set(Tag::HEADING, $boldCyan)
71-
->set(Tag::BOLD, $bold)
72-
->set(Tag::ITALIC, $yellow)
73-
->set(Tag::UNDERLINE, $yellowUnderline)
74-
->set(Tag::LOW_PRIORITY, $dim)
75-
->set(Tag::CODE_SPAN, $bold)
76-
->set(Tag::DIFF_HEADER, $bold)
77-
->set(Tag::DIFF_RANGE, $cyan)
78-
->set(Tag::DIFF_ADDITION, $green)
79-
->set(Tag::DIFF_REMOVAL, $red);
70+
->withFormat(Tag::HEADING, $boldCyan)
71+
->withFormat(Tag::BOLD, $bold)
72+
->withFormat(Tag::ITALIC, $yellow)
73+
->withFormat(Tag::UNDERLINE, $yellowUnderline)
74+
->withFormat(Tag::LOW_PRIORITY, $dim)
75+
->withFormat(Tag::CODE_SPAN, $bold)
76+
->withFormat(Tag::DIFF_HEADER, $bold)
77+
->withFormat(Tag::DIFF_RANGE, $cyan)
78+
->withFormat(Tag::DIFF_ADDITION, $green)
79+
->withFormat(Tag::DIFF_REMOVAL, $red);
8080
}
8181

8282
protected function createMessageFormats(): MessageFormats

src/Toolkit/Console/ConsoleFormatter.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Salient\Contract\Console\ConsoleMessageType as MessageType;
1414
use Salient\Contract\Console\ConsoleTag as Tag;
1515
use Salient\Contract\Core\MessageLevel as Level;
16-
use Salient\Core\Concern\HasImmutableProperties;
16+
use Salient\Core\Concern\HasMutator;
1717
use Salient\Utility\Regex;
1818
use Salient\Utility\Str;
1919
use LogicException;
@@ -24,7 +24,7 @@
2424
*/
2525
final class ConsoleFormatter implements FormatterInterface
2626
{
27-
use HasImmutableProperties;
27+
use HasMutator;
2828

2929
public const DEFAULT_LEVEL_PREFIX_MAP = [
3030
Level::EMERGENCY => '! ', // U+0021
@@ -189,23 +189,23 @@ public function withSpinnerState(?array &$state)
189189
*/
190190
public function withUnescape(bool $value = true)
191191
{
192-
return $this->withPropertyValue('TagFormats', $this->TagFormats->withUnescape($value));
192+
return $this->with('TagFormats', $this->TagFormats->withUnescape($value));
193193
}
194194

195195
/**
196196
* @inheritDoc
197197
*/
198198
public function withWrapAfterApply(bool $value = true)
199199
{
200-
return $this->withPropertyValue('TagFormats', $this->TagFormats->withWrapAfterApply($value));
200+
return $this->with('TagFormats', $this->TagFormats->withWrapAfterApply($value));
201201
}
202202

203203
/**
204204
* @inheritDoc
205205
*/
206206
public function getTagFormat($tag): Format
207207
{
208-
return $this->TagFormats->get($tag);
208+
return $this->TagFormats->getFormat($tag);
209209
}
210210

211211
/**
@@ -583,11 +583,11 @@ public function formatMessage(
583583
public function formatDiff(string $diff): string
584584
{
585585
$formats = [
586-
'---' => $this->TagFormats->get(Tag::DIFF_HEADER),
587-
'+++' => $this->TagFormats->get(Tag::DIFF_HEADER),
588-
'@' => $this->TagFormats->get(Tag::DIFF_RANGE),
589-
'+' => $this->TagFormats->get(Tag::DIFF_ADDITION),
590-
'-' => $this->TagFormats->get(Tag::DIFF_REMOVAL),
586+
'---' => $this->TagFormats->getFormat(Tag::DIFF_HEADER),
587+
'+++' => $this->TagFormats->getFormat(Tag::DIFF_HEADER),
588+
'@' => $this->TagFormats->getFormat(Tag::DIFF_RANGE),
589+
'+' => $this->TagFormats->getFormat(Tag::DIFF_ADDITION),
590+
'-' => $this->TagFormats->getFormat(Tag::DIFF_REMOVAL),
591591
];
592592

593593
return Regex::replaceCallback(

src/Toolkit/Console/Support/ConsoleLoopbackFormat.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ public static function getFormatter(): Formatter
7979
public static function getTagFormats(): TagFormats
8080
{
8181
return (new TagFormats(false))
82-
->set(Tag::HEADING, new self('***', '***'))
83-
->set(Tag::BOLD, new self('**', '**'))
84-
->set(Tag::ITALIC, new self('*', '*'))
85-
->set(Tag::UNDERLINE, new self('<', '>'))
86-
->set(Tag::LOW_PRIORITY, new self('~~', '~~'))
87-
->set(Tag::CODE_SPAN, new self('`', '`'))
88-
->set(Tag::CODE_BLOCK, new self('```', '```'));
82+
->withFormat(Tag::HEADING, new self('***', '***'))
83+
->withFormat(Tag::BOLD, new self('**', '**'))
84+
->withFormat(Tag::ITALIC, new self('*', '*'))
85+
->withFormat(Tag::UNDERLINE, new self('<', '>'))
86+
->withFormat(Tag::LOW_PRIORITY, new self('~~', '~~'))
87+
->withFormat(Tag::CODE_SPAN, new self('`', '`'))
88+
->withFormat(Tag::CODE_BLOCK, new self('```', '```'));
8989
}
9090
}

src/Toolkit/Console/Support/ConsoleManPageFormat.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ public static function getFormatter(): Formatter
8282
public static function getTagFormats(): TagFormats
8383
{
8484
return (new TagFormats(false, true))
85-
->set(Tag::HEADING, new self('***', '***'))
86-
->set(Tag::BOLD, new self('**', '**'))
87-
->set(Tag::ITALIC, new self('*', '*'))
88-
->set(Tag::UNDERLINE, new self('*', '*'))
89-
->set(Tag::LOW_PRIORITY, new self('', ''))
90-
->set(Tag::CODE_SPAN, new self('`', '`'))
91-
->set(Tag::CODE_BLOCK, new self('```', '```'));
85+
->withFormat(Tag::HEADING, new self('***', '***'))
86+
->withFormat(Tag::BOLD, new self('**', '**'))
87+
->withFormat(Tag::ITALIC, new self('*', '*'))
88+
->withFormat(Tag::UNDERLINE, new self('*', '*'))
89+
->withFormat(Tag::LOW_PRIORITY, new self('', ''))
90+
->withFormat(Tag::CODE_SPAN, new self('`', '`'))
91+
->withFormat(Tag::CODE_BLOCK, new self('```', '```'));
9292
}
9393
}

src/Toolkit/Console/Support/ConsoleMarkdownFormat.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ public static function getFormatter(): Formatter
8585
public static function getTagFormats(): TagFormats
8686
{
8787
return (new TagFormats(false, true))
88-
->set(Tag::HEADING, new self('***', '***'))
89-
->set(Tag::BOLD, new self('**', '**'))
90-
->set(Tag::ITALIC, new self('*', '*'))
91-
->set(Tag::UNDERLINE, new self('*<u>', '</u>*'))
92-
->set(Tag::LOW_PRIORITY, new self('<small>', '</small>'))
93-
->set(Tag::CODE_SPAN, new self('`', '`'))
94-
->set(Tag::CODE_BLOCK, new self('```', '```'));
88+
->withFormat(Tag::HEADING, new self('***', '***'))
89+
->withFormat(Tag::BOLD, new self('**', '**'))
90+
->withFormat(Tag::ITALIC, new self('*', '*'))
91+
->withFormat(Tag::UNDERLINE, new self('*<u>', '</u>*'))
92+
->withFormat(Tag::LOW_PRIORITY, new self('<small>', '</small>'))
93+
->withFormat(Tag::CODE_SPAN, new self('`', '`'))
94+
->withFormat(Tag::CODE_BLOCK, new self('```', '```'));
9595
}
9696
}

src/Toolkit/Console/Support/ConsoleMessageAttributes.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
use Salient\Contract\Console\ConsoleMessageAttributesInterface;
66
use Salient\Contract\Console\ConsoleMessageType as MessageType;
77
use Salient\Contract\Core\MessageLevel as Level;
8-
use Salient\Core\Concern\HasImmutableProperties;
8+
use Salient\Core\Concern\HasMutator;
99

1010
/**
1111
* Message attributes
1212
*/
1313
final class ConsoleMessageAttributes implements ConsoleMessageAttributesInterface
1414
{
15-
use HasImmutableProperties;
15+
use HasMutator;
1616

1717
/**
1818
* Message level
@@ -74,22 +74,22 @@ public function __construct(
7474
*/
7575
public function withIsMsg1(bool $value = true)
7676
{
77-
return $this->withPropertyValue('IsMsg1', $value);
77+
return $this->with('IsMsg1', $value);
7878
}
7979

8080
/**
8181
* @return static
8282
*/
8383
public function withIsMsg2(bool $value = true)
8484
{
85-
return $this->withPropertyValue('IsMsg2', $value);
85+
return $this->with('IsMsg2', $value);
8686
}
8787

8888
/**
8989
* @return static
9090
*/
9191
public function withIsPrefix(bool $value = true)
9292
{
93-
return $this->withPropertyValue('IsPrefix', $value);
93+
return $this->with('IsPrefix', $value);
9494
}
9595
}

0 commit comments

Comments
 (0)