Conversation
nicolas-grekas
commented
May 30, 2017
| Q | A |
|---|---|
| Branch? | 2.7 |
| Bug fix? | yes |
| New feature? | no |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | needs twigphp/Twig#2490 and twigphp/Twig#2491 |
| Fixed tickets | - |
| License | MIT |
| Doc PR | - |
| use Twig\Markup; | ||
| use Twig\Profiler\Dumper\HtmlDumper; | ||
| use Twig\Profiler\Profile; | ||
| use Twig\Source; |
There was a problem hiding this comment.
@keradus just wondering: this useis not used in the class - is it a php-cs-fixer bug that fabbot is still green?
There was a problem hiding this comment.
The NoUnusedImportsFixer is quite permissive (not removing an unsed import in better than removing an used one) particularly it check if the class in not referenced in a comment.
In this case it think it's the "source" word in the license header comment that make the fixer think that the class is still used.
There was a problem hiding this comment.
that's exactly the case here.
Imported class name could be used in comment, even in different casing, which later is utilized by Doctrine or some annotation-parsers. that behaviour was added after fixer broke some code.
I would not focus here is it header comment or other comment actually.
One could bring configuration to fixer to ignore comments or non-docblock comments / be strict about casing !
There was a problem hiding this comment.
Is there a way to make it more strict so that I can cleanup locally?
There was a problem hiding this comment.
@nicolas-grekas Not currently, see PHP-CS-Fixer/PHP-CS-Fixer#2814.
| * @param Environment $twig | ||
| */ | ||
| public function setTwigEnvironment(\Twig_Environment $twig) | ||
| public function setTwigEnvironment(Environment $twig) |
There was a problem hiding this comment.
Reading this, I would rename Twig\Environment to Twig\Twig
There was a problem hiding this comment.
Is it possible to name it just Twig to avoid the Twig\Twig repetition?
There was a problem hiding this comment.
Yep but you will have to import Twig\Twig anyway
There was a problem hiding this comment.
We cannot use Twig only as all classes need to be under a namespace. That's PSR-4.
There was a problem hiding this comment.
@javiereguiluz PSR-4 doesn't allow top-level classes. In §2.2.1, "The fully qualified class name MUST have a top-level namespace name, also known as a “vendor namespace”.
http://www.php-fig.org/psr/psr-4/#specification
There was a problem hiding this comment.
renamed to Twig\Twig
6a2452b to
4cfb449
Compare
|
Just fixed a few potential BC breaks related to the use of aliases type hints. |
| } | ||
|
|
||
| return !$param->getClass() || $param->getClass()->getName() !== 'Twig_Environment'; | ||
| return !$param->getClass() || !in_array($param->getClass()->getName(), array('Twig_Environment', 'Twig\Twig')); |
There was a problem hiding this comment.
Using class_alias, the ReflectionClass refers to the original class. Checking against Twig\Twig is not necessary.
https://3v4l.org/QH2KQ
There was a problem hiding this comment.
True, until Twig moves to namespaces-first, which is why this code is here.
There was a problem hiding this comment.
Actually, this logic could be improved to avoid relying on typehints or param names (btw, the check on param name is wrong, as the name is not relevant). I will send a PR.
There was a problem hiding this comment.
@nicolas-grekas please revert this change to avoid useless conflicts with my PR removing this code entirely 😄
| * | ||
| * @return array An array with the contexts the URL is safe | ||
| * | ||
| * To be made @final in 3.4, and the type-hint be changed to "\Twig\Node\Node" in 4.0. |
There was a problem hiding this comment.
Wouldn't this trigger the warning already ? Or does DebugClassLoader check for beginning of lines ?
There was a problem hiding this comment.
| * | ||
| * To be made @final in 3.4, and the type-hint be changed to "\Twig\Node\Node" in 4.0. | ||
| */ | ||
| public function isUrlGenerationSafe(\Twig_Node $argsNode) |
There was a problem hiding this comment.
Can't we already change the typehint here (with the same class_exists call) ?
There was a problem hiding this comment.
We can, but that means loading Node, which in turn loads Compiler.
I preferred not, thus the current code.
223b126 to
029377d
Compare
|
now green |
fabpot
left a comment
There was a problem hiding this comment.
You just need to revert the Twig\Environment => Twig\Twig change. Sorry about that :)
|
renaming done, now green |
This PR was merged into the 2.7 branch. Discussion ---------- Use namespaced Twig | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | needs twigphp/Twig#2490 and twigphp/Twig#2491 | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- c3d1262 Use namespaced Twig