-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f9c7bbd
commit bde30fc
Showing
4 changed files
with
118 additions
and
1 deletion.
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
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,101 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* @phpstan-pure | ||
* @throws \Exception | ||
*/ | ||
function pureWithThrows(): void | ||
{ | ||
throw new \Exception(); | ||
} | ||
|
||
/** | ||
* @phpstan-pure | ||
* @phpstan-assert int $a | ||
*/ | ||
function pureWithAssert(mixed $a): void | ||
{ | ||
if (!is_int($a)) { | ||
throw new \Exception(); | ||
} | ||
} | ||
|
||
/** | ||
* @phpstan-pure | ||
* @phpstan-assert int $a | ||
*/ | ||
function pureWithAssertAndReturn(mixed $a): int | ||
{ | ||
if (!is_int($a)) { | ||
throw new \Exception(); | ||
} | ||
return $a; | ||
} | ||
|
||
class A { | ||
/** | ||
* @phpstan-pure | ||
* @throws \Exception | ||
*/ | ||
public function pureWithThrows(): void | ||
{ | ||
throw new \Exception(); | ||
} | ||
|
||
/** | ||
* @phpstan-pure | ||
* @phpstan-assert int $a | ||
*/ | ||
public function pureWithAssert(mixed $a): void | ||
{ | ||
if (!is_int($a)) { | ||
throw new \Exception(); | ||
} | ||
} | ||
|
||
/** | ||
* @phpstan-pure | ||
* @phpstan-assert int $a | ||
*/ | ||
public function pureWithAssertAndReturn(mixed $a): int | ||
{ | ||
if (!is_int($a)) { | ||
throw new \Exception(); | ||
} | ||
return $a; | ||
} | ||
} | ||
|
||
class B { | ||
/** | ||
* @phpstan-pure | ||
* @throws \Exception | ||
*/ | ||
public static function pureWithThrows(): void | ||
{ | ||
throw new \Exception(); | ||
} | ||
|
||
/** | ||
* @phpstan-pure | ||
* @phpstan-assert int $a | ||
*/ | ||
public static function pureWithAssert(mixed $a): void | ||
{ | ||
if (!is_int($a)) { | ||
throw new \Exception(); | ||
} | ||
} | ||
|
||
/** | ||
* @phpstan-pure | ||
* @phpstan-assert int $a | ||
*/ | ||
public static function pureWithAssertAndReturn(mixed $a): int | ||
{ | ||
if (!is_int($a)) { | ||
throw new \Exception(); | ||
} | ||
return $a; | ||
} | ||
} |