Skip to content

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
Co-authored-by: kenjis <kenji.uui@gmail.com>
@kenjis kenjis merged commit 9597237 into codeigniter4:develop Jul 25, 2024
@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