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

[Bug]: Excel::fake() for Excel::Store Parameters Do Not Match #3683

Closed
1 task done
LarsaSolidor opened this issue Jul 21, 2022 · 3 comments
Closed
1 task done

[Bug]: Excel::fake() for Excel::Store Parameters Do Not Match #3683

LarsaSolidor opened this issue Jul 21, 2022 · 3 comments

Comments

@LarsaSolidor
Copy link

LarsaSolidor commented Jul 21, 2022

Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?

  • Yes, it's still reproducable

What version of Laravel Excel are you using?

3.1.40

What version of Laravel are you using?

9.11.0

What version of PHP are you using?

8.1.7

Describe your issue

The method signature for Excel::store does not match when faked, so using a named parameter for diskName tests fail with Unknown named parameter $diskName

store($export, $filePath, $diskName = null, $writerType = null, $diskOptions = []

But the method signature for the faked Excel::store, substituted when Excel::fake() is called is:

store($export, string $filePath, string $disk = null, string $writerType = null, $diskOptions = [])

$diskName <> $disk

How can the issue be reproduced?

Write some code that uses Excel::Store() and provide it a list of named parameters:

Excel::store(
                export: new CSVExport(),
                filePath: "A file name.csv",
                diskName: 'diskname',
                writerType: \Maatwebsite\Excel\Excel::CSV,
                diskOptions: ['visibility' => 'private']
            )

In a test, call Excel::fake() and run the above code

What should be the expected behaviour?

The test should not throw a Unknown named parameter $diskName parameter error when Excel is faked.

@patrickbrouwers
Copy link
Member

Please provide a PR with a suggested fix.
Please note that as we support multiple PHP versions, we never intended it to be used as named parameters.

@stale stale bot added the stale label Sep 19, 2022
@stale
Copy link

stale bot commented Sep 21, 2022

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.

@stale stale bot closed this as completed Sep 21, 2022
@eleftrik
Copy link

eleftrik commented Dec 4, 2023

Please provide a PR with a suggested fix. Please note that as we support multiple PHP versions, we never intended it to be used as named parameters.

I'm experiencing the same problem as @LarsaSolidor. So, does this mean that we shouldn't use named parameters?

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

No branches or pull requests

3 participants