Repository: tightenco/tlint (php)

Issue:
False Positive `SpacesAroundBladeRenderContent`
```blade
{{-- This comment will not be present in the rendered HTML --}}
```

Pull request:
fix False Positive  from blade comments, fixes #39

Patch:
diff --git a/src/Linters/SpacesAroundBladeRenderContent.php b/src/Linters/SpacesAroundBladeRenderContent.php
index 72d6f1c..7cf6638 100644
--- a/src/Linters/SpacesAroundBladeRenderContent.php
+++ b/src/Linters/SpacesAroundBladeRenderContent.php
@@ -25,12 +25,23 @@ class SpacesAroundBladeRenderContent extends BaseLinter
             $matches = [];
 
             preg_match(
-                '/\{\{\s*(.+?)\s*\}\}/',
+                '/\{\{(.+?)\}\}/',
                 $codeLine,
                 $matches
             );
 
-            if (isset($matches[1]) && (! str_contains($codeLine, '{{ ') && ! str_contains($codeLine, ' }}'))) {
+            if (isset($matches[1]) && isset($matches[0])
+                /** Is not a blade comment */
+                && (substr($matches[1], 0, 2) !== '--')
+                && (
+                    /** Does not only have a *single* space before the start of the content */
+                    $matches[1][0] !== ' '
+                    || $matches[1][1] === ' '
+                    /** Does not only have a *single* space at the end of the content */
+                    || $matches[1][-1] !== ' '
+                    || $matches[1][-2] === ' '
+                )
+            ) {
                 $foundNodes[] = new class(['startLine' => $line + 1]) extends NodeAbstract {
                     public function getSubNodeNames() : array
                     {


Test patch:
diff --git a/tests/Linters/SpacesAroundBladeRenderContentTest.php b/tests/Linters/SpacesAroundBladeRenderContentTest.php
index 5f5bef2..2b02327 100644
--- a/tests/Linters/SpacesAroundBladeRenderContentTest.php
+++ b/tests/Linters/SpacesAroundBladeRenderContentTest.php
@@ -34,6 +34,20 @@ file;
         $this->assertEquals(1, $lints[0]->getNode()->getLine());
     }
 
+    /** @test */
+    public function does_not_trigger_when_spaces_are_placed_correctly_raw_blade_render_content()
+    {
+        $file = <<<file
+        {!! \$a !!}
+file;
+
+        $lints = (new TLint)->lint(
+            new SpacesAroundBladeRenderContent($file)
+        );
+
+        $this->assertEmpty($lints);
+    }
+
     /** @test */
     public function does_not_trigger_when_spaces_are_placed_correctly()
     {
@@ -63,4 +77,18 @@ file;
 
         $this->assertEmpty($lints);
     }
+
+    /** @test */
+    public function does_not_trigger_on_blade_comment()
+    {
+        $file = <<<file
+{{-- This comment will not be present in the rendered HTML --}}
+file;
+
+        $lints = (new TLint)->lint(
+            new SpacesAroundBladeRenderContent($file)
+        );
+
+        $this->assertEmpty($lints);
+    }
 }