Skip to content

Sometimes it has duplicated warning messages in return statements #16495

Closed as not planned
@YuanchengJiang

Description

@YuanchengJiang

Description

The following code:

<?php
class A {
	function method(?int $a): ?int {
		return $i;    // it only warns once if return $i+$a
	}
}
$a = new A();
$a->method(1);
?>

Resulted in this output:

Warning: Undefined variable $i in test.php on line 4

Warning: Undefined variable $i in test.php on line 4

If this is expected, wondering why return $i+$a only warns once.

PHP Version

nightly

Operating System

ubuntu 22.04

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions