Skip to content

Commit cd9fd6a

Browse files
committed
apply CallableThisArrayToAnonymousFunctionRector
1 parent 97195fc commit cd9fd6a

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

rector.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_80);
3030

3131
$parameters->set(Option::SKIP, [
32-
CallableThisArrayToAnonymousFunctionRector::class,
32+
CallableThisArrayToAnonymousFunctionRector::class => [
33+
__DIR__ . '/spec',
34+
],
3335
UnSpreadOperatorRector::class,
3436
]);
3537
};

src/HeroTrait.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ public function phpError(...$args): void
4949
ob_end_flush();
5050
}
5151

52-
ob_start([$this, 'phpFatalErrorHandler']);
52+
ob_start(fn(string $buffer): string => $this->phpFatalErrorHandler($buffer));
5353
register_shutdown_function([$this, 'execOnShutdown']);
54-
set_error_handler([$this, 'phpErrorHandler']);
54+
set_error_handler(function (int $errorType, string $errorMessage, string $errorFile, int $errorLine): void {
55+
$this->phpErrorHandler($errorType, $errorMessage, $errorFile, $errorLine);
56+
});
5557
}
5658

5759
private static function isUncaught(array $error): bool

src/Listener/Mvc.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,17 @@ public function attach(EventManagerInterface $events, $priority = 1): void
4343
}
4444

4545
// exceptions
46-
$this->listeners[] = $events->attach(MvcEvent::EVENT_RENDER_ERROR, [$this, 'exceptionError']);
47-
$this->listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH_ERROR, [$this, 'exceptionError'], 100);
46+
$this->listeners[] = $events->attach(MvcEvent::EVENT_RENDER_ERROR, function (MvcEvent $e): void {
47+
$this->exceptionError($e);
48+
});
49+
$this->listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH_ERROR, function (MvcEvent $e): void {
50+
$this->exceptionError($e);
51+
}, 100);
4852

4953
// php errors
50-
$this->listeners[] = $events->attach(MvcEvent::EVENT_BOOTSTRAP, [$this, 'phpError']);
54+
$this->listeners[] = $events->attach(MvcEvent::EVENT_BOOTSTRAP, function ($args): void {
55+
$this->phpError($args);
56+
});
5157
}
5258

5359
public function exceptionError(MvcEvent $e): void

src/Module.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ class Module
1717
public function init(ModuleManager $moduleManager): void
1818
{
1919
$eventManager = $moduleManager->getEventManager();
20-
$eventManager->attach(ModuleEvent::EVENT_LOAD_MODULES_POST, [$this, 'doctrineTransform']);
21-
$eventManager->attach(ModuleEvent::EVENT_MERGE_CONFIG, [$this, 'errorPreviewPageHandler'], 101);
20+
$eventManager->attach(ModuleEvent::EVENT_LOAD_MODULES_POST, function (ModuleEvent $event): void {
21+
$this->doctrineTransform($event);
22+
});
23+
$eventManager->attach(ModuleEvent::EVENT_MERGE_CONFIG, function (ModuleEvent $event): void {
24+
$this->errorPreviewPageHandler($event);
25+
}, 101);
2226
}
2327

2428
public function doctrineTransform(ModuleEvent $event): void

0 commit comments

Comments
 (0)