Skip to content

[1.x] Allow using namespaced aliases as extension names#2490

Merged
fabpot merged 1 commit intotwigphp:1.xfrom
nicolas-grekas:alias
May 31, 2017
Merged

[1.x] Allow using namespaced aliases as extension names#2490
fabpot merged 1 commit intotwigphp:1.xfrom
nicolas-grekas:alias

Conversation

@nicolas-grekas
Copy link
Copy Markdown
Contributor

No description provided.

@stof
Copy link
Copy Markdown
Member

stof commented May 30, 2017

Actually, can you add a unit test covering this ?

@nicolas-grekas
Copy link
Copy Markdown
Contributor Author

test added

@nicolas-grekas
Copy link
Copy Markdown
Contributor Author

Now with some require_once so that PHP doesn't cry because of incompatible type hints (because it doesn't know about the aliases yet.)

*/

require_once dirname(__FILE__).'/FilesystemHelper.php';
require_once __DIR__.'/FilesystemHelper.php';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be reverted. Even if you're right here, I prefer to not upgrade the code to 5.3+ in 1.x. It has been done in 2.x and I don't want people starting to send random PR about such changes :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

reverted

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

haha, who should I fallow? fabpot or fabbot?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(#2493 ;) )

@stof
Copy link
Copy Markdown
Member

stof commented May 30, 2017

Do we actually need these require_once everywhere ?

@nicolas-grekas
Copy link
Copy Markdown
Contributor Author

Yes. That's what symfony/symfony#22962 allowed me to spot.

@nicolas-grekas
Copy link
Copy Markdown
Contributor Author

renamed Twig\Environment to Twig\Twig

public function setLoader(Twig_LoaderInterface $loader)
{
if (!$loader instanceof Twig_SourceContextLoaderInterface && 0 !== strpos(get_class($loader), 'Mock_Twig_LoaderInterface')) {
if (!$loader instanceof Twig_SourceContextLoaderInterface && 0 !== strpos(get_class($loader), 'Mock_')) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Mock_Twig_LoaderInterface vs Mock_LoaderInterface when sing the namespaced variant
looking for mock_ is enough IMHO

@nicolas-grekas
Copy link
Copy Markdown
Contributor Author

Now with aliases that were missing for Twig_Extension_InitRuntimeInterface, Twig_Extension_GlobalsInterface, Twig_SourceContextLoaderInterface and Twig_ExistsLoaderInterface

PR should be ready.

@fabpot
Copy link
Copy Markdown
Contributor

fabpot commented May 31, 2017

Thank you @nicolas-grekas.

@fabpot fabpot merged commit c9a2f3d into twigphp:1.x May 31, 2017
fabpot added a commit that referenced this pull request May 31, 2017
…colas-grekas)

This PR was merged into the 1.x branch.

Discussion
----------

[1.x] Allow using namespaced aliases as extension names

Commits
-------

c9a2f3d [1.x] Allow using namespaced aliases as extension names
@nicolas-grekas nicolas-grekas deleted the alias branch May 31, 2017 21:26
@Koc
Copy link
Copy Markdown
Contributor

Koc commented May 31, 2017

@fabpot why reverted \Twig\Twig?

@fabpot
Copy link
Copy Markdown
Contributor

fabpot commented Jun 1, 2017

After trying to use the new class, it felt wrong. Twig feels like a singleton, which is wrong. Environment conveys the idea that you can have more than one, which is better.

nicolas-grekas added a commit to symfony/symfony that referenced this pull request Jun 2, 2017
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
fabpot added a commit that referenced this pull request Jun 12, 2017
This PR was merged into the 1.x branch.

Discussion
----------

Update .php_cs.dist

following #2490 (comment)
:)

Commits
-------

8539a18 Update .php_cs.dist
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.

5 participants