Why is PHP 8 giving me an "expected semicolon" error in every namespace and use statement?

  debugging, laravel, php, php-8, syntax-error

I’ve just upgraded my (Windows 10 2004) system from PHP 7.4 to PHP 8.0.3. I did this by uninstalling then reinstalling XAMPP with the later version. I am developing a Laravel 8.0 application in VS Code v 1.55, and the application runs absolutely fine. However, every single namespace/use statement in every single .php file has these annoying errors where the statement is marked as an error with "[semicolon] expected" – even though it shouldn’t be.

enter image description here

Hovering over the paths themselves also gives another useless error "Unexpected ‘Unknown’":

enter image description here

As a result, the problems tab just looks like this – a list of nothing but the above two errors across all my files, obscuring any actual errors there might be:

enter image description here

So what do these errors actually mean? And how can I get rid of them? Thanks very much!

Source: Laravel

Leave a Reply