eclipse-pdt / pdt

PHP Development Tools project (PDT)
https://eclipse.org/pdt
Eclipse Public License 2.0
188 stars 46 forks source link

Missing warning on statement after never function call #204

Open the-liquid-metal opened 1 year ago

the-liquid-metal commented 1 year ago

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

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);