errorHandler === null) { return; } set_error_handler($this->errorHandler, E_WARNING); } /** * @covers \phpDocumentor\Reflection\Utils::pregSplit */ public function testSimplePregSplit(): void { $result = Utils::pregSplit('/\s/', 'word split'); $this->assertSame(['word', 'split'], $result); } /** * @covers \phpDocumentor\Reflection\Utils::pregSplit */ public function testPregSplitThrowsOnError(): void { //We need to disable the error handler for phpunit... because we expect some errors here $this->errorHandler = set_error_handler( static function (int $i, string $s, string $s2, int $x, ?array $trace = null): bool { return true; }, E_WARNING ); $this->expectException(PcreException::class); Utils::pregSplit('~InvalidRegular)Expression~', 'some word'); } }