Skip to content

Commit e0797cd

Browse files
committed
chore: modernize and update types
1 parent 1000c99 commit e0797cd

18 files changed

+60
-68
lines changed

src/LibraryStarterKit/Answers.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,10 @@ final class Answers
6060
public bool $skipPrompts = false;
6161
public ?string $vendorName = null;
6262

63-
private string $saveToPath;
64-
private Filesystem $filesystem;
65-
66-
public function __construct(string $saveToPath, Filesystem $filesystem)
67-
{
68-
$this->saveToPath = $saveToPath;
69-
$this->filesystem = $filesystem;
63+
public function __construct(
64+
private readonly string $saveToPath,
65+
private readonly Filesystem $filesystem,
66+
) {
7067
$this->loadFile();
7168
}
7269

src/LibraryStarterKit/Console/InstallQuestions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
class InstallQuestions
4545
{
4646
/**
47-
* @return array<StarterKitQuestion & SymfonyQuestion>
47+
* @return list<StarterKitQuestion & SymfonyQuestion>
4848
*/
4949
public function getQuestions(Answers $answers): array
5050
{

src/LibraryStarterKit/Console/Question/CodeOfConduct.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ public function __construct(Answers $answers)
6363
$this->answers = $answers;
6464
}
6565

66+
/**
67+
* @return callable(string | null): string
68+
*/
6669
public function getNormalizer(): callable
6770
{
6871
$choiceMap = array_combine(self::CHOICES, self::CHOICE_IDENTIFIER_MAP);
@@ -76,6 +79,9 @@ public function getNormalizer(): callable
7679
};
7780
}
7881

82+
/**
83+
* @return callable(string | null): (string | null)
84+
*/
7985
public function getValidator(): callable
8086
{
8187
return function (?string $value): ?string {

src/LibraryStarterKit/Console/Question/CodeOfConductCommittee.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public function __construct(Answers $answers)
3636
$this->answers = $answers;
3737
}
3838

39+
/**
40+
* @return callable(string | null): (string | null)
41+
*/
3942
public function getValidator(): callable
4043
{
4144
return fn (?string $data): ?string => $data;

src/LibraryStarterKit/Console/Question/CopyrightYear.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public function getDefault(): float | bool | int | string | null
4545
return $this->getAnswers()->copyrightYear ?? date('Y');
4646
}
4747

48+
/**
49+
* @return callable(string | null): string
50+
*/
4851
public function getValidator(): callable
4952
{
5053
return function (?string $data): string {

src/LibraryStarterKit/Console/Question/EmailValidatorTool.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ trait EmailValidatorTool
2525
{
2626
private bool $isOptional = true;
2727

28+
/**
29+
* @return callable(string | null): (string | null)
30+
*/
2831
public function getValidator(): callable
2932
{
3033
return function (?string $data): ?string {

src/LibraryStarterKit/Console/Question/License.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ public function __construct(Answers $answers)
7979
$this->answers = $answers;
8080
}
8181

82+
/**
83+
* @return callable(string | null): string
84+
*/
8285
public function getNormalizer(): callable
8386
{
8487
$choiceMap = array_combine(self::CHOICES, self::CHOICE_IDENTIFIER_MAP);
@@ -92,6 +95,9 @@ public function getNormalizer(): callable
9295
};
9396
}
9497

98+
/**
99+
* @return callable(string | null): string
100+
*/
95101
public function getValidator(): callable
96102
{
97103
return function (?string $value): string {

src/LibraryStarterKit/Console/Question/PackageDescription.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public function __construct(Answers $answers)
3636
$this->answers = $answers;
3737
}
3838

39+
/**
40+
* @return callable(string | null): (string | null)
41+
*/
3942
public function getValidator(): callable
4043
{
4144
return fn (?string $data): ?string => $data;

src/LibraryStarterKit/Console/Question/PackageKeywords.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public function __construct(Answers $answers)
4343
$this->answers = $answers;
4444
}
4545

46+
/**
47+
* @return callable(string | null): list<string>
48+
*/
4649
public function getNormalizer(): callable
4750
{
4851
return function (?string $answer): array {

src/LibraryStarterKit/Console/Question/UrlValidatorTool.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Ramsey\Dev\LibraryStarterKit\Exception\InvalidConsoleInput;
1515

1616
use function filter_var;
17-
use function strpos;
17+
use function str_starts_with;
1818
use function trim;
1919

2020
use const FILTER_VALIDATE_URL;
@@ -26,6 +26,9 @@ trait UrlValidatorTool
2626
{
2727
private bool $isOptional = true;
2828

29+
/**
30+
* @return callable(string | null): (string | null)
31+
*/
2932
public function getValidator(): callable
3033
{
3134
return function (?string $data): ?string {
@@ -35,7 +38,7 @@ public function getValidator(): callable
3538

3639
if (
3740
filter_var((string) $data, FILTER_VALIDATE_URL)
38-
&& strpos((string) $data, 'http') === 0
41+
&& str_starts_with((string) $data, 'http')
3942
) {
4043
return $data;
4144
}

0 commit comments

Comments
 (0)