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

Remove Twig_TokenParserBroker (deprecated) + all deprecation warnings #36

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

adrienrn
Copy link

Here's a PR that will fix all deprecation warnings including Twig_TokenParserBroker. This should help with (#31 & phpro/grumphp#199).

I've dig some things about the deprecation of the Twig_TokenParserBroker (twigphp/Twig#903). One notable change is that Twig 2.x does not offer a way to dynamically add token parser (like it was done with the Twig_TokenParserBroker). Instead, it just look up an array and throws a syntax error.
https://github.com/twigphp/Twig/blob/2.x/lib/Twig/Parser.php#L148

Therefore, you have to provide the list of tags to stub.

./bin/twig-lint lint tests/Asm89/Twig/Lint/Test/Fixtures/mixed.twig \
    --stub-tag some_other_block \
    --stub-tag stylesheets \
    --stub-tag meh \
    --stub-tag render \
    --stub-tag trans

Or via the options of the StubbedEnvironment in the constructor.

$twig = new StubbedEnvironment(
     new \Twig_Loader_Array(),
     array(
         'stub_tags' => $stubTagList,
     )
);

This might look like but thinking about it, it makes sense to only allow some tags to be stubbed so that a real "unknown tag" in your code can be detected by the linter.

Additionally, that kind of config would end in the twigcs.yml file, see my other PR.

@adrienrn
Copy link
Author

Added the same behavior for tests, to make "two words" tests work.

./bin/twig-lint lint tests/Asm89/Twig/Lint/Test/Fixtures/undefined_test.twig \
  --stub-test 'some_undefined_test' \
  --stub-test 'some_undefined_test_with_args' \
  --stub-test 'created by'

Did it because of this commit: twigphp/Twig@0d6686e#diff-6192884269e0c83e3fc69c733aa01715

Stubbing all tests made the two words tests fail and I feel a white-list behavior is better than to go and override the ExpressionParser.

PS: I shamelessly took some things from the https://github.com/asm89/twig-lint/pull/37/files to make this PR pass travis

@seyfer
Copy link

seyfer commented Mar 7, 2019

@adrienrn seems like this repository was abandoned.
I would continue maintaining your own repo. Just merge your PRs in your fork master.
And tag it like 1.1.0
That would be really useful.

@seyfer seyfer mentioned this pull request Mar 7, 2019
16 tasks
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

Successfully merging this pull request may close these issues.

2 participants