Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regression tests for NumberComparisonOperatorsConstantConditionRule
- Loading branch information
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Bug6776; | ||
|
||
class HelloWorld | ||
{ | ||
/** | ||
* @param positive-int|null $date | ||
*/ | ||
public function sayHello(?int $date): void | ||
{ | ||
if($date !== null && $date < 1){ | ||
throw new \InvalidArgumentException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Bug7075; | ||
|
||
/** @param int<0, 100> $b */ | ||
function foo(int $b): void { | ||
if ($b > 100) throw new \Exception("bad"); | ||
print "ok"; | ||
} | ||
|
||
/** | ||
* @param int<1,max> $number | ||
*/ | ||
function foo2(int $number): void { | ||
if ($number < 1) { | ||
throw new \Exception('Number cannot be less than 1'); | ||
} | ||
} |