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 - False negative: uninitialized output-parameter variables
Summary: False negative: uninitialized output-parameter variables
Status: RESOLVED DUPLICATE of bug 204589
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.4
Hardware: All All
: P3 normal (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-03 18:18 UTC by dharkness
Modified: 2014-04-17 19:23 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ***