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 251045 - Editor does not correctly resolve namespaces for traits
Summary: Editor does not correctly resolve namespaces for traits
Status: NEW
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.0.2
Hardware: All All
: P3 normal (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-09 22:30 UTC by satrogenum
Modified: 2017-09-05 08:01 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Partial fix (for model) (3.67 KB, patch)
2016-06-23 10:58 UTC, Tomas Mysik
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description satrogenum 2015-03-09 22:30:13 UTC
If I have a two traits in different namespaces with the same name, the editor does not correctly determine the trait to use: it seems to go in alphabetical order rather than using the current namespace.

Example:

--- FILE 1 ---

<?php

namespace ns1;

trait TestTrait {

    public abstract function foo();
}

--- FILE 2 ---

<?php

namespace ns2;

trait TestTrait {

    public abstract function bar();
}


--- FILE 3 ---

<?php

namespace ns2;

class TestClass {

    use TestTrait;

    public function bar() {}

}

The editor reports an error in file 3, that abstract function 'foo()' has not been defined. This seems to be because it is resolving the 'use TestTrait' statement as 'use ns1\TestTrait' rather than 'use ns2\TestTrait'. Trait names in a trait use statement are expressed relevant to the namespace of the class.
Comment 1 Tomas Mysik 2016-06-10 08:44:52 UTC
Taking over.
Comment 2 Tomas Mysik 2016-06-23 10:57:10 UTC
Unfortunately, this is very difficult to fix. Even if I fix the model part, the index part still (incorrectly in this case) uses both traits and there is no easy way to fix it (at least for now, at least for me).

Attaching partial fix for model.

Thanks for reporting.
Comment 3 Tomas Mysik 2016-06-23 10:58:32 UTC
Created attachment 160146 [details]
Partial fix (for model)

However, the index part is still broken.