Skip to content

Commit 6d706c5

Browse files
committed
Fix linter issues
1 parent 7f0bfe0 commit 6d706c5

18 files changed

Lines changed: 139 additions & 54 deletions

src/Action/AssemblyAction.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/**
1010
* @template TStatus of \UnitEnum
11+
*
1112
* @template-implements ActionInterface<TStatus>
1213
*/
1314
abstract readonly class AssemblyAction implements ActionInterface

src/Action/ClearBuildAssemblyDirectoryAction.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function process(Configuration $config): iterable
1818
$directory = $this->assembly->getBuildDirectory($config);
1919

2020
if (\is_dir($directory)) {
21+
/** @var \SplFileInfo $file */
2122
foreach ($this->getIterator($directory) as $file) {
2223
if ($file->isDir()) {
2324
yield $file->getPathname() => ClearBuildAssemblyDirectoryStatus::Cleaning;
@@ -41,7 +42,7 @@ public function process(Configuration $config): iterable
4142
}
4243

4344
/**
44-
* @return \RecursiveIteratorIterator<array-key, \SplFileInfo>
45+
* @return \RecursiveIteratorIterator<\RecursiveDirectoryIterator>
4546
*/
4647
private function getIterator(string $directory): \RecursiveIteratorIterator
4748
{

src/Action/CompileAction.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@ public function process(Configuration $config): iterable
2121

2222
$targetPathname = $this->getBinaryTargetPathname($config);
2323

24-
$targetStream = \fopen($targetPathname, 'wb+');
24+
$targetStream = @\fopen($targetPathname, 'wb+');
25+
26+
if ($targetStream === false) {
27+
throw new \RuntimeException(\sprintf(
28+
'Unable to create target binary "%s"',
29+
$targetPathname,
30+
));
31+
}
32+
2533
\flock($targetStream, \LOCK_EX);
2634

2735
$this->appendSfxArchive($targetStream);
@@ -51,7 +59,15 @@ private function getBinaryTargetPathname(Configuration $config): string
5159
*/
5260
private function appendSource(mixed $stream, Configuration $config): void
5361
{
54-
$sourceStream = \fopen($config->pharPathname, 'rb');
62+
$sourceStream = @\fopen($config->pharPathname, 'rb');
63+
64+
if ($sourceStream === false) {
65+
throw new \RuntimeException(\sprintf(
66+
'Unable to open application phar file "%s"',
67+
$config->pharPathname,
68+
));
69+
}
70+
5571
\flock($sourceStream, \LOCK_SH);
5672

5773
\stream_copy_to_stream($sourceStream, $stream);
@@ -78,7 +94,15 @@ private function appendSfxArchive(mixed $stream): void
7894
{
7995
$archive = $this->getSfxArchivePathname($this->assembly);
8096

81-
$archiveStream = \fopen($archive, 'rb');
97+
$archiveStream = @\fopen($archive, 'rb');
98+
99+
if ($archiveStream === false) {
100+
throw new \RuntimeException(\sprintf(
101+
'Unable to open application SFX file "%s"',
102+
$archive,
103+
));
104+
}
105+
82106
\flock($archiveStream, \LOCK_SH);
83107

84108
\stream_copy_to_stream($archiveStream, $stream);

src/Action/CreateBoxConfigAction.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ public function process(Configuration $config): iterable
2626
yield CreateBoxConfigStatus::Created;
2727
}
2828

29+
/**
30+
* @return list<array{
31+
* name?: non-empty-string,
32+
* in?: non-empty-string
33+
* }>
34+
*/
2935
private function getBoxFinderConfig(Configuration $config): array
3036
{
3137
$finder = [];
@@ -53,6 +59,9 @@ private function getBoxFinderConfig(Configuration $config): array
5359
return $finder;
5460
}
5561

62+
/**
63+
* @return list<non-empty-string>
64+
*/
5665
private function getBoxFilesConfig(Configuration $config): array
5766
{
5867
$files = [];
@@ -68,6 +77,9 @@ private function getBoxFilesConfig(Configuration $config): array
6877
return $files;
6978
}
7079

80+
/**
81+
* @return list<non-empty-string>
82+
*/
7183
private function getBoxDirectoriesConfig(Configuration $config): array
7284
{
7385
$directories = [];
@@ -83,6 +95,9 @@ private function getBoxDirectoriesConfig(Configuration $config): array
8395
return $directories;
8496
}
8597

98+
/**
99+
* @return array<non-empty-string, mixed>
100+
*/
86101
private function getBoxConfig(Configuration $config): array
87102
{
88103
$finder = $this->getBoxFinderConfig($config);

src/Action/CreateBoxStubAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function process(Configuration $config): iterable
1818
$stub = \str_replace(
1919
search: ['{name}', '{entrypoint}'],
2020
replace: [$config->name, $config->entrypoint],
21-
subject: \file_get_contents(__DIR__ . '/../../resources/stub.php'),
21+
subject: (string) @\file_get_contents(__DIR__ . '/../../resources/stub.php'),
2222
);
2323

2424
\file_put_contents($config->boxStubPathname, $stub);

src/Action/DownloadBoxAction.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ public function process(Configuration $config): iterable
2828
return yield DownloadBoxStatus::Complete;
2929
}
3030

31-
$localBoxStream = \fopen($config->boxPharPathname, 'w+b');
31+
$localBoxStream = @\fopen($config->boxPharPathname, 'w+b');
32+
33+
if ($localBoxStream === false) {
34+
throw new \RuntimeException(\sprintf(
35+
'Unable to create humbug/box phar package in "%s"',
36+
$config->boxPharPathname,
37+
));
38+
}
39+
3240
\flock($localBoxStream, \LOCK_EX);
3341

3442
try {

src/Assembly/Assembly.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
namespace Boson\Component\Compiler\Assembly;
66

7+
use Boson\Component\Compiler\Assembly\EditionInterface as PhpEditionInterface;
78
use Boson\Component\Compiler\Configuration;
89
use Boson\Component\CpuInfo\ArchitectureInterface as CpuArchitectureInterface;
910
use Boson\Component\OsInfo\FamilyInterface as OsFamilyInterface;
10-
use Boson\Component\Compiler\Assembly\EditionInterface as PhpEditionInterface;
1111

1212
final readonly class Assembly implements \Stringable
1313
{

src/Assembly/AssemblyCollection.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,6 @@ final class AssemblyCollection implements \IteratorAggregate, \Countable
1919
*/
2020
private array $assemblies;
2121

22-
/**
23-
* @phpstan-type OSFamilyType non-empty-string
24-
* @phpstan-type CPUArchitectureType non-empty-string
25-
* @phpstan-type PHPEditionType non-empty-string
26-
* @phpstan-type FrontendBinaryType non-empty-string
27-
* @phpstan-type BackendBinaryType non-empty-string
28-
*
29-
* @var array<OSFamilyType, array<CPUArchitectureType, array<PHPEditionType, array{
30-
* FrontendBinaryType,
31-
* BackendBinaryType
32-
* }>>>
33-
*/
3422
private const array BUILTIN_ASSEMBLIES = [
3523
'linux' => [
3624
'arm64' => [
@@ -60,6 +48,9 @@ final class AssemblyCollection implements \IteratorAggregate, \Countable
6048
],
6149
];
6250

51+
/**
52+
* @param iterable<mixed, Assembly> $assemblies
53+
*/
6354
public function __construct(iterable $assemblies)
6455
{
6556
$this->assemblies = \iterator_to_array($assemblies, false);

src/Assembly/Edition.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
/**
3232
* @api
33+
*
34+
* @param non-empty-string $name
3335
*/
3436
public static function tryFrom(string $name): ?BuiltinEdition
3537
{
@@ -38,6 +40,8 @@ public static function tryFrom(string $name): ?BuiltinEdition
3840

3941
/**
4042
* @api
43+
*
44+
* @param non-empty-string $name
4145
*/
4246
public static function from(string $name): EditionInterface
4347
{
@@ -46,6 +50,7 @@ public static function from(string $name): EditionInterface
4650

4751
/**
4852
* @api
53+
*
4954
* @return non-empty-list<EditionInterface>
5055
*/
5156
public static function cases(): array

src/Assembly/Edition/BuiltinEdition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Boson\Component\Compiler\Assembly\EditionInterface;
99

1010
/**
11-
* @internal this is an internal library class, please do not use it in your code.
11+
* @internal this is an internal library class, please do not use it in your code
1212
* @psalm-internal Boson\Component\Compiler\Assembly
1313
*/
1414
final readonly class BuiltinEdition implements EditionInterface

0 commit comments

Comments
 (0)