![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/allure-framework/allure-php-commons/src/Io/ |
<?php declare(strict_types=1); namespace Qameta\Allure\Io; use Qameta\Allure\Io\Exception\IoFailedException; use Qameta\Allure\Io\Exception\StreamOpenFailedException; use Qameta\Allure\Io\Exception\StreamWriteFailedException; use Throwable; use function error_clear_last; use function error_get_last; use function fclose; use function fopen; use function fwrite; use function rewind; /** * @internal */ final class StringDataSource implements DataSourceInterface { public function __construct(private string $data) { } /** * @return resource */ public function createStream() { error_clear_last(); $link = 'php://temp'; $stream = @fopen($link, 'r+b'); if (false === $stream) { $error = error_get_last(); throw new StreamOpenFailedException($link, $error['message'] ?? null); } try { error_clear_last(); if (false === @fwrite($stream, $this->data)) { $error = error_get_last(); throw new StreamWriteFailedException($error['message'] ?? null); } error_clear_last(); if (false == @rewind($stream)) { $error = error_get_last(); throw new IoFailedException($error['message'] ?? null); } } catch (Throwable $e) { @fclose($stream); throw $e; } return $stream; } }