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

docs: [File Instance] RunTimeException if file does not exist #9037

Merged
merged 4 commits into from
Jul 25, 2024
Merged

docs: [File Instance] RunTimeException if file does not exist #9037

merged 4 commits into from
Jul 25, 2024

Conversation

christianberkman
Copy link
Contributor

Description
File::getSize and File::getSizeByUnit() may cause a RunTimeException if the file does not exist or an error occurs. From the original docblock my expectation was that the functions would return false on an error (e.g. file does not exist), but the called SplFileInfo::getSize() throws a runtime error if the file does not exist.

From the PHP docs

The filesize in bytes on success, or false on failure.
A RuntimeException will be thrown if the file does not exist or an error occurs.

From the PHP docs it is not quite clear to me when to expect an exception and when to expect false.

If return of false on any error is desired, I am happy to submit a PR to catch the exception.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis added the documentation Pull requests for documentation only label Jul 10, 2024
@kenjis kenjis merged commit 9597237 into codeigniter4:develop Jul 25, 2024
41 of 42 checks passed
@kenjis
Copy link
Member

kenjis commented Jul 25, 2024

@christianberkman Thank you!

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

Successfully merging this pull request may close these issues.

3 participants