Skip to content

Commit

Permalink
Regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Apr 21, 2022
1 parent 6506d87 commit 6a611f0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/PHPStan/Analyser/AnalyserIntegrationTest.php
Expand Up @@ -732,6 +732,15 @@ public function testDiscussion6993(): void
$this->assertSame('Parameter #1 $specificable of method Bug6993\AndSpecificationValidator<Bug6993\TestSpecification,Bug6993\Foo>::isSatisfiedBy() expects Bug6993\Foo, Bug6993\Bar given.', $errors[0]->getMessage());
}

public function testBug7077(): void
{
if (!self::$useStaticReflectionProvider) {
$this->markTestSkipped('Test requires static reflection.');
}
$errors = $this->runAnalyse(__DIR__ . '/data/bug-7077.php');
$this->assertNoErrors($errors);
}

/**
* @param string[]|null $allAnalysedFiles
* @return Error[]
Expand Down
28 changes: 28 additions & 0 deletions tests/PHPStan/Analyser/data/bug-7077.php
@@ -0,0 +1,28 @@
<?php

namespace Bug7077;

function date_add(string $pd, ?int $nr, ?string $date): ?string {
if ($date === null || $nr === null) {
return null;
}

$interval = new \DateInterval('P' . abs($nr) . $pd);

$dt = new \DateTime($date);
if ($nr >= 0) {
$dt->add($interval);
} else {
$dt->sub($interval);
}

return $dt->format('Y-m-d H:i:s');
}

function date_add_day(?string $date, ?int $days): ?string {
return date_add('D', $days, $date);
}

function date_add_month(?string $date, ?int $months): ?string {
return date_add('M', $months, $date);
}

0 comments on commit 6a611f0

Please sign in to comment.