Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
serialize is not pure for array of object
- Loading branch information
1 parent
85b5436
commit 222df2c
Showing
4 changed files
with
49 additions
and
6 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
36 changes: 36 additions & 0 deletions
36
src/Psalm/Internal/TypeVisitor/ContainsObjectTypeVisitor.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,36 @@ | ||
<?php | ||
|
||
namespace Psalm\Internal\TypeVisitor; | ||
|
||
use Psalm\Type\Atomic\TNamedObject; | ||
use Psalm\Type\Atomic\TObject; | ||
use Psalm\Type\Atomic\TTemplateParam; | ||
use Psalm\Type\NodeVisitor; | ||
use Psalm\Type\TypeNode; | ||
|
||
class ContainsObjectTypeVisitor extends NodeVisitor | ||
{ | ||
/** | ||
* @var bool | ||
*/ | ||
private $contains_object_type = false; | ||
|
||
protected function enterNode(TypeNode $type): ?int | ||
{ | ||
if ($this instanceof TObject | ||
|| $this instanceof TNamedObject | ||
|| ($this instanceof TTemplateParam | ||
&& $this->as->hasObjectType()) | ||
) { | ||
$this->contains_object_type = true; | ||
return NodeVisitor::STOP_TRAVERSAL; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public function matches(): bool | ||
{ | ||
return $this->contains_object_type; | ||
} | ||
} |
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