Skip to content

Commit f78dce7

Browse files
committed
chore: address static analysis issues
1 parent 21f80a3 commit f78dce7

File tree

9 files changed

+30
-34
lines changed

9 files changed

+30
-34
lines changed

src/LibraryStarterKit/Setup.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ public function getVerbosity(): int
122122
* Returns an instance used for executing a system command
123123
*
124124
* @param string[] $command
125-
*
126-
* @phpstan-ignore-next-line
127125
*/
128126
public function getProcess(array $command): Process
129127
{

src/LibraryStarterKit/Task/Builder/RenameTemplates.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public function build(): void
4141
{
4242
$this->getConsole()->section('Renaming template files');
4343

44-
/** @var SplFileInfo $template */
4544
foreach ($this->getTemplatesFinder() as $template) {
4645
$this->removeTemplateExtension($template);
4746
}

src/LibraryStarterKit/Task/Builder/UpdateComposerJson.php

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
use Ramsey\Dev\LibraryStarterKit\Task\Builder;
2626
use RuntimeException;
27-
use Symfony\Component\Finder\SplFileInfo;
2827

2928
use function in_array;
3029
use function json_decode;
@@ -37,6 +36,10 @@
3736

3837
/**
3938
* Updates values in the composer.json file
39+
*
40+
* @psalm-type ComposerAuthorType = array{name: string, email?: string | null, homepage?: string | null}
41+
* @psalm-type ComposerAutoloadType = array{psr-4?: array<string, string>}
42+
* @psalm-type ComposerType = array{name: string, description: string, type: string, keywords: string[], license: string | null, authors: ComposerAuthorType[], require?: array<string, string>, require-dev?: array<string, string>, autoload?: ComposerAutoloadType, autoload-dev?: ComposerAutoloadType, scripts?: array<string, string | string[]>, scripts-descriptions?: array<string, string>, suggest?: array<string, string>}
4043
*/
4144
class UpdateComposerJson extends Builder
4245
{
@@ -63,7 +66,7 @@ public function build(): void
6366
$this->getConsole()->section('Updating composer.json');
6467

6568
/**
66-
* @var array<string, mixed>|null $composer
69+
* @psalm-var ComposerType|null $composer
6770
*/
6871
$composer = json_decode($this->getComposerContents(), true);
6972
if ($composer === null) {
@@ -122,7 +125,6 @@ private function getComposerContents(): string
122125

123126
$composerContents = null;
124127

125-
/** @var SplFileInfo $file */
126128
foreach ($finder as $file) {
127129
$composerContents = $file->getContents();
128130

@@ -137,12 +139,12 @@ private function getComposerContents(): string
137139
}
138140

139141
/**
140-
* @param array<string, mixed> $composer
142+
* @psalm-param ComposerType $composer
141143
*/
142144
private function buildAuthors(array &$composer): void
143145
{
144-
$author = [];
145-
$author['name'] = $this->getAnswers()->authorName;
146+
/** @var ComposerAuthorType $author */
147+
$author = ['name' => $this->getAnswers()->authorName];
146148

147149
if (trim((string) $this->getAnswers()->authorEmail) !== '') {
148150
$author['email'] = $this->getAnswers()->authorEmail;
@@ -156,73 +158,61 @@ private function buildAuthors(array &$composer): void
156158
}
157159

158160
/**
159-
* @param array<string, mixed> $composer
161+
* @psalm-param ComposerType $composer
160162
*/
161163
private function buildRequire(array &$composer): void
162164
{
163165
if (!isset($composer['require'])) {
164166
return;
165167
}
166168

167-
/** @var array<string, string> $require */
168-
$require = $composer['require'];
169-
170169
$composer['require'] = $this->filterPropertiesByWhitelist(
171-
$require,
170+
$composer['require'],
172171
self::WHITELIST_REQUIRE,
173172
);
174173
}
175174

176175
/**
177-
* @param array<string, mixed> $composer
176+
* @psalm-param ComposerType $composer
178177
*/
179178
private function buildRequireDev(array &$composer): void
180179
{
181180
if (!isset($composer['require-dev'])) {
182181
return;
183182
}
184183

185-
/** @var array<string, string> $requireDev */
186-
$requireDev = $composer['require-dev'];
187-
188184
$composer['require-dev'] = $this->filterPropertiesByWhitelist(
189-
$requireDev,
185+
$composer['require-dev'],
190186
self::WHITELIST_REQUIRE_DEV,
191187
);
192188
}
193189

194190
/**
195-
* @param array<string, mixed> $composer
191+
* @psalm-param ComposerType $composer
196192
*/
197193
private function buildAutoload(array &$composer): void
198194
{
199195
if (!isset($composer['autoload']['psr-4'])) {
200196
return;
201197
}
202198

203-
/** @var array<string, string> $autoload */
204-
$autoload = $composer['autoload']['psr-4'];
205-
206199
$composer['autoload']['psr-4'] = $this->filterPropertiesByWhitelist(
207-
$autoload,
200+
$composer['autoload']['psr-4'],
208201
self::WHITELIST_AUTOLOAD,
209202
);
210203
}
211204

212205
/**
213-
* @param array<string, mixed> $composer
206+
* @psalm-param ComposerType $composer
214207
*/
215208
private function buildAutoloadDev(array &$composer): void
216209
{
217210
if (!isset($composer['autoload-dev']['psr-4'])) {
218211
return;
219212
}
220213

221-
/** @var array<string, string> $autoloadDev */
222-
$autoloadDev = $composer['autoload-dev']['psr-4'];
223-
224214
$composer['autoload-dev']['psr-4'] = $this->filterPropertiesByWhitelist(
225-
$autoloadDev,
215+
$composer['autoload-dev']['psr-4'],
226216
self::WHITELIST_AUTOLOAD_DEV,
227217
);
228218
}

src/LibraryStarterKit/Task/Builder/UpdateNamespace.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ private function getSourceFiles(): array
9595
->depth('== 0')
9696
->name('composer.json');
9797

98-
/** @var SplFileInfo $file */
9998
foreach ($composerFinder as $file) {
10099
$files[] = $file;
101100

src/LibraryStarterKit/Task/Builder/UpdateReadme.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
use Ramsey\Dev\LibraryStarterKit\Task\Builder;
2626
use RuntimeException;
27-
use Symfony\Component\Finder\SplFileInfo;
2827

2928
use function array_keys;
3029
use function array_values;
@@ -81,7 +80,6 @@ private function getReadmeContents(): string
8180

8281
$readmeContents = null;
8382

84-
/** @var SplFileInfo $file */
8583
foreach ($finder as $file) {
8684
$readmeContents = $file->getContents();
8785

src/LibraryStarterKit/Task/Builder/UpdateSourceFileHeaders.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ public function build(): void
5252
$headerLines = array_filter($headerLines);
5353
$newFileHeader = implode("\n", $headerLines);
5454

55-
/** @var SplFileInfo $file */
5655
foreach ($this->getSourceFilesFinder() as $file) {
5756
$this->replaceSourceFileHeader($file, $newFileHeader);
5857
}

src/LibraryStarterKit/Wizard.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,10 @@ public static function newApplication(): Application
261261

262262
public static function start(Event $event): void
263263
{
264-
$appPath = dirname((string) $event->getComposer()->getConfig()->get('vendor-dir'));
264+
/** @var string $vendorDir */
265+
$vendorDir = $event->getComposer()->getConfig()->get('vendor-dir');
266+
267+
$appPath = dirname($vendorDir);
265268

266269
$projectName = strtolower(basename((string) realpath($appPath)));
267270
$projectName = (string) preg_replace('/[^a-z0-9]/', '-', $projectName);

tests/LibraryStarterKit/Console/Question/QuestionTestCase.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44

55
namespace Ramsey\Test\Dev\LibraryStarterKit\Console\Question;
66

7+
use Ramsey\Dev\LibraryStarterKit\Console\Question\StarterKitQuestion;
78
use Ramsey\Test\Dev\LibraryStarterKit\TestCase;
9+
use Symfony\Component\Console\Question\Question;
810

911
abstract class QuestionTestCase extends TestCase
1012
{
13+
/**
14+
* @return class-string<Question & StarterKitQuestion>
15+
*/
1116
abstract protected function getTestClass(): string;
1217

1318
abstract protected function getQuestionName(): string;

tests/LibraryStarterKit/WindowsSafeTextDriver.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
class WindowsSafeTextDriver implements Driver
1717
{
1818
/**
19+
* @param string $data
20+
*
1921
* @inheritDoc
2022
*/
2123
public function serialize($data): string
@@ -32,6 +34,9 @@ public function extension(): string
3234
}
3335

3436
/**
37+
* @param string $expected
38+
* @param string $actual
39+
*
3540
* @inheritDoc
3641
*/
3742
public function match($expected, $actual): void

0 commit comments

Comments
 (0)