-
Notifications
You must be signed in to change notification settings - Fork 426
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
da8c7f9
commit cb91818
Showing
6 changed files
with
77 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
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,24 @@ | ||
<?php declare(strict_types=1); // lint >= 8.1 | ||
|
||
namespace Bug3488; | ||
|
||
enum EnumWithThreeCases { | ||
case ValueA; | ||
case ValueB; | ||
case ValueC; | ||
} | ||
|
||
function testFunction(EnumWithThreeCases $var) : int | ||
{ | ||
switch ($var) { | ||
case EnumWithThreeCases::ValueA: | ||
// some other code | ||
return 1; | ||
case EnumWithThreeCases::ValueB: | ||
// some other code | ||
return 2; | ||
case EnumWithThreeCases::ValueC: | ||
// some other code | ||
return 3; | ||
} | ||
} |
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
28 changes: 28 additions & 0 deletions
28
tests/PHPStan/Rules/Variables/data/defined-variables-enum.php
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,28 @@ | ||
<?php // lint >= 8.1 | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DefinedVariablesEnum; | ||
|
||
enum Foo | ||
{ | ||
case A; | ||
case B; | ||
} | ||
|
||
class HelloWorld | ||
{ | ||
public function sayHello(Foo $f): void | ||
{ | ||
switch ($f) { | ||
case Foo::A: | ||
$i = 5; | ||
break; | ||
case Foo::B: | ||
$i = 6; | ||
break; | ||
} | ||
|
||
var_dump($i); | ||
} | ||
} |