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 242520

Summary: False negative: uninitialized output-parameter variables
Product: php Reporter: dharkness <dharkness>
Component: EditorAssignee: Ondrej Brejla <obrejla>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: P3    
Version: 7.4   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description dharkness 2014-03-03 18:18:48 UTC
Some variables passed to built-in (and custom) functions are set by the function (output parameters) and don't need to be initialized before the call. A prime example is preg_match:

    if (preg_match('/foo/', 'the foobar', $matches) { ... }

Here, any value given to $matches before the call will be overwritten by the call itself, i.e., the call is guaranteed to initialize the variable.

IDEA

Since there's no way to declare this in PHP, use a simple inline comment in the NetBeans-supplied header files and make this available to custom code as well:

    function preg_match (
        $pattern, $subject, /* out */ array &$matches = null, $flags = 0, $offset = 0
    ) {}
Comment 1 dharkness 2014-04-17 19:23:41 UTC

*** This bug has been marked as a duplicate of bug 204589 ***