Dennis
Dennis

Reputation: 1169

How to turn off error types in VSCODE (PHP6606 for example)

In some inherited code, there are many cases where certain errors (such as PHP6606)

Constant from class 'subclass' referenced through child PHP(PHP6606)

appear due to the standards in place when the code was written. These mount up in the Find Problems (F8), making it difficult to find problems that really matter.

Using this as an example, is there a way to disable certain types of errors within VSCODE so that we can focus on real problems?

Apparently more detail is needed. The referenced code has a base class, lovFunctions, that is included in another class, lovBaseFunctions as such:

// lovfunctions.php
require_once('lovBaseFunctions.php') ;
class lovFunctions extends lovBaseFunctions {
    public string $className = __CLASS__ ;
    ...
}

// lovBaseFunctions.php
class lovBaseFunctions {
    const OPT_EXEC_FECH_ALL_ROWS = 0x000000020 ;
    ....
    // other constants and utility functions
    ....
}

// someScript.php
require_once('lovfunctions.php') ;
....
// Next executable line will cause this message:
// Constant from class 'lovBaseFunctions' referenced through child.PHP(PHP6606)
if ($flag == LOVFUNCTIONS::OPT_EXEC_FETCH_ALL_ROWS) {
    ....
}

So, while it may not be standard to reference a property through a child, it is certainly not an error, any more than referencing a function through that child would be. And such references (to functions) do not trip an error - I don't see why this one would. But rather than argue that purist point, I would like to be able to turn off the message. My question is about that, not about the code that causes it.

Upvotes: 0

Views: 72

Answers (0)

Related Questions