[10.x] Enhancement of Interface Cloud: Addition of fileExists
method
#47723
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This pull request addresses a recurring PHPStan error that point out an undefined method, fileExists(), being called on the Illuminate\Contracts\Filesystem\Cloud interface.
This has been corrected by introducing a fileExists() method in the Cloud interface, which clarifies the contract for all classes that implement this interface. Consequently, it serves two essential tasks:
Fixes PHPStan error: Call to an undefined method Illuminate\Contracts\Filesystem\Cloud::fileExists(). when I using the
Storage::cloud()->fileExists($s3_relative_path)
to ensure the determine if a file exists.Makes the interface's responsibilities more explicit and precise.
Modified Files:
Illuminate\Contracts\Filesystem\Cloud
Tasks:
Add fileExists() method to the Cloud interface
Update all the classes that implement Cloud interface and provide an implementation for fileExists()
Testing:
After the correction:
All existing tests should pass without any error
No PHPStan errors should be thrown for Call to an undefined method Illuminate\Contracts\Filesystem\Cloud::fileExists(). ✏️ app/Console/Commands/File/Retrieve.php
Note: This PR doesn't include implementations for fileExists(). The classes that implement Cloud should provide their own.