Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Some PHP Function Flagged as Error in VSCode

I am a beginner and am developing a specific web system using PHP 8.2, Codeigniter 4 and XAMPP in VSCode. However, in my Controller, some PHP functions are marked as errors, such as password_verify(), strpos() etc. After I run it, the program runs fine. Where is the error? Is it in the VS Code program?

the vs code screenshot

The problem is:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Expected type ‘string’. Found ‘array|null’.intelephense(1006)

For additional information, I am using Intelephense PHP extension 1.9.2. I also opened the code in PHPStorm and the error is not there. Thank you for any provided information.

When I uninstalled / disabled the Intelephense PHP, of course the error was not found. Whe I use PHP IntelliSense, it’s did not even mark the function as an error. However, when Intelephense was re-enabled the PHP function was still marked as an error.

>Solution :

I see that $request->getPost() has a signature of mixed|null.
And password_verify a a signature of string.

You can cast it to string and the warning will dissapear.

$password = (string) $this->request->getPost('password')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading