Skip to content

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

Description

@finwe

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions