Skip to content

Commit bfe1f8d

Browse files
authored
refactor: code quality updates (#1715)
1 parent 0749f1d commit bfe1f8d

File tree

12 files changed

+15
-19
lines changed

12 files changed

+15
-19
lines changed

docs/0-getting-started/01-introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ final readonly class BooksCommand
139139
Or what about [Tempest's ORM](../1-essentials/03-database), which aims to have truly decoupled models:
140140

141141
```php
142-
use Tempest\Validation\Rules\Length;
142+
use Tempest\Validation\Rules\HasLength;
143143
use App\Author;
144144

145145
final class Book
146146
{
147-
#[Length(min: 1, max: 120)]
147+
#[HasLength(min: 1, max: 120)]
148148
public string $title;
149149

150150
public ?Author $author = null;

docs/1-essentials/01-routing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,13 @@ A request class must implement {`Tempest\Http\Request`} and should use the {`Tem
344344
```php app/RegisterAirportRequest.php
345345
use Tempest\Http\Request;
346346
use Tempest\Http\IsRequest;
347-
use Tempest\Validation\Rules\Length;
347+
use Tempest\Validation\Rules\HasLength;
348348

349349
final class RegisterAirportRequest implements Request
350350
{
351351
use IsRequest;
352352

353-
#[Length(min: 10, max: 120)]
353+
#[HasLength(min: 10, max: 120)]
354354
public string $name;
355355

356356
public ?DateTimeImmutable $registeredAt = null;

packages/clock/src/MockClock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function minus(int|Duration $duration): void
9090
/**
9191
* @mago-expect lint:no-debug-symbols
9292
*/
93-
public function dd(): void
93+
public function dd(): never
9494
{
9595
dd($this->now);
9696
}

packages/database/src/QueryStatements/UpdateStatement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function compile(DatabaseDialect $dialect): string
3535
}
3636

3737
$query[] = 'SET ' . $this->values
38-
->map(fn (mixed $_, mixed $key) => sprintf("`{$key}` = ?"))
38+
->map(fn (mixed $_, mixed $key) => "`{$key}` = ?")
3939
->implode(', ');
4040

4141
if ($this->where->isNotEmpty()) {

packages/datetime/src/TemporalConvenienceMethods.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ public function __toString(): string
561561
* @phpstan-ignore disallowed.function
562562
* @mago-expect lint:no-debug-symbols
563563
*/
564-
public function dd(): void
564+
public function dd(): never
565565
{
566566
dd($this);
567567
}

packages/debug/src/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function lw(mixed ...$input): void
2121
* Writes the given `$input` to the logs, dumps it, and stops the execution of the script.
2222
* @see \Tempest\Debug\Debug::log()
2323
*/
24-
function ld(mixed ...$input): void
24+
function ld(mixed ...$input): never
2525
{
2626
Debug::resolve()->log($input);
2727
die();

packages/intl/src/MessageFormat/Formatter/MessageFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function format(string $message, mixed ...$variables): string
5757

5858
$this->variables = $this->parseLocalVariables($variables);
5959

60-
return $this->formatMessage($ast, $variables);
60+
return $this->formatMessage($ast);
6161
} catch (ParsingException $e) {
6262
throw new FormattingException('Failed to parse message.', [
6363
'message' => $message,

packages/process/src/Testing/ProcessTester.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function disableProcessExecution(): void
107107
*
108108
* @mago-expect lint:no-debug-symbols
109109
*/
110-
public function debugExecutedProcesses(): void
110+
public function debugExecutedProcesses(): never
111111
{
112112
dd($this->executor->executions);
113113
}

packages/support/src/Math/functions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ function max(array $numbers): null|int|float
380380
*/
381381
function maxva(int|float $first, int|float $second, int|float ...$rest): int|float
382382
{
383-
$max = $first > $second ? $first : $second;
383+
$max = \max($first, $second);
384384

385385
foreach ($rest as $number) {
386386
if ($number > $max) {
@@ -512,7 +512,7 @@ function min(array $numbers): null|float|int
512512
*/
513513
function minva(int|float $first, int|float $second, int|float ...$rest): int|float
514514
{
515-
$min = $first < $second ? $first : $second;
515+
$min = \min($first, $second);
516516

517517
foreach ($rest as $number) {
518518
if ($number < $min) {

packages/support/src/Str/ManipulatesString.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ public function pluralize(int|array|Countable $count = 2): self
128128
/**
129129
* Converts the string to its English singular form.
130130
*/
131-
public function singularize(int|array|Countable $count = 2): self
131+
public function singularize(): self
132132
{
133133
$this->ensurePluralizerInstalled(__METHOD__);
134134

135-
return $this->createOrModify(Intl\singularize($this->value, $count));
135+
return $this->createOrModify(Intl\singularize($this->value));
136136
}
137137

138138
/**

0 commit comments

Comments
 (0)