Skip to content

Commit 8d3ce94

Browse files
authored
refactor(core): various core package improvements and fixes (#1763)
1 parent c6e6867 commit 8d3ce94

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

packages/core/src/FrameworkKernel.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,16 @@ public function registerExceptionHandler(): self
256256
$handler = $this->container->get(ExceptionHandler::class);
257257

258258
set_exception_handler($handler->handle(...));
259-
set_error_handler(fn (int $code, string $message, string $filename, int $line) => $handler->handle(
260-
new ErrorException(
259+
set_error_handler(function (int $code, string $message, string $filename, int $line) use ($handler): bool {
260+
$handler->handle(new ErrorException(
261261
message: $message,
262262
code: $code,
263263
filename: $filename,
264264
line: $line,
265-
),
266-
), error_levels: E_ERROR);
265+
));
266+
267+
return true;
268+
}, error_levels: E_ERROR);
267269

268270
return $this;
269271
}

packages/core/src/Kernel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public static function boot(
3636
string $root,
3737
array $discoveryLocations = [],
3838
?Container $container = null,
39+
?string $internalStorage = null,
3940
): self;
4041

4142
public function shutdown(int|string $status = ''): never;

packages/core/src/Kernel/LoadConfig.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ private function scan(string $path, MutableArray $configPaths): void
100100
return;
101101
}
102102

103-
foreach (scandir($input, SCANDIR_SORT_NONE) as $subPath) {
103+
$subPaths = scandir($input, SCANDIR_SORT_NONE);
104+
if ($subPaths === false) {
105+
return;
106+
}
107+
108+
foreach ($subPaths as $subPath) {
104109
// `.` and `..` are skipped
105110
if ($subPath === '.' || $subPath === '..') {
106111
continue;

packages/core/src/Kernel/LoadDiscoveryClasses.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,12 @@ private function scan(DiscoveryLocation $location, array $discoveries, string $p
153153
return;
154154
}
155155

156-
foreach (scandir($input, SCANDIR_SORT_NONE) as $subPath) {
156+
$subPaths = scandir($input, SCANDIR_SORT_NONE);
157+
if ($subPaths === false) {
158+
return;
159+
}
160+
161+
foreach ($subPaths as $subPath) {
157162
// `.` and `..` are skipped
158163
if ($subPath === '.' || $subPath === '..') {
159164
continue;

tests/Integration/Http/HttpExceptionHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ public function __construct(FrameworkKernel $kernel)
5656
$this->container = $kernel->container;
5757
}
5858

59-
public static function boot(string $root, array $discoveryLocations = [], ?Container $container = null): self
59+
public static function boot(string $root, array $discoveryLocations = [], ?Container $container = null, ?string $internalStorage = null): self
6060
{
61-
return Kernel::boot($root, $discoveryLocations, $container); // @phpstan-ignore-line
61+
return Kernel::boot($root, $discoveryLocations, $container, $internalStorage); // @phpstan-ignore-line
6262
}
6363

6464
public function shutdown(int|string $status = ''): never

0 commit comments

Comments
 (0)