-
Notifications
You must be signed in to change notification settings - Fork 10
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
Php code cleanup #119
Php code cleanup #119
Conversation
@@ -1,8 +1,10 @@ | |||
<?php | |||
|
|||
// declare(strict_types=1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will enable this for all files in an upcoming PR.
use Twig\Environment; | ||
use Twig\TwigFunction; | ||
|
||
function addCustomExtension(Environment &$env, $config) { | ||
$env->addFunction(new TwigFunction('customTwigFunctionThatSaysWorld', fn() => 'Custom World')); | ||
function addCustomExtension(Environment &$twigEnvironment, $config): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes in this PR make use of new arrow function syntax and typing.
|
||
function __construct(array $config) { | ||
$this->config = $config; | ||
function __construct(public array $config) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$config
makes use of new constructor promotion feature.
@@ -34,7 +36,7 @@ | |||
} | |||
|
|||
try { | |||
$config = json_decode($configString, true); | |||
$config = json_decode($configString, true, 512, JSON_THROW_ON_ERROR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New JSON_THROW_ON_ERROR
is a better error experience with json_decode
and json_encode
🚀 PR was released in |
First of a couple PRs related to cleanup/modernizing before bumping to twig 3, and then update all the JS packages and implementation.