vscode-intelephense icon indicating copy to clipboard operation
vscode-intelephense copied to clipboard

Add setting to disable Non static method '' should not be called statically.

Open ghost opened this issue 5 years ago • 7 comments

微信截图_20200530164638

I have the __callStatic method, But it still prompts me a lot of info information, I don't think this should be prompted. Intelephense version 1.4.0 php version 7.4.0

ghost avatar May 30 '20 08:05 ghost

Can you provide a code example that reproduces the problem? Is startTrans static or non-static? If it is declared non-static then I think this is valid diagnostic even if you have __callStatic.

bmewburn avatar May 31 '20 07:05 bmewburn

微信截图_20200530164638

the startTrans is non-static, Can this info be shut down? I think it's a little annoying

ghost avatar Jun 01 '20 00:06 ghost

This diagnostic is current bundled in with others under intelephense.diagnostics.languageConstraints . Will look at separating it out.

bmewburn avatar Jun 01 '20 07:06 bmewburn

I think this option should be added, and the default is off state

ghost avatar Jun 02 '20 01:06 ghost

@bmewburn

intelephense.diagnostics.languageConstraints

Thank you for the suggestion, it worked. I have a question, though: is there a "documented way" to find out which certain option helps to disable this or that Warning/Notice? Maybe, display it in the error message itself, like:

Non static method 'builder' should not be called statically.intelephense(1036) You can disable this kind of messages via "intelephense.diagnostics.languageConstraints" option

Something like this.

mityukov avatar Jun 12 '20 07:06 mityukov

This becomes very annoying.

baoanhng avatar Mar 28 '23 10:03 baoanhng

Any updates on this?

mrvnklm avatar May 19 '24 10:05 mrvnklm

I had a similar issue and it turned out it was the file size limitation for Intelephense, causing it not to index the IDE helper files. The output tab showed this:

[Warn - 22:40:21] file:///home/foo/my/project/_ide_helper.php is over the maximum file size of 1000000 bytes.

Just changed the Intelephense › Files: Max Size setting and all was good after.

carestad avatar Jun 20 '24 20:06 carestad

Calling non static methods statically has been a fatal error since php 8.0 (which was EOL 11/2023) and a deprecated warning before that. Closing as I don't see a good reason for the need to suppress this. Individual errors can still be suppressed with /** @disregard P1036 */.

bmewburn avatar Jun 21 '24 02:06 bmewburn

Unfortunately, this issue has resurfaced in version 1.12.3. The problem is caused by PHP magic functions, which are not recognized by Intelephense

Abolfazl74 avatar Aug 14 '24 07:08 Abolfazl74

yes same here, cannot disable it.

anyb1s avatar Aug 21 '24 12:08 anyb1s

the commit you've added to this thread did not fix this issue, and the problem still exists in 1.12.5

Abolfazl74 avatar Sep 04 '24 15:09 Abolfazl74

the commit you've added to this thread did not fix this issue, and the problem still exists in 1.12.5

Yeah that was a mistake, I didn't release adding a url to a commit linked it to the issue. You learn something new every day...

And yes, it didn't even fix it!

decantr avatar Sep 04 '24 15:09 decantr

What an annoying question!

nq2021 avatar Oct 04 '24 12:10 nq2021

It is still there?

anyb1s avatar Oct 30 '24 18:10 anyb1s

I'm using v1.12.6 and PHP 8.3.14 and PHP doesn't throw fatal errors for the below implementation. Is it possible to add a suppression comment at the top of a file to ignore /** @disregard P1036 */ for the whole file? I have many database calls like the example and it's hard to see any real errors.

image

__callStatic() implementation

image

Thank you.

neubreed avatar Dec 05 '24 02:12 neubreed

This error will be suppressed in cases where __callStatic is declared in next release.

bmewburn avatar Dec 11 '24 02:12 bmewburn

Thank you!

neubreed avatar Dec 11 '24 04:12 neubreed

Do I need to know if it's solved?

nigiwen avatar Dec 30 '24 07:12 nigiwen

Still appears to be an issue today with 1.12.6.

virgildotcodes avatar Feb 06 '25 05:02 virgildotcodes

Can confirm this on the latest version of both.

RC-CTO avatar Feb 06 '25 22:02 RC-CTO

Try the pre-release

bmewburn avatar Feb 06 '25 23:02 bmewburn