Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VarDumper] Fixed dumping of terminated generator #21542

Merged
merged 1 commit into from
Feb 6, 2017

Conversation

lyrixx
Copy link
Member

@lyrixx lyrixx commented Feb 6, 2017

Q A
Branch? 2.8
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

try {
$reflectionGenerator = new \ReflectionGenerator($c);
} catch (\Exception $e) {
return $a;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a virtual prop that says closed: true?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Added.

@@ -99,28 +110,28 @@ public static function castReflectionGenerator(\ReflectionGenerator $c, array $a
if ($c->getThis()) {
$a[$prefix.'this'] = new CutStub($c->getThis());
}
$x = $c->getFunction();
$function = $c->getFunction();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

diff irrelevant for review

@@ -76,7 +76,18 @@ public static function castClosure(\Closure $c, array $a, Stub $stub, $isNested)

public static function castGenerator(\Generator $c, array $a, Stub $stub, $isNested)
{
return class_exists('ReflectionGenerator', false) ? self::castReflectionGenerator(new \ReflectionGenerator($c), $a, $stub, $isNested) : $a;
if (!class_exists('ReflectionGenerator', false)) {
return $a;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

closed: true/false virtual prop?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can I know?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call ->valid()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can not because it alters the generator. That's why I used the try catch method and not ->valid().

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

// Cannot create ReflectionGenerator based on a terminated Generator
try {
$reflectionGenerator = new \ReflectionGenerator($c);
} catch (\Exception $e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm that an Exception is thrown here, even-though I'd personally have expected a ReflectionException
ping @jpauli.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been fixed as part of PHP 7.2 in php/php-src@ed4216c

@nicolas-grekas
Copy link
Member

Thank you @lyrixx.

@nicolas-grekas nicolas-grekas merged commit c5094a0 into symfony:2.8 Feb 6, 2017
nicolas-grekas added a commit that referenced this pull request Feb 6, 2017
This PR was merged into the 2.8 branch.

Discussion
----------

[VarDumper] Fixed dumping of terminated generator

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

c5094a0 [VarDumper] Fixed dumping of terminated generator
@lyrixx lyrixx deleted the dump-generator branch February 6, 2017 16:53
@fabpot fabpot mentioned this pull request Feb 17, 2017
@fabpot fabpot mentioned this pull request Mar 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants