Skip to content

Commit 3afbab9

Browse files
committed
DateTimeInstantiationRule - do not report warnings
1 parent 5b07282 commit 3afbab9

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/Rules/DateTimeInstantiationRule.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ public function processNode(Node $node, Scope $scope): array
4646
}
4747
$lastErrors = DateTime::getLastErrors();
4848
if ($lastErrors !== false) {
49-
foreach ($lastErrors['warnings'] as $warning) {
50-
$errors[] = RuleErrorBuilder::message(sprintf(
51-
'Instantiating %s with %s produces a warning: %s',
52-
(string) $node->class,
53-
$dateString,
54-
$warning
55-
))->build();
56-
}
5749
foreach ($lastErrors['errors'] as $error) {
5850
$errors[] = RuleErrorBuilder::message(sprintf(
5951
'Instantiating %s with %s produces an error: %s',

tests/PHPStan/Rules/DateTimeInstantiationRuleTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ public function test(): void
2222
'Instantiating DateTime with 2020.11.17 produces an error: Double time specification',
2323
3,
2424
],
25-
[
25+
/*[
2626
'Instantiating DateTimeImmutable with asdfasdf produces a warning: Double timezone specification',
2727
5,
28-
],
28+
],*/
2929
[
3030
'Instantiating DateTimeImmutable with asdfasdf produces an error: The timezone could not be found in the database',
3131
5,
@@ -38,10 +38,10 @@ public function test(): void
3838
'Instantiating DateTimeImmutable with 2020.11.18 produces an error: Double time specification',
3939
17,
4040
],
41-
[
41+
/*[
4242
'Instantiating DateTime with 2020-04-31 produces a warning: The parsed date was invalid',
4343
20,
44-
],
44+
],*/
4545
]
4646
);
4747
}

0 commit comments

Comments
 (0)