'nul', default => '/dev/null', }; $this->assertEquals( ['file', $null, 'r'], Stdio::null()->getDescriptiorSpec(0), ); $this->assertEquals( ['file', $null, 'w'], Stdio::null()->getDescriptiorSpec(1), ); $this->assertEquals( ['file', $null, 'w'], Stdio::null()->getDescriptiorSpec(2), ); } public function testInherit(): void { $this->assertEquals( STDIN, Stdio::inherit()->getDescriptiorSpec(0), ); $this->assertEquals( STDOUT, Stdio::inherit()->getDescriptiorSpec(1), ); $this->assertEquals( STDERR, Stdio::inherit()->getDescriptiorSpec(2), ); } public function testFile(): void { $this->assertEquals( ['file', '/foo/bar/baz', 'r'], Stdio::file('/foo/bar/baz', 'r')->getDescriptiorSpec(0), ); } public function testStream(): void { $this->assertEquals( STDOUT, Stdio::stream(STDOUT)->getDescriptiorSpec(0), ); } public function testThrowsOnInvalidStream(): void { $handle = fopen('php://memory', 'w'); $this->assertNotFalse($handle); fclose($handle); $this->expectException(InvalidArgumentException::class); /** @psalm-suppress InvalidArgument */ Stdio::stream($handle); } }