-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw more informative error when file has PHP syntax error (#18)
* Throw more informative error when file has PHP syntax error * Fix warning, passing generator to count
- Loading branch information
Showing
7 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Cspray\AnnotatedTargetFixture; | ||
|
||
class BadPhpFileFixture implements Fixture { | ||
|
||
public function getPath() : string { | ||
return __DIR__ . '/InvalidPhpSyntax'; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Cspray\AnnotatedTargetFixture\InvalidPhpSyntax; | ||
|
||
class BadPhpFile { | ||
|
||
public function method() : string { | ||
return '': | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Cspray\AnnotatedTarget\Exception; | ||
|
||
final class InvalidPhpSyntax extends Exception { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Cspray\AnnotatedTarget\Unit; | ||
|
||
use Cspray\AnnotatedTarget\Exception\InvalidPhpSyntax; | ||
use Cspray\AnnotatedTargetFixture\Fixtures; | ||
|
||
uses(AnnotatedTargetParserTestCase::class); | ||
|
||
beforeEach()->withFixtures(Fixtures::invalidSyntax()); | ||
|
||
|
||
it('throws an exception if invalid PHP syntax is encountered', fn() => $this->getTargets()) | ||
->throws( | ||
InvalidPhpSyntax::class, | ||
'Encountered error parsing ' . Fixtures::invalidSyntax()->getPath() . '/BadPhpFile.php. Message: Syntax error, unexpected \':\', expecting \';\' on line 8' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters