Skip to content

Commit 6a611f0

Browse files
committed
Regression test
1 parent 6506d87 commit 6a611f0

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

tests/PHPStan/Analyser/AnalyserIntegrationTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,15 @@ public function testDiscussion6993(): void
732732
$this->assertSame('Parameter #1 $specificable of method Bug6993\AndSpecificationValidator<Bug6993\TestSpecification,Bug6993\Foo>::isSatisfiedBy() expects Bug6993\Foo, Bug6993\Bar given.', $errors[0]->getMessage());
733733
}
734734

735+
public function testBug7077(): void
736+
{
737+
if (!self::$useStaticReflectionProvider) {
738+
$this->markTestSkipped('Test requires static reflection.');
739+
}
740+
$errors = $this->runAnalyse(__DIR__ . '/data/bug-7077.php');
741+
$this->assertNoErrors($errors);
742+
}
743+
735744
/**
736745
* @param string[]|null $allAnalysedFiles
737746
* @return Error[]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Bug7077;
4+
5+
function date_add(string $pd, ?int $nr, ?string $date): ?string {
6+
if ($date === null || $nr === null) {
7+
return null;
8+
}
9+
10+
$interval = new \DateInterval('P' . abs($nr) . $pd);
11+
12+
$dt = new \DateTime($date);
13+
if ($nr >= 0) {
14+
$dt->add($interval);
15+
} else {
16+
$dt->sub($interval);
17+
}
18+
19+
return $dt->format('Y-m-d H:i:s');
20+
}
21+
22+
function date_add_day(?string $date, ?int $days): ?string {
23+
return date_add('D', $days, $date);
24+
}
25+
26+
function date_add_month(?string $date, ?int $months): ?string {
27+
return date_add('M', $months, $date);
28+
}

0 commit comments

Comments
 (0)