mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Add test for #4825
This commit is contained in:
parent
4f4182897b
commit
972738b772
@ -464,7 +464,7 @@ class TryAnalyzer
|
|||||||
/** @var string $var_id */
|
/** @var string $var_id */
|
||||||
foreach ($finally_context->assigned_var_ids as $var_id => $_) {
|
foreach ($finally_context->assigned_var_ids as $var_id => $_) {
|
||||||
if (isset($context->vars_in_scope[$var_id])
|
if (isset($context->vars_in_scope[$var_id])
|
||||||
&& $finally_context->vars_in_scope[$var_id]
|
&& isset($finally_context->vars_in_scope[$var_id])
|
||||||
) {
|
) {
|
||||||
if ($context->vars_in_scope[$var_id]->possibly_undefined
|
if ($context->vars_in_scope[$var_id]->possibly_undefined
|
||||||
&& $context->vars_in_scope[$var_id]->possibly_undefined_from_try
|
&& $context->vars_in_scope[$var_id]->possibly_undefined_from_try
|
||||||
|
@ -227,6 +227,31 @@ class PropertyTypeTest extends TestCase
|
|||||||
$this->analyzeFile('somefile.php', new Context());
|
$this->analyzeFile('somefile.php', new Context());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNoCrashInTryCatch(): void
|
||||||
|
{
|
||||||
|
Config::getInstance()->remember_property_assignments_after_call = false;
|
||||||
|
|
||||||
|
$this->addFile(
|
||||||
|
'somefile.php',
|
||||||
|
'<?php
|
||||||
|
function maybeMutates() : void {}
|
||||||
|
|
||||||
|
class X {
|
||||||
|
public int $f = 0;
|
||||||
|
|
||||||
|
public function validate(): void {
|
||||||
|
try {
|
||||||
|
} finally {
|
||||||
|
$this->f = 1;
|
||||||
|
maybeMutates();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->analyzeFile('somefile.php', new Context());
|
||||||
|
}
|
||||||
|
|
||||||
public function testUniversalObjectCrates(): void
|
public function testUniversalObjectCrates(): void
|
||||||
{
|
{
|
||||||
Config::getInstance()->addUniversalObjectCrate(\DateTime::class);
|
Config::getInstance()->addUniversalObjectCrate(\DateTime::class);
|
||||||
|
Loading…
Reference in New Issue
Block a user