This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 251578

Summary: Wrong uninitialized prompt
Product: php Reporter: fcjailybo
Component: EditorAssignee: Tomas Mysik <tmysik>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 8.0.2   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: the prompt screeshot

Description fcjailybo 2015-04-02 02:27:39 UTC
Created attachment 152991 [details]
the prompt screeshot

I use try {} catch{},code like follow:
public function test() {
        try {
            $sk = 'knight';
            $this->testexp();
        } catch (Exception $exc) {
            echo $exc->getMessage() . '<br>';
            echo $sk;
        }
    }

I define $sk at try {}, and use it at catch{}, but the IDE prompt me that $sk seems to be uninitialized.
Comment 1 Tomas Mysik 2016-06-07 15:10:52 UTC
Well, this seems to be correct because e.g. in Java, this would be an error. You would need to type something like this:

$sk = null;
try {
    $sk = 'knight';
    $this->testexp();
} catch (Exception $exc) {
    echo $exc->getMessage() . '<br>';
    echo $sk;
}

But this is not necessary in PHP so there should not be any warning here.

Thanks for reporting.