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

Optional parameter $upload declared before required parameter $contents is implicitly treated as a required parameter #422

Open
piridium opened this issue Nov 28, 2024 · 1 comment
Labels
bug keep Issues that should not be closed

Comments

@piridium
Copy link

piridium commented Nov 28, 2024

Bug Report

Current Behavior
Update fof/upload from 1.5.8 to 1.6.0 throws the following deprectation error:

Deprecated: Optional parameter $upload declared before required parameter $contents is implicitly treated as a required parameter in ./vendor/fof/upload/src/Adapters/Flysystem.php on line 55

Environment

  • Flarum version: 1.8.9
  • Extension version: ^1.6.0
  • Webserver: apache
  • Hosting environment: local development server
  • PHP version: 8.2.25

Possible solution(s)
Switching off deprecation warnings is not a good idea because
a) I want to have them enabled on the dev server, and
b) we should fix deprecations in order to not run into any problems in the future.

As of php 8.0 having an optional parameter followed by a required one is deprecated. (https://www.php.net/manual/en/migration80.deprecated.php)
It is recommended to use a explicit nullable type instead.

Suggestion:

# change line 55 from
public function upload(File $file, ?UploadedFile $upload = null, $contents)
# into
public function upload(File $file, ?UploadedFile $upload, $contents)

This gets rid of the error. And as UploadedFile is explicitly nullable, it should be ok, right? This is where I am not sure if we will run into any problems if a caller does not specify UploadedFile.

Additional Context
Duplicate of #407 which has already been closed.

@piridium piridium added the bug label Nov 28, 2024
@DavideIadeluca DavideIadeluca added the keep Issues that should not be closed label Nov 30, 2024
@piridium
Copy link
Author

This is still preventing us from upgrading to 1.6.0+. How is everybody else doing it? Did you guys all deactivate deprecation warnings?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug keep Issues that should not be closed
Projects
None yet
Development

No branches or pull requests

2 participants