pdt
pdt copied to clipboard
Missing warning on statement after never function call
Bug Description Missing warning on statement after never function call.
Eclipse environment Version: 2023-06 (4.28.0) Build id: 20230608-1333 PDT: 8.0.0.202306050832
System
- PHP Version: 8.2.7, 8.1.20, 8.0.29, 7.4.33 (via https://onlinephp.io/)
To Reproduce Steps to reproduce the behavior: copy-paste this script to the IDE
<?php
declare(strict_types=1);
namespace ns1\ns2;
use Exception;
use stdClass;
class Test28 {
public static function redirect(string $uri): never {
header('Location: ' . $uri);
exit();
}
}
echo "before";
Test28::redirect("http://localhost/");
echo "after"; // this statement will not executed and SHOULD trigger warning message.
// -------------------------------------------------------------------------
trait Test28b {
public static function redirect(string $uri): never {
header('Location: ' . $uri);
exit();
}
}
class Test28c {
use Test28b;
}
echo "before";
Test28c::redirect("http://localhost/");
echo "after"; // this statement will not executed and SHOULD trigger warning message.
// -------------------------------------------------------------------------
function redirect(string $uri): never {
header('Location: ' . $uri);
exit();
}
echo "before";
redirect("http://localhost/");
echo "after"; // this statement will not executed and SHOULD trigger warning message.
// -------------------------------------------------------------------------
class Gateway {
public function __construct($connection, $params) {}
public function fetchDb(): object|null {}
public function thrower(): never {
throw new Exception(json_encode($this));
}
}
$connection = new stdClass;
$params = new stdClass;
$gateway = new Gateway($connection, $params);
$data = $gateway->fetchDb() ?? $gateway->thrower();
echo "after"; // this statement might be executed and SHOULD NOT trigger warning message.
var_dump($data);