Context:
With the recent PHP 7 version releases, many sites are being migrated from PHP 5.6, and in that process, compatibility checks are being executed using PHPCompatibility for PHPCodeSniffer to guarantee that code is compatible with all PHP 7 releases.
Problem:
Running the compatibility check on the branch 7.x-2.x-dev for PHP 7.1, the following errors are shown:
FILE: workflow/workflow_admin_ui/workflow_admin_ui.api.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 1 LINE
----------------------------------------------------------------------
21 | ERROR | 'object' type declaration is not present in PHP version
| | 7.1 or earlier
21 | ERROR | 'object' type declaration is not present in PHP version
| | 7.1 or earlier
----------------------------------------------------------------------
Solution:
The reason for these errors is that the "object" type hint is not allowed on PHP 7.1 and PHP 7.0. This was later re-introduced on PHP 7.2, as per the RFC (https://wiki.php.net/rfc/object-typehint)
Since the parameters that are type-hinted this way are already object instances of a custom class (Workflow and WorkflowState), this would be the best approach.
Impact:
As this is only a api documentation file, this has no impact on any of the module's functionality.
Regardless, this should be fixed so that site developers use the correct type hint when implementing this hook.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | php7.1_compatibility_type_hint-2952583-2.patch | 1.03 KB | caminadaf |
Comments
Comment #2
caminadaf commentedAttaching patch that solves the compatibility issue.
Comment #3
caminadaf commentedComment #5
johnvFixed, thanks.