Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

DateTime::getLastErrors() not returning false when no errors/warnings #9431

Closed
@Quirinus

Description

@Quirinus

Description

The following code:

<?php$dateTime = DateTime::createFromFormat('Y-m-d','2022-08-26');$lastErrors = DateTime::getLastErrors();var_dump($lastErrors);

Resulted in this output:

array(4) {  ["warning_count"]=>  int(0)  ["warnings"]=>  array(0) {  }  ["error_count"]=>  int(0)  ["errors"]=>  array(0) {  }}

But I expected this output instead:

bool(false)

Discussion

I'm not sure if this is a documentation issue or a PHP bug.

The documentation says that the return type ofDateTime::getLastErrors() isarray|false.
array is returned if there are errors and/or warnings, whilefalse is returned if there's no errors nor warnings.

In actuality,false is not returned even when there are no errors/warnings - thearray is returned instead, as can be seen in the above example.

Either the documentation needs to be corrected, or if it's correct, the bug needs to be fixed.

PHP Version

PHP 8.1.8, PHP 7.4.30

Operating System

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp