netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

editor of a php file does not recognize class inhereted methods from a trait that uses trait

Open thanasis-oob opened this issue 3 years ago • 1 comments

Apache NetBeans version

Apache NetBeans 13

What happened

I use the IDE for a php project(PHP7.4 as PHP version). I am going to give you an example to understand the problem because it is about inheritance and I think it is more practical to view the class definitions.

The problem is that the system displays me a false alarm error hint that the Class does satisfy a method from an interface. screenshot

Specifically, The error appeared in the CookiesPage class and informs me that the class should implement the cancelUrl method of the HasCancelPageInterface interface

There is not any compilation error in the web application. it is just problem in the development because confuses the programmer.

\App\Logic\Template\Page\Frontend\CookiesPage is not abstract and does not override abstract method  cancelUrl(array $parameters = []) in \App\Logic\Template\Page\Contracts\HasCancelPageInterface

The class relationships are

class CookiesPage extends PageModelWebPageAbstract
{
}
abstract class PageModelWebPageAbstract extends FrontendWebPage
{
}
abstract class FrontendWebPage implements FrontendWebPageInterface
{
    use FrontendWebPageTrait;
}
interface FrontendWebPageInterface extends WebPageInterface, HasCancelPageInterface
{
    public function enabled();

    public function displayedDate();

    public function lastUpdatedDate();

    public function hasAuthUser()
   
    public function authUser();
}
interface WebPageInterface
{
    public function type();

    public function title();

    public function description();

    public function content();

    public function metaTitle();

    public function metaDescription();

    public function url(array $parameters = []);

    public function viewName();
    
    public function htmlBodyClass();
}
interface HasCancelPageInterface
{
    public function cancelPage();
    
    public function cancelTitle()

    public function cancelUrl(array $parameters = [])
}
trait FrontendWebPageTrait
{
    use CancelablePageTrait;
    use WebPageTrait;

    public function __construct()
    {
    }

    public function type()
    {
        return null;
    }
    
    public function enabled()
    {
    }

    public function ogType()
    {
    }

    public function displayedDate()
    {
    }

    public function lastUpdatedDate()
    {
    }
}
trait CancelablePageTrait
{
    
    public function cancelPage()
    {
    }

    public function hasCancelPage()
    {
    }

    public function cancelTitle()
    {
    }

    public function cancelUrl(array $parameters = [])
    {
    }
}
trait WebPageTrait
{
    
    public function hasAuthUser()
    {
    }

    public function authUser()
    {
    }
    
    public function setActionUser(Authenticatable $user)
    {
    }

    public function getActionUser()
    {
    }

    public function htmlBodyClass()
    {
    }
    
    public function viewName()
    {
    }

    public function viewPath()
    {
    }

    public function title()
    {
    }

    public function description()
    {
    }

    public function content()
    {
    }

    public function metaTitle()
    {
    }

    public function metaDescription()
    {
    }

    public function metaKeywords()
    {
    }

    public function url(array $parameters = [])
    {
    }

    public function checkActive($request)
    {
    }
}

How to reproduce

Create a new PHP project(using PHP7.4 as php version). Create the files which I described above. Open the Cookies class file for editing and check the the re is any error hint in the line of the class definition.

Did this work correctly in an earlier version?

No

Operating System

Ubuntu 16.04

JDK

openjdk 1.8.0_292

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

No response

Are you willing to submit a pull request?

No

Code of Conduct

Yes

thanasis-oob avatar Mar 15 '22 08:03 thanasis-oob

@thanasis-oob Could you provide an example project to reproduce it as a zip file? (Please attach it to this issue.)

junichi11 avatar Oct 13 '22 05:10 junichi11

Hi @junichi11, Now my netbeans version is 15. The error it does not appear. However, I attached a demo structure if you want to make a deeper check. FYI This error was appeared in a PHP project that uses Lavarel framework v6.x which uses composer to autoload classes. In addition, Laravel has an extension to help IDEs to detect all classes by adding the _ide_helper.php file in the root directory of the project. I don`t know if this may affect.

demo.zip

thanasis-oob avatar Oct 13 '22 07:10 thanasis-oob

@thanasis-oob Great to hear. Just close this. Thanks!

junichi11 avatar Oct 14 '22 05:10 junichi11