Skip to content

Commit

Permalink
Merge pull request #45 from ScullWM/fix_short_tag
Browse files Browse the repository at this point in the history
Fix issue with php short tag #44
  • Loading branch information
EHER authored Nov 12, 2020
2 parents 49b1e1e + 2f84bc8 commit 0e11477
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Lint/PhpLint.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<?php ' . PHP_EOL . $code;
}

Expand Down
3 changes: 3 additions & 0 deletions tests/assets/understand-short-tag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```php
<?= $this->json($this->data) ?>
```
3 changes: 3 additions & 0 deletions tests/assets/understand-short-tag.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.. code-block:: php
<?= $this->json($this->data) ?>
14 changes: 14 additions & 0 deletions tests/functional/md-short-php-tag.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Report a warning in case of missing PHP open tag
--FILE--
<?php

$checkRunner = require __DIR__ . '/init.php';

$checkRunner('tests/assets/understand-short-tag.md');

--EXPECTF--
Finding documentation files on tests/assets/understand-short-tag.md


Everything is OK!
14 changes: 14 additions & 0 deletions tests/functional/rst-short-php-tag.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Report a warning in case of missing PHP open tag
--FILE--
<?php

$checkRunner = require __DIR__ . '/init.php';

$checkRunner('tests/assets/understand-short-tag.rst');

--EXPECTF--
Finding documentation files on tests/assets/understand-short-tag.rst


Everything is OK!

0 comments on commit 0e11477

Please sign in to comment.