Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Towards PHP 7 compatibility #14086

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

Closed
stof opened this issue Mar 27, 2015 · 28 comments
Closed

Towards PHP 7 compatibility #14086

stof opened this issue Mar 27, 2015 · 28 comments

Comments

@stof
Copy link
Member

stof commented Mar 27, 2015

PHP 7 is meant to be released at the end of the year. At this time, our supported versions will be 2.3, 2.6 (security-only), 2.7 and 3.0. Each of these versions will need to be compatible with PHP 7.

Currently, Travis is running our testsuite against PHP 7 nightly, showing that this goal is not yet reached.

A bunch of tests are triggering fatal errors. We should debug the reason for that, to see whether it is a regression in PHP (which should be reported to them as soon as possible) or something related to one of the PHP 7 BC breaks, requiring to fix our code:

Except these components where we cannot run tests because of these errors, the only remaining failures on PHP 7 for Symfony 2.3 (you can check Travis builds for other branches to see whether there are more in newer versions) are the parsing of hexadecimal numeric strings in XmlUtils and Yaml because PHP 7 does not cast them as int anymore. We will need to implement this conversion separately.
It would be great to start working on the PHP 7 compatibility soon (especially for the issue with class names being reserved because it might require deprecating a class name in favor of a new one, which should be done before the 2.7 release)

@Tobion
Copy link
Contributor

Tobion commented Mar 27, 2015

For Translation component: #14087

@dosten
Copy link
Contributor

dosten commented Mar 27, 2015

The Security test seems to be a phpunit issue

@xabbuh
Copy link
Member

xabbuh commented Mar 27, 2015

@dosten Did you see an open issue at the PhpUnit repo?

@dosten
Copy link
Contributor

dosten commented Mar 27, 2015

@xabbuh No, i see that the error come from here https://github.com/symfony/security-core/blob/master/Tests/Authentication/Token/RememberMeTokenTest.php#L55-L62.
Seems that PHPUnit is not catching the exceptions in PHP7.

@Tobion
Copy link
Contributor

Tobion commented Mar 27, 2015

That test doesn't make sense. You don't test against phpunit exceptions and even testing fatal errors that are ensured by the language is even worse. Then we would have to add a lot of tests. I'll fix it.

@Tobion
Copy link
Contributor

Tobion commented Mar 27, 2015

See #14088

fabpot added a commit that referenced this issue Mar 29, 2015
This PR was merged into the 2.3 branch.

Discussion
----------

remove useless tests that fail in php 7

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #14086 for Security and Form component
| License       | MIT
| Doc PR        | -

`@expectedException \PHPUnit_Framework_Error` doesn't catch php fatal errors for wrong types in php 7. But these test are also pretty useless anyway. Then we would have to add a lot of tests for all arguments that are typehinted. Let's just remove these tests.

Commits
-------

59cab27 remove useless tests that fail in php 7
fabpot added a commit that referenced this issue Mar 29, 2015
This PR was merged into the 2.3 branch.

Discussion
----------

[Translator] fix test for php 7 compatibility

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #14086 for Translation component
| License       | MIT
| Doc PR        | -

Commits
-------

02b829f [Translator] fix test for php 7 compatibility
@stof
Copy link
Member Author

stof commented Mar 30, 2015

See #14107 for the remaining work

fabpot added a commit that referenced this issue Mar 30, 2015
This PR was merged into the 2.3 branch.

Discussion
----------

Add parsing of hexadecimal strings for PHP 7

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #14086
| License       | MIT
| Doc PR        | n/a

PHP 7 does not handle the hexadecimal notation in is_numeric checks anymore, so the detection needs to be implemented explicitly.

With this change, we should have a passing testsuite on PHP 7

Commits
-------

e848040 Add parsing of hexadecimal strings for PHP 7
@fabpot fabpot closed this as completed Mar 30, 2015
@stof
Copy link
Member Author

stof commented Apr 2, 2015

Reopening because we are not there yet.

We have some classes using reserved keywords in the Validator component (the True and False constraints for instance).
The only way to fix this is to rename the constraint to a different name and deprecate the old name (providing it through a class_alias for PHP 5.x to avoid defining a class with the reserved named for PHP 7). So we must do it before the 2.7 release to have the new constraint names in the LTS version.

We also have some test failures in the Debug, Translation and VarDumper components

@nicolas-grekas
Copy link
Member

See #14204 for VarDumper

For Debug (and maybe also VarDumper), we'll have to wait until the new exception mechanism is stabilized

@stefanruijsenaars
Copy link
Contributor

I think #14228 is ready now, how are we doing otherwise with this issue?

@stefanruijsenaars
Copy link
Contributor

Just crossposting @nicolas-grekas comments from #14228 which seems to help the tests a bit further along and exposes a fatal error for the Validator component. Possibly a PHP 7 bug or maybe it's something we can code around.

Anyone have a PHP 7 setup to debug this on?: https://travis-ci.org/symfony/symfony/jobs/61229099#L560

stof added a commit that referenced this issue May 15, 2015
…straints as they are reserved words in PHP7 (stefan.r)

This PR was merged into the 2.3 branch.

Discussion
----------

Add PHP7 compatible versions for the Null/True/False constraints as they are reserved words in PHP7

| Q             | A
| ------------- | ---
| Bug fix?      |  PHP7 compatibility
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | N/A
| Fixed tickets | N/A - helps towards #14086
| License       | MIT

Null, True and False are reserved words in PHP7:

https://wiki.php.net/rfc/reserve_more_types_in_php_7

Commits
-------

44edbdf Fixed compatibility with PHP7 and up by introducing new constraints (IsNull, IsTrue, IsFalse) and related validators (IsNullValidator, IsTrueValidator, IsFalseValidator)
symfony-splitter pushed a commit to symfony/validator that referenced this issue May 15, 2015
…straints as they are reserved words in PHP7 (stefan.r)

This PR was merged into the 2.3 branch.

Discussion
----------

Add PHP7 compatible versions for the Null/True/False constraints as they are reserved words in PHP7

| Q             | A
| ------------- | ---
| Bug fix?      |  PHP7 compatibility
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | N/A
| Fixed tickets | N/A - helps towards symfony/symfony#14086
| License       | MIT

Null, True and False are reserved words in PHP7:

https://wiki.php.net/rfc/reserve_more_types_in_php_7

Commits
-------

44edbdf Fixed compatibility with PHP7 and up by introducing new constraints (IsNull, IsTrue, IsFalse) and related validators (IsNullValidator, IsTrueValidator, IsFalseValidator)
symfony-splitter pushed a commit to symfony/form that referenced this issue May 15, 2015
…straints as they are reserved words in PHP7 (stefan.r)

This PR was merged into the 2.3 branch.

Discussion
----------

Add PHP7 compatible versions for the Null/True/False constraints as they are reserved words in PHP7

| Q             | A
| ------------- | ---
| Bug fix?      |  PHP7 compatibility
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | N/A
| Fixed tickets | N/A - helps towards symfony/symfony#14086
| License       | MIT

Null, True and False are reserved words in PHP7:

https://wiki.php.net/rfc/reserve_more_types_in_php_7

Commits
-------

44edbdf Fixed compatibility with PHP7 and up by introducing new constraints (IsNull, IsTrue, IsFalse) and related validators (IsNullValidator, IsTrueValidator, IsFalseValidator)
symfony-splitter pushed a commit to symfony/form that referenced this issue May 15, 2015
…straints as they are reserved words in PHP7 (stefan.r)

This PR was merged into the 2.3 branch.

Discussion
----------

Add PHP7 compatible versions for the Null/True/False constraints as they are reserved words in PHP7

| Q             | A
| ------------- | ---
| Bug fix?      |  PHP7 compatibility
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | N/A
| Fixed tickets | N/A - helps towards symfony/symfony#14086
| License       | MIT

Null, True and False are reserved words in PHP7:

https://wiki.php.net/rfc/reserve_more_types_in_php_7

Commits
-------

44edbdf Fixed compatibility with PHP7 and up by introducing new constraints (IsNull, IsTrue, IsFalse) and related validators (IsNullValidator, IsTrueValidator, IsFalseValidator)
@stof
Copy link
Member Author

stof commented May 15, 2015

Remaining issues on PHP 7:

  • the fatal error in the Validator tests
  • the YAML component failures

@bitraft
Copy link

