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

User first class callable syntax #4137

Merged
merged 1 commit into from
Jul 14, 2024
Merged

Conversation

fabpot
Copy link
Contributor

@fabpot fabpot commented Jul 13, 2024

No description provided.

extra/html-extra/HtmlExtension.php Outdated Show resolved Hide resolved
Copy link
Contributor

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

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

For the failing test, you can fix Twig\Parser::subparse() with something like this:

$tokenParser = match (true) {
    \is_array($test) => $test[0],
    $test instanceof \Closure => (new \ReflectionFunction($test))->getClosureThis(),
    default => null,
};
if ($tokenParser instanceof TokenParserInterface) {
    $e->appendMessage(\sprintf(' (expecting closing tag for the "%s" tag defined near line %s).', $tokenParser->getTag(), $lineno));
}

@fabpot fabpot force-pushed the first-class-callable branch 2 times, most recently from 3df30ef to d5a81a8 Compare July 14, 2024 12:00
@fabpot
Copy link
Contributor Author

fabpot commented Jul 14, 2024

For the failing test, you can fix Twig\Parser::subparse() with something like this:

$tokenParser = match (true) {
    \is_array($test) => $test[0],
    $test instanceof \Closure => (new \ReflectionFunction($test))->getClosureThis(),
    default => null,
};
if ($tokenParser instanceof TokenParserInterface) {
    $e->appendMessage(\sprintf(' (expecting closing tag for the "%s" tag defined near line %s).', $tokenParser->getTag(), $lineno));
}

I have added native support instead.

@fabpot fabpot merged commit 05df869 into twigphp:4.x Jul 14, 2024
28 of 31 checks passed
@fabpot fabpot deleted the first-class-callable branch July 14, 2024 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants