diff --git a/src/Lint/PhpLint.php b/src/Lint/PhpLint.php index ea15220..e8be861 100644 --- a/src/Lint/PhpLint.php +++ b/src/Lint/PhpLint.php @@ -50,7 +50,7 @@ public function getViolation(string $code): string private function ensureCodePrefix(string $code): string { - if (! preg_match('/<\?php/i', $code)) { + if (! preg_match('/<\?(=|php)/i', $code)) { return 'json($this->data) ?> +``` diff --git a/tests/assets/understand-short-tag.rst b/tests/assets/understand-short-tag.rst new file mode 100644 index 0000000..cd8673b --- /dev/null +++ b/tests/assets/understand-short-tag.rst @@ -0,0 +1,3 @@ +.. code-block:: php + + json($this->data) ?> diff --git a/tests/functional/md-short-php-tag.phpt b/tests/functional/md-short-php-tag.phpt new file mode 100644 index 0000000..7c2c116 --- /dev/null +++ b/tests/functional/md-short-php-tag.phpt @@ -0,0 +1,14 @@ +--TEST-- +Report a warning in case of missing PHP open tag +--FILE-- +