tmpfile

Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Creates a temporary file
<?php tmpfile(): resource|false
<?php         $this->storage = Storage::disk($this->disk);

        $this->path = FileUploadConfiguration::path($path, false);



        $tmpFile = tmpfile();



        parent::__construct(stream_get_meta_data($tmpFile)['uri'], $this->path);
<?php     public function dimensions()

    {

        stream_copy_to_stream($this->storage->readStream($this->path), $tmpFile = tmpfile());



        return @getimagesize(stream_get_meta_data($tmpFile)['uri']);

    }
<?php             return $this->createWithContent($name, $kilobytes);

        }



        return tap(new File($name, tmpfile()), function ($file) use ($kilobytes, $mimeType) {

            $file->sizeToReport = $kilobytes * 1024;

            $file->mimeTypeToReport = $mimeType;

        });
<?php     public function createWithContent($name, $content)

    {

        $tmpfile = tmpfile();



        fwrite($tmpfile, $content);
<?php             throw new LogicException('GD extension is not installed.');

        }



        return tap(tmpfile(), function ($temp) use ($width, $height, $extension) {

            ob_start();



            $extension = in_array($extension, ['jpeg', 'png', 'gif', 'webp', 'wbmp', 'bmp'])
<?php     protected function dump($value)

    {

        $outputFile = stream_get_meta_data(tmpfile())['uri'];



        $dumper = new HtmlDumper(

            '/my-work-directory',
<?php     public static function jsonErrorDataProvider()

    {


        $resource = tmpfile();




        $recursiveObject = new stdClass;
<?php     {

        $this->fails(

            File::image()->dimensions(Rule::dimensions()->width(100)->height(100)),

            new UploadedFileWithCustomImageSizeMethod(stream_get_meta_data($tmpFile = tmpfile())['uri'], 'foo.png'),

            ['validation.dimensions'],

        );
<?php         $this->passes(

            File::image()->dimensions(Rule::dimensions()->width(200)->height(200)),

            new UploadedFileWithCustomImageSizeMethod(stream_get_meta_data($tmpFile = tmpfile())['uri'], 'foo.png'),

        );

    }
<?php use PHPUnit\Framework\ExpectationFailedException;



$resource = tmpfile();



afterAll(function () use ($resource) {

    fclose($resource);
<?php     private function createTemporaryFile()

    {

        $handle = @tmpfile();



        if ($handle === false) {

            throw CannotCreateTemporaryFile::new(error_get_last());
<?php         return [

            [[]],

            [new stdClass()],

            [tmpfile()],

        ];

    }
<?php         $source = $this->getTestDecoder($resource);

        $this->assertTrue($source->isGdResource());



        $source = $this->getTestDecoder(tmpfile());

        $this->assertFalse($source->isGdResource());



        $source = $this->getTestDecoder(null);
<?php     public function invalidStreamInput(): Generator

    {

        $handle = tmpfile();

        fclose($handle);

        yield "resource that is not open" => [$handle];

        yield "something that is not a resource" => [false];
<?php     public function not_being_able_to_stream_write_a_file(): void

    {

        $handle = tmpfile();

        $this->firstStubAdapter->stageException('writeStream', 'file.txt', UnableToWriteFile::atLocation('file.txt'));



        $this->expectException(UnableToWriteFile::class);