diff --git a/src/ProxyManager/GeneratorStrategy/FileWriterGeneratorStrategy.php b/src/ProxyManager/GeneratorStrategy/FileWriterGeneratorStrategy.php index 3cc826afa..44590aa6e 100644 --- a/src/ProxyManager/GeneratorStrategy/FileWriterGeneratorStrategy.php +++ b/src/ProxyManager/GeneratorStrategy/FileWriterGeneratorStrategy.php @@ -4,16 +4,12 @@ namespace ProxyManager\GeneratorStrategy; -use Closure; use Laminas\Code\Generator\ClassGenerator; use ProxyManager\Exception\FileNotWritableException; use ProxyManager\FileLocator\FileLocatorInterface; use Webimpress\SafeWriter\Exception\ExceptionInterface as FileWriterException; use Webimpress\SafeWriter\FileWriter; -use function restore_error_handler; -use function set_error_handler; - /** * Generator strategy that writes the generated classes to disk while generating them * @@ -22,13 +18,10 @@ class FileWriterGeneratorStrategy implements GeneratorStrategyInterface { protected FileLocatorInterface $fileLocator; - private Closure $emptyErrorHandler; public function __construct(FileLocatorInterface $fileLocator) { - $this->fileLocator = $fileLocator; - $this->emptyErrorHandler = static function (): void { - }; + $this->fileLocator = $fileLocator; } /** @@ -44,16 +37,12 @@ public function generate(ClassGenerator $classGenerator): string $className = $classGenerator->getNamespaceName() . '\\' . $classGenerator->getName(); $fileName = $this->fileLocator->getProxyFileName($className); - set_error_handler($this->emptyErrorHandler); - try { FileWriter::writeFile($fileName, "tempDir = tempnam(sys_get_temp_dir(), 'FileWriterGeneratorStrategyTest'); - $this->originalErrorHandler = static function (): bool { - throw new ErrorException(); - }; + $this->tempDir = tempnam(sys_get_temp_dir(), 'FileWriterGeneratorStrategyTest'); unlink($this->tempDir); mkdir($this->tempDir); - set_error_handler($this->originalErrorHandler); - } - - protected function tearDown(): void - { - self::assertSame($this->originalErrorHandler, set_error_handler(static function (): bool { - return true; - })); - restore_error_handler(); - restore_error_handler(); - - parent::tearDown(); } public function testGenerate(): void