Skip to content

Commit

Permalink
Update php7.md
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerom committed Nov 4, 2019
1 parent 4f9d556 commit 1b70a7a
Showing 1 changed file with 34 additions and 17 deletions.
51 changes: 34 additions & 17 deletions doc/bc/5.90/php7.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# PHP 7 support

## PHP 7.0 support

For the [2017.10 release](https://github.com/ezsystems/ezpublish-legacy/releases/tag/v2017.10.0),
eZ Publish recived changes to switch to PHP 5 style constuctors all over the code base.

Reason is to reach full PHP 7 support by avoiding deprecation warnings for still using PHP 4
Reason is to reach full PHP 7.0 support by avoiding deprecation warnings for still using PHP 4
style constructors.

And while there are compatability functions kept around in most cases to avoid any fatal errors for you,
to avoid warnings you'll need to adapt too.

Here is an example of how you might need to adapt for this change in your code:

```diff
Expand All @@ -30,24 +34,37 @@ Other more common examples are classes extending `eZPersistentObject` or `eZData
You should also consider changing your own code to use PHP 5 style constructor while doing this,
in example above that would imply changing `function eZFindResultNode` to `function __construct`.

Further reading: http://php.net/manual/en/language.oop5.decon.phpi
Further reading:
- http://php.net/manual/en/language.oop5.decon.php
- https://www.php.net/manual/en/migration70.incompatible.php
- https://www.php.net/manual/en/migration71.incompatible.php

## PHP 7.2 support

Starting with 2019.03 release, issues on PHP 7.2 and PHP 7.3 has been fixed, but in your own code you'll ideally also need to handle some of this.

Most notably is `Warn when counting non-countable types` added in PHP 7.2.

To hande this across all supported PHP versions, we intropduced use of [symfony/polyfill-php73](https://github.com/symfony/polyfill-php73) package, witch backports PHP 7.3's function [is_countable](https://www.php.net/is_countable).

This comment has been minimized.

Copy link
@gggeek

gggeek Dec 18, 2019

Contributor

typo: intropduced

This comment has been minimized.

Copy link
@andrerom

andrerom Dec 18, 2019

Author Contributor

PR?

This comment has been minimized.

Copy link
@gggeek

gggeek Dec 18, 2019

Contributor

coming soon...

This comment has been minimized.

Copy link
@gggeek

gggeek Dec 18, 2019

Contributor

Here is an example of changes you might need to do in your own code around this:

Note: You should also increase requriment for ezplublish-legacy once the above changes are done like following example:
```diff
diff --git a/composer.json b/composer.json
index de225eb1..d0389c6d 100644
--- a/composer.json
+++ b/composer.json
@@ -11,7 +11,8 @@
],
"minimum-stability": "dev",
"require": {
- "ezsystems/ezpublish-legacy-installer": "*"
+ "ezsystems/ezpublish-legacy-installer": "*",
+ "ezsystems/ezpublish-legacy": ">=2017.10"
},
"extra": {
"ezpublish-legacy-extension-name": "ezfind"
diff --git a/kernel/common/eztemplatedesignresource.php b/kernel/common/eztemplatedesignresource.php
index b0fc28faa9a..9b8ca2a8d94 100644
--- a/kernel/common/eztemplatedesignresource.php
+++ b/kernel/common/eztemplatedesignresource.php
@@ -86,7 +86,7 @@ function templateNodeTransformation( $functionName, &$node,
$matchCount = 0;
foreach ( $customMatchList as $customMatch )
{
- $matchConditionCount = count( $customMatch['conditions'] );
+ $matchConditionCount = is_countable( $customMatch['conditions'] ) ? count( $customMatch['conditions'] ) : 0;
$code = '';
if ( $matchCount > 0 )
{
```

Further reading:
- https://www.php.net/manual/en/migration72.incompatible.php
- https://www.php.net/manual/en/migration73.incompatible.php

0 comments on commit 1b70a7a

Please sign in to comment.