8000 Use class_exists instead of require by ogizanagi · Pull Request #2502 · twigphp/Twig · GitHub
[go: up one dir, main page]

Skip to content

Use class_exists instead of require 10000 #2502

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

Merged
merged 1 commit into from
Jun 5, 2017

Conversation

ogizanagi
Copy link
Contributor
@ogizanagi ogizanagi commented Jun 5, 2017

I think this is required for symfony/symfony#23073 to pass. It's probably very similar to symfony/symfony#22657.

A simple reproducer:

<?php

use Twig\Node\Node;

require_once __DIR__ . '/vendor/autoload.php';

new Node();
new \Twig_Node();

Without this patch:

PHP Fatal error:  Cannot declare class Twig_Node, because the name is already in use in vendor/twig/twig/lib/Twig/Node.php on line 20

With, everything works fine, whatever the two calls order.

@ogizanagi ogizanagi changed the title Use class_alias instead of require Use class_exists instead of require Jun 5, 2017
@ogizanagi ogizanagi force-pushed the fix/cannot_redeclare_class branch from 01f0715 to 2c174e4 Compare June 5, 2017 21:43
@fabpot
Copy link
Contributor
fabpot commented Jun 5, 2017

Thank you @ogizanagi.

@fabpot fabpot merged commit 2c174e4 into twigphp:1.x Jun 5, 2017
fabpot added a commit that referenced this pull request Jun 5, 2017
This PR was merged into the 1.x branch.

Discussion
----------

Use class_exists instead of require

I think this is required for symfony/symfony#23073 to pass. It's probably very similar to symfony/symfony#22657.

A simple reproducer:

```php
<?php

use Twig\Node\Node;

require_once __DIR__ . '/vendor/autoload.php';

new Node();
new \Twig_Node();
```

[Without this patch](https://travis-ci.org/symfony/symfony/jobs/239712676#L2100):

```php
PHP Fatal error:  Cannot declare class Twig_Node, because the name is already in use in vendor/twig/twig/lib/Twig/Node.php on line 20
```

With, everything works fine, whatever the two calls order.

Commits
-------

2c174e4 Use class_exists instead of require
@ogizanagi ogizanagi deleted the fix/cannot_redeclare_class branch June 6, 2017 04:20
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
0