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 240527 - Autocomplete for object with scope resolution operator (::)
Summary: Autocomplete for object with scope resolution operator (::)
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.4
Hardware: All All
: P3 normal with 1 vote (vote)
Assignee: Tomas Mysik
URL:
Keywords:
: 251447 253274 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-01-16 06:51 UTC by sectus
Modified: 2016-01-09 02:41 UTC (History)
6 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
patch (38.23 KB, patch)
2015-12-14 01:53 UTC, junichi11
Details | Diff
patch (40.05 KB, patch)
2015-12-15 11:34 UTC, junichi11
Details | Diff
patch (39.17 KB, patch)
2015-12-21 03:50 UTC, junichi11
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description sectus 2014-01-16 06:51:48 UTC
Scope resolution operator (::) could be used with object it self. So, it could be autocompleted by static and constant.

ini_set('error_reporting', -1);
ini_set('display_errors', 1);

class SomeClass
    {
    const SOME_CONSTANT = 'some constant';
    static public $some_member = 'some member';
    static public function someFunction(){}
    }

$object = new SomeClass();


$object::SOME_CONSTANT;
$object::$some_member;
$object::someFunction();

There is should be an autocompletion list with SOME_CONSTANT, $some_member and someFunction() after :: operator.
Comment 1 junichi11 2015-12-11 04:41:59 UTC
*** Bug 251447 has been marked as a duplicate of this bug. ***
Comment 2 junichi11 2015-12-11 04:42:27 UTC
*** Bug 253274 has been marked as a duplicate of this bug. ***
Comment 3 junichi11 2015-12-14 01:53:27 UTC
Created attachment 157777 [details]
patch

I just comment out one test case[1] because I'm not sure whether it should be removed completely.

[1] test/unit/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletionTest.java : test146648()

Thanks.
Comment 4 junichi11 2015-12-15 11:34:06 UTC
Created attachment 157792 [details]
patch

Array case is missing. Thanks.
Comment 5 junichi11 2015-12-21 03:50:55 UTC
Created attachment 157869 [details]
patch

Minor change. Thanks.
Comment 6 junichi11 2016-01-06 04:41:47 UTC
@Tomas, Could you please review it (when you can make time) ? 

I wrote echo statements in the PHP test file to confirm whether we can run the code actually. If it's not good, I'll remove them.

Thanks.
Comment 7 Tomas Mysik 2016-01-07 11:23:16 UTC
(In reply to sectus from comment #0)
> $object::SOME_CONSTANT;
> $object::$some_member;
> $object::someFunction();

I have to say that personally I strongly prefer to use SomeClass::___ and not an instance since static members belongs to the class, not its instance.

But I will apply the patch. Thanks a lot for it, Junichi!
Comment 8 Tomas Mysik 2016-01-07 11:26:08 UTC
(In reply to junichi11 from comment #6)
> I wrote echo statements in the PHP test file to confirm whether we can run
> the code actually. If it's not good, I'll remove them.

Junichi, how do you verify that the code runs without any problem?

Thanks.
Comment 9 junichi11 2016-01-07 12:27:31 UTC
(In reply to Tomas Mysik from comment #8)
> (In reply to junichi11 from comment #6)
> > I wrote echo statements in the PHP test file to confirm whether we can run
> > the code actually. If it's not good, I'll remove them.
> 
> Junichi, how do you verify that the code runs without any problem?

I just run `php issue240527.php` manually.
Comment 10 Tomas Mysik 2016-01-08 07:39:31 UTC
Patch applied, thanks a lot for it, Junichi!

Junichi, one idea related to this change:

+// This is valid since PHP 5.3.0. Fixed in #240527
+//    public void test146648() throws Exception {

Perhaps we could add a hint for it? OTOH, not sure if it is worth since older versions of PHP are today basically not used anymore...

Thanks!

http://hg.netbeans.org/web-main/rev/09316766795d
Comment 11 junichi11 2016-01-08 10:24:57 UTC
Tomas, thanks a lot for reviewing it!

(In reply to Tomas Mysik from comment #10)
> Perhaps we could add a hint for it? OTOH, not sure if it is worth since
> older versions of PHP are today basically not used anymore...

I'll try it. But I also think so...

Thanks!
Comment 12 Quality Engineering 2016-01-09 02:41:34 UTC
Integrated into 'main-silver', will be available in build *201601090002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/09316766795d
User: Tomas Mysik <tmysik@netbeans.org>
Log: #240527 - Autocomplete for object with scope resolution operator

Patch contributed by junichi11@netbeans.org.