-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
198 additions
and
35 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
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,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Roave\BetterReflection\Reflection\Exception; | ||
|
||
use PhpParser\Node\Stmt; | ||
use PhpParser\PrettyPrinter\Standard; | ||
use RuntimeException; | ||
|
||
use function sprintf; | ||
use function substr; | ||
|
||
class InvalidArrowFunctionBodyNode extends RuntimeException | ||
{ | ||
public static function create(Stmt $node): self | ||
{ | ||
return new self(sprintf( | ||
'Invalid arrow function body node (first 50 characters: %s)', | ||
substr((new Standard())->prettyPrint([$node]), 0, 50), | ||
)); | ||
} | ||
} |
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
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
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,5 @@ | ||
<?php | ||
|
||
namespace Roave\BetterReflectionTest\Fixture; | ||
|
||
return fn () => 'Hello world!'; |
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,3 @@ | ||
<?php | ||
|
||
return fn () => 'Hello world!'; |
26 changes: 26 additions & 0 deletions
26
test/unit/Reflection/Exception/InvalidArrowFunctionBodyNodeTest.php
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Roave\BetterReflectionTest\Reflection\Exception; | ||
|
||
use PhpParser\Node\Scalar\String_; | ||
use PhpParser\Node\Stmt\Echo_; | ||
use PHPUnit\Framework\TestCase; | ||
use Roave\BetterReflection\Reflection\Exception\InvalidArrowFunctionBodyNode; | ||
|
||
/** | ||
* @covers \Roave\BetterReflection\Reflection\Exception\InvalidArrowFunctionBodyNode | ||
*/ | ||
class InvalidArrowFunctionBodyNodeTest extends TestCase | ||
{ | ||
public function testCreate(): void | ||
{ | ||
$exception = InvalidArrowFunctionBodyNode::create(new Echo_([ | ||
new String_('Hello world!'), | ||
])); | ||
|
||
self::assertInstanceOf(InvalidArrowFunctionBodyNode::class, $exception); | ||
self::assertStringStartsWith('Invalid arrow function body node', $exception->getMessage()); | ||
} | ||
} |
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
Oops, something went wrong.