Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Filesystem: typehints prevent resources from being passed #45749

Closed
@tvdijen

Description

@tvdijen

Symfony version(s) affected

^5.0

Description

The type-hints that were added in 5.x for the methods in Filesystem prevent us from passing resources because the file-parameter is now type-hinted as string. It used to deal with resources before this change and even the phpdoc for the methods still mention the possibility to pass resources.

Support for resources was added in #29661

How to reproduce

    $fs = new Filesystem();
    $fs->appendToFile(
        fopen('php://stderr', 'w'),
        "We're logging an error!" . \PHP_EOL,
        false,
    );

Possible Solution

No response

Additional Context

My initial goal was to 'appendToFile' to file php://stderr, but on Windows that breaks on the call to mkdir().
As an alternative I tried to pass fopen('php://stderr', 'w') as a file, but then I hit the typehint restriction.

It's basically two different issues:

  1. Stuff breaking when file is php://stderr. I should probably be able to pass this as a file.
  2. Typehints preventing us from passing resources

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions