-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Export AST for default value strings in reflection
When dumping default values in ReflectionXXX::__toString(), for expression initializers print the AST export instead of trying to evaluate the expression. With the introduction of "new in initializers" the result of the evaluation will commonly not be printable at all, and "__toString" will throw an exception, which is not particularly useful. Using the AST export also provides more information on how the parameter was originally declared, e.g. it preserves the fact that a certain constant was used.
- Loading branch information
Showing
10 changed files
with
86 additions
and
46 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
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
17 changes: 17 additions & 0 deletions
17
ext/reflection/tests/ReflectionParameter_new_initializer.phpt
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 @@ | ||
--TEST-- | ||
ReflectionParameter::__toString() with new initializer | ||
--FILE-- | ||
<?php | ||
|
||
function test( | ||
$p1 = new stdClass, | ||
$p2 = new SomeClass(new With, some: new Parameters) | ||
) {} | ||
|
||
echo new ReflectionParameter('test', 'p1'), "\n"; | ||
echo new ReflectionParameter('test', 'p2'), "\n"; | ||
|
||
?> | ||
--EXPECT-- | ||
Parameter #0 [ <optional> $p1 = new \stdClass() ] | ||
Parameter #1 [ <optional> $p2 = new \SomeClass(new \With(), some: new \Parameters()) ] |
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