Error Identifier: phpstanPlayground.noPhp
Every error reported by PHPStan has an error identifier. Here’s a list of all error identifiers. In PHPStan Pro you can see the error identifier next to each error and filter errors by their identifiers.
Code example #
This is not PHP code.
It's just plain text without the opening PHP tag.
Why is it reported? #
The submitted code in the PHPStan Playground does not contain any PHP code. The file consists entirely of inline HTML without any <?php opening tag, so the PHP parser treats the entire content as non-PHP markup.
This error is not ignorable because there is no PHP code for PHPStan to analyse.
How to fix it #
Add the <?php opening tag at the beginning of the code:
+<?php declare(strict_types = 1);
+
+function greet(string $name): string
+{
+ return 'Hello, ' . $name;
+}
+
Non-ignorable error #
This error cannot be ignored using @phpstan-ignore or the ignoreErrors configuration. Non-ignorable errors indicate code that would cause a crash or a fatal error at runtime, or a fundamental problem in the analysed code that must be addressed.
Rules that report this error #
- PHPStan\Rules\Playground\NoPhpCodeRule [1]