mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
chore: removes unused code
This commit is contained in:
@ -12,7 +12,6 @@ parameters:
|
|||||||
reportUnmatchedIgnoredErrors: true
|
reportUnmatchedIgnoredErrors: true
|
||||||
|
|
||||||
ignoreErrors:
|
ignoreErrors:
|
||||||
- '#Cannot instantiate interface PHPUnit\\Util\\Exception#'
|
|
||||||
- "#with a nullable type declaration#"
|
- "#with a nullable type declaration#"
|
||||||
- "#type mixed is not subtype of native#"
|
- "#type mixed is not subtype of native#"
|
||||||
- "#is not allowed to extend#"
|
- "#is not allowed to extend#"
|
||||||
|
|||||||
@ -1,62 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Pest\Support;
|
|
||||||
|
|
||||||
use PHPUnit\Util\Exception;
|
|
||||||
use PHPUnit\Util\Filesystem;
|
|
||||||
|
|
||||||
abstract class Printer implements \PHPUnit\Util\Printer
|
|
||||||
{
|
|
||||||
/** @var resource|bool */
|
|
||||||
private $stream;
|
|
||||||
|
|
||||||
private readonly bool $isPhpStream;
|
|
||||||
|
|
||||||
private bool $isOpen;
|
|
||||||
|
|
||||||
private function __construct(string $out)
|
|
||||||
{
|
|
||||||
if (str_starts_with($out, 'socket://')) {
|
|
||||||
$tmp = explode(':', str_replace('socket://', '', $out));
|
|
||||||
|
|
||||||
if (count($tmp) !== 2) {
|
|
||||||
throw new Exception(sprintf('"%s" does not match "socket://hostname:port" format', $out));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->stream = fsockopen($tmp[0], (int) $tmp[1]);
|
|
||||||
$this->isOpen = true;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->isPhpStream = str_starts_with($out, 'php://');
|
|
||||||
|
|
||||||
if (! $this->isPhpStream && ! Filesystem::createDirectory(dirname($out))) {
|
|
||||||
throw new Exception(sprintf('Directory "%s" was not created', dirname($out)));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->stream = fopen($out, 'wb');
|
|
||||||
$this->isOpen = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final public function print(string $buffer): void
|
|
||||||
{
|
|
||||||
assert($this->isOpen);
|
|
||||||
assert($this->stream !== false);
|
|
||||||
|
|
||||||
// @phpstan-ignore-next-line
|
|
||||||
fwrite($this->stream, $buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
final public function flush(): void
|
|
||||||
{
|
|
||||||
if ($this->isOpen && $this->isPhpStream && $this->stream !== false) {
|
|
||||||
// @phpstan-ignore-next-line
|
|
||||||
fclose($this->stream);
|
|
||||||
|
|
||||||
$this->isOpen = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user