-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Fix facade diskName #4020
Fix facade diskName #4020
Conversation
The facade method currently has a PHPDoc for `$disk` while the actual implementation accepts `$diskName` as an argument.
Does it cause issues that the ExcelFake store() method refers to disk instead of diskName? |
It causes PHPStan to think the code is incorrect:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you fix it everywhere it would be consistent
@@ -12,7 +12,7 @@ | |||
|
|||
/** | |||
* @method static BinaryFileResponse download(object $export, string $fileName, string $writerType = null, array $headers = []) | |||
* @method static bool store(object $export, string $filePath, string $disk = null, string $writerType = null, $diskOptions = []) | |||
* @method static bool store(object $export, string $filePath, string $diskName = null, string $writerType = null, $diskOptions = []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However changing it in other places like Exportable would make it a breaking change, as someone doing the following
(new MyExport)->store('path', disk: 'public')
would get an error if we can it to diskname.
I think for now it would probably be best to just update the facade docblock and leave the rest until a major release with upgrade notes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we leave everything as is, and just add a fallback option to Excel@store, so disk: 'name'
would work as well via the facade.
public function store($export, string $filePath, string $diskName = null, string $writerType = null, $diskOptions = [], string $disk =null)
That way no breaking change, but ensuring consistency with the facade and the other locations. (Honestly absolutely no idea why it isn't consistent, it of course didn't matter before named params)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds fine to me, then we can drop one of the two in a major version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes exactly, can you update your PR? Can you add a comment to that docblock that it serves as a fallback for named params consistency?
This bug report has been automatically closed because it has not had recent activity. If this is still an active bug, please comment to reopen. Thank you for your contributions. |
Replaced by 81c921d |
1️⃣ Why should it be added? What are the benefits of this change?
Currently the facade has an incorrect PHPDoc stating that the
store
method ofExcel.php
accepts the$disk
argument while it actually accepts the$diskName
argument. This causes confusing behaviour, for example incorrect IDE autocompletion or PHPStan errors2️⃣ Does it contain multiple, unrelated changes? Please separate the PRs out.
No
3️⃣ Does it include tests, if possible?
No
4️⃣ Any drawbacks? Possible breaking changes?
No breaking change.
A drawback is that other methods in Excel.php use
$disk
instead of$diskName
, so using$disk
instead of$diskName
would be more consistent, but that would be a breaking change. Using$diskName
everywhere would make the most sense, since we're not receiving an instance of a Disk, but that would be an even bigger breaking change I think.5️⃣ Mark the following tasks as done:
6️⃣ Thanks for contributing! 🙌
yw :)