bitraft commented Jul 16, 2015

any update ?

@fabpot
Copy link
Member

fabpot commented Jul 16, 2015

@changloong We've fixed a bunch of other errors, but not all of them. If you have some time, can you help us finish this one?

@bitraft
Copy link

bitraft commented Jul 16, 2015

Hi @fabpot

I think I can work on this and make some pull request when I pass my local test:)

@GrahamCampbell
Copy link
Contributor

The debug component needs updating to correctly display throwables. This came up in laravel 5.2.

@fabpot
Copy link
Member

fabpot commented Jul 16, 2015

@GrahamCampbell That's probably something for @nicolas-grekas :)

@GrahamCampbell
Copy link
Contributor

Great. :)

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jul 16, 2015 via email

@GrahamCampbell
Copy link
Contributor

Loosing the exception typehint from non-private methods on non-final classes is a bigish breaking change though. Does this mean many of the changes can only be made on symfony 3.0?

@mickaelandrieu
Copy link
Contributor

@stof I met some issues with ParameterBag / ContainerBuilder too. I will try to make a relevant issue asap :/

fabpot added a commit that referenced this issue Jul 28, 2015
…-grekas)

This PR was merged into the 2.3 branch.

Discussion
----------

[php7] Fix for substr() always returning a string

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #14086
| License       | MIT
| Doc PR        | -

This should be the last required fix for PHP7 support.

The patch in the debug component is a workaround for a bug in PHP7 (http://3v4l.org/8rm9B) that is going to be fixed soon (@jpauli power).

Commits
-------

77ee866 [php7] Fix for substr() always returning a string
@fabpot fabpot closed this as completed Jul 28, 2015
fabpot added a commit that referenced this issue Jul 29, 2015
…-grekas)

This PR was merged into the 2.7 branch.

Discussion
----------

[php7] Fix for substr() always returning a string

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #14086
| License       | MIT
| Doc PR        | -

The remaining failures will stop once https://bugs.php.net/bug.php?id=70159 is fixed ([patch pending](php/php-src@a28115c)).

Commits
-------

d6dfe98 [php7] Fix for substr() always returning a string
fabpot added a commit that referenced this issue Aug 5, 2015
…ekas)

This PR was merged into the 2.3 branch.

Discussion
----------

[travis] Build phpunit with local components

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #14086
| License       | MIT
| Doc PR        | -

The tests for PHP7 currently fail because travis ships with a phar phpunit that embeds the yaml components. This one takes priority over the one in the repo. But it is outdated.
The issue arose with PHP7 tests but could have happen with any build.

Commits
-------

ce2a371 [travis] Build phpunit with local components
@anacicconi
Copy link

anacicconi commented Nov 16, 2016

Sorry if my question is not in the right place but this discussion made me realize that I cannot upgrade my project to PHP7 as I'm using Symfony 2.8. I just checked on Github and all 2.8 related tags have the old names for the constraints (True, False, Null...). I was surprised because I had read this post before checking the code:

http://symfony.com/blog/symfony-achieves-100-php7-compatibility

If that's the case, do I have to upgrade to Symfony 3 in order to upgrade to PHP7? As Symfony 3.1 is not a LTS I thought it wasn't a good idea to use it on production. Am I right? How are you guys doing to have both a LTS Symfony version and PHP7 on production? Thanks!

@lyrixx
Copy link
Member

lyrixx commented Nov 16, 2016

Symfony 2.8 (and even 2.7) are compatible with PHP7. as you can see on github, the class True is deprecated. So if you don't use it, everything will be fine. Instead you should use IsTrue

@xabbuh
Copy link
Member

xabbuh commented Nov 16, 2016

@anacicconi All releases before Symfony 3.0 ship with both the legacy and the Is-prefixed class names (see for example True and IsTrue).

@anacicconi
Copy link

Oh, ok! I didn't understand that. So I can keep 2.8. Just out of curiosity, is it recommended to use Symfony3.1 on production?

@stof
Copy link
Member Author

stof commented Nov 16, 2016

sure

@lyrixx
Copy link
Member

lyrixx commented Nov 16, 2016

@anacicconi sure. we are using it ;)

@anacicconi
Copy link

Ok, thanks ;)

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

No branches or pull requests