bmewburn / vscode-intelephense

PHP intellisense for Visual Studio Code
https://intelephense.com
Other
1.61k stars 94 forks source link

Use of unassigned variable '$product' PHP(PHP1412) #2835

Closed ahmadengali closed 6 months ago

ahmadengali commented 6 months ago

using vsc 1.87.2 to define an api project over Laravel 10 in the file " productcontroller.php" , I'v define all the needed values , like " $product " variable as shown below

'' " " public function index() { return product::all(); } public function store(Request $request) { $validated = $request->validate([ 'name' => 'required|max:255', 'description'=>'required', 'price'=>'required | numeric', ]); $product = Product::create($validated); return response()->Json($product, 201); } public function show() { return response()->Json($product, 200); }

Expected behavior the var : "$product" gives " ' Use of unassigned variable '$product' PHP(PHP1412) ' in the line : // return response()->Json($product, 200); // !

**php PHP 8.2.12 (cli) OS windows 10 / Intelephense version: 1.25.0

can some help please.. thank you.

bmewburn commented 6 months ago

Looks like a valid error to me. Either way it is coming from a different extension.