Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling __toString() on FileUpload class directly can often result in type/uninitialized typed property error #234

Open
finwe opened this issue Mar 5, 2024 · 1 comment

Comments

@finwe
Copy link

finwe commented Mar 5, 2024

Version: 3.2.4, 3.3.0

Bug Description

When a file is not uploaded in a form, an empty FileUpload with uninitialized properties is returned to the Presenter. Once the data is processed by underlying code, by calling the __toString() method on the object, which is typed as returning string, it will, based on version, either end on null returned, expected string, or $tmpName must not be accessed before initialization

Expected Behavior

The method that should return a string returns a string.

Possible Solution

  • Initialize the properties of FileUpload with values, namely $tmpName with empty string
    • Alternatively make the properties nullable and initialize with nulls
  • Cast the $tmpName to string in the toString method so that no error is thrown.

Happy to prepare a PR once I know what the preferred solution is.

@dg
Copy link
Member

dg commented Mar 6, 2024

The uninitialized FileUpload is completely stupid. I've had it in my TODO for like five years, so if you could fix the whole thing, that would be really cool. Or at least the __toString(). Which way to solve it probably doesn't matter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants