Skip to content

Commit

Permalink
fixed parser [Closes #28]
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Sep 26, 2023
1 parent abc683f commit 329088d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/RobotLoader/RobotLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,6 @@ private function scanPhp(string $file): array
$expected = $token->id;
$name = '';
continue 2;

case T_CURLY_OPEN:
case T_DOLLAR_OPEN_CURLY_BRACES:
$level++;
}

if ($expected) {
Expand Down
2 changes: 2 additions & 0 deletions tests/Loaders/RobotLoader.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ $loader->addDirectory(__DIR__ . '/files/'); // purposely doubled
$loader->addDirectory(__DIR__ . '/file/interface.php'); // as file
$loader->addDirectory(__DIR__ . '/file/class.const.php');
$loader->addDirectory(__DIR__ . '/file/trait.php');
$loader->addDirectory(__DIR__ . '/file/bug-28.php');
$loader->excludeDirectory(__DIR__ . '/files/exclude');
$loader->excludeDirectory(__DIR__ . '/files/exclude2/excluded.php');
$loader->register();

Assert::false(class_exists('ConditionalClass')); // files/conditional.class.php
Assert::true(interface_exists('TestInterface')); // file/interface.php
Assert::true(trait_exists('TestTrait')); // file/trait.php
Assert::true(class_exists('Bug28')); // file/bug-28.php

Assert::true(class_exists('TestClass')); // files/namespaces1.php
Assert::true(class_exists('MySpace1\TestClass1')); // files/namespaces1.php
Expand Down
13 changes: 13 additions & 0 deletions tests/Loaders/file/bug-28.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

$foo = '';
$foo = "Hello {$foo}!";

class Bug28
{
public function fn()
{
}
}

0 comments on commit 329088d

Please sign in to comment.