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

T_YIELD_FROM is not recognized and breaks code #37

Closed
r4ndsen opened this issue Nov 2, 2017 · 2 comments
Closed

T_YIELD_FROM is not recognized and breaks code #37

r4ndsen opened this issue Nov 2, 2017 · 2 comments

Comments

@r4ndsen
Copy link

r4ndsen commented Nov 2, 2017

function b()
{
    yield from a();
}

results in

function b()
{
    yield froma();
}

removing the space and breaking the actual logic.
i believe it would be enough to just define T_YIELD_FROM in the tokenizer.
token id is 269

//edit: running on php7.1.11

thanks

@MKCG
Copy link

MKCG commented Dec 5, 2017

It seems that PHPFMT is not compatible with PHP 7.1

This issue is caused by the fact that "yield from" produces the token T_YIELD_FROM but this token is not yet managed by phpfmt.

I made a quick fix which does not seems to have any side effect.

I uncompressed the fmt.phar to have access to fmt.stub.php and then I simply added the following lines before the default case of ResizeSpaces::format :

case T_YIELD_FROM:
    $this->appendCode($text . $this->getSpace($this->rightTokenIs(T_STRING)));
    break;

The updated fmt.phar and the script used to update its content are both available here : https://github.com/MKCG/phpfmt_7-1

@r4ndsen
Copy link
Author

r4ndsen commented Dec 14, 2017

works great, thank you.

@r4ndsen r4ndsen closed this as completed Dec 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants