Skip to content

Commit 2400896

Browse files
committed
apply handle Fatal Error with spl_autoload_register
1 parent 795f785 commit 2400896

File tree

5 files changed

+32
-13
lines changed

5 files changed

+32
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ coverage.json
55
bin
66
.php_cs.cache
77
.vscode/
8+
build/logs/*

kahlan-config.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
<?php // kahlan-config.php
22

3-
use App\Kernel;
43
use Kahlan\Filter\Filters;
4+
use Kahlan\Reporter\Coverage;
5+
use Kahlan\Reporter\Coverage\Driver\Xdebug;
56

6-
Filters::apply($this, 'bootstrap', function($next) {
7-
8-
require __DIR__ . '/vendor/autoload.php';
9-
10-
$root = $this->suite()->root();
11-
$root->beforeAll(function () {
12-
// allow('spl_autoload_register')->toBeCalled()->andReturn(null);
13-
});
14-
15-
return $next();
7+
Filters::apply($this, 'coverage', function($next) {
8+
if (! extension_loaded('xdebug')) {
9+
return;
10+
}
1611

12+
$reporters = $this->reporters();
13+
$coverage = new Coverage([
14+
'verbosity' => $this->commandLine()->get('coverage'),
15+
'driver' => new Xdebug(),
16+
'path' => $this->commandLine()->get('src'),
17+
'exclude' => [
18+
'src/HeroAutoload.php',
19+
],
20+
'colors' => ! $this->commandLine()->get('no-colors')
21+
]);
22+
$reporters->add('coverage', $coverage);
1723
});

src/HeroAutoload.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ public static function handle(string $class)
1414
return;
1515
}
1616

17+
if (\in_array(
18+
$class,
19+
[
20+
'error_reporting',
21+
'error_get_last',
22+
'ErrorHeroModuleLogger',
23+
'ZendDeveloperTools\\ProfilerEvent',
24+
]
25+
)) {
26+
return;
27+
}
28+
1729
throw new RuntimeException(sprintf(
1830
'class %s not found',
1931
$class

src/Listener/Mvc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function phpError(MvcEvent $e) : void
5757
{
5858
\register_shutdown_function([$this, 'execOnShutdown']);
5959
\set_error_handler([$this, 'phpErrorHandler']);
60-
//\spl_autoload_register([HeroAutoload::class, 'handle']);
60+
\spl_autoload_register([HeroAutoload::class, 'handle']);
6161
}
6262

6363
public function exceptionError(MvcEvent $e) : void

src/Middleware/Expressive.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function phpError() : void
6161
{
6262
\register_shutdown_function([$this, 'execOnShutdown']);
6363
\set_error_handler([$this, 'phpErrorHandler']);
64-
//\spl_autoload_register([HeroAutoload::class, 'handle']);
64+
\spl_autoload_register([HeroAutoload::class, 'handle']);
6565
}
6666

6767
/**

0 commit comments

Comments
 (0)