0

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:

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.

2
  • I'd say the error is in the plugin. It seems clear, especially since it disappeared when you uninstalled the plugin. Also have you actually tried to run the code? If it gets to that line and doesn't throw that error, then that also helps to prove it. But I think you've already answered your own question in the last paragraph, to be honest. Commented Jan 13, 2023 at 13:02
  • @ADyson Okay, my code is not pleasing to the eye when there are such error markers. Thanks for all the information. That's been resolved with Borjante's answers. Commented Jan 13, 2023 at 13:12

1 Answer 1

1

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')
Sign up to request clarification or add additional context in comments.

1 Comment

Okay, thank you. The error marker that appeared has disappeared by adding (string) $request->getPost(). I have run the code and it still works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.