If you actually run the code, it will work correctly.
Make sure to distinguish between a "warning messages that are only displayed in the IDE or editor" and a "errors caused by mistakes in the code."
To an editor that doesn't know about Folio, it will look like an undefined $id has been used suddenly.
This is because the editor doesn't support Folio, so it cannot be fixed.
Since it's not an error, the only thing you can do is remove the warning message in the editor.
No, I'm getting this error while actually running the code. It happens when I run the route() helper function. When I drill into the call stack, I find that in the class Laravel\Folio\InlineMetadataInterceptor, there's a command require $__path that results in the code above being run.