-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix readonly property assigned in if-else
- Loading branch information
1 parent
185b964
commit ce3c164
Showing
6 changed files
with
122 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Node\Expr; | ||
|
||
use PhpParser\Node\Expr; | ||
use PHPStan\Node\VirtualNode; | ||
|
||
class PropertyInitializationExpr extends Expr implements VirtualNode | ||
{ | ||
|
||
public function __construct(private string $propertyName) | ||
{ | ||
parent::__construct([]); | ||
} | ||
|
||
public function getPropertyName(): string | ||
{ | ||
return $this->propertyName; | ||
} | ||
|
||
public function getType(): string | ||
{ | ||
return 'PHPStan_Node_PropertyInitializationExpr'; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public function getSubNodeNames(): array | ||
{ | ||
return []; | ||
} | ||
|
||
} |
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,32 @@ | ||
<?php // lint >= 8.1 | ||
|
||
namespace Bug6402; | ||
|
||
class SomeModel | ||
{ | ||
public readonly ?int $views; | ||
|
||
public function __construct(string $mode, int $views) | ||
{ | ||
if ($mode === 'mode1') { | ||
$this->views = $views; | ||
} else { | ||
$this->views = null; | ||
} | ||
} | ||
} | ||
|
||
class SomeModel2 | ||
{ | ||
public readonly ?int $views; | ||
|
||
public function __construct(string $mode, int $views) | ||
{ | ||
if ($mode === 'mode1') { | ||
$this->views = $views; | ||
} else { | ||
echo $this->views; | ||
$this->views = null; | ||
} | ||
} | ||
} |