phabelio / phabel

PHP transpiler - Write and deploy modern PHP 8 code, today.
MIT License
242 stars 8 forks source link

Symfony's function `import` has different signatures, it is not fixed when transpiling to 7.1 #9

Closed leoloso closed 3 years ago

leoloso commented 3 years ago

Symfony has the same function import from class FileLoader with different signatures, and these are not harmonized when transpiling to PHP 7.1.

In Symfony\Component\Config\Loader\FileLoader it has bool $ignoreErrors = false (source):

public function import($resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null, $exclude = null)

In its extending class Symfony\Component\DependencyInjection\Loader\FileLoader it has $ignoreErrors = false, so bool is missing (source):

public function import($resource, string $type = null, $ignoreErrors = false, string $sourceResource = null, $exclude = null)

When running this in PHP 7.1 it shows a warning (first lines of this screenshot):

Screenshot 2021-09-27 at 15-39-38 WordPress › Error

I guess that, when transpiling, the first function should have the bool typehint removed.

danog commented 3 years ago

This seems like a missing contra/covariance substitution, will look into this, it's supposed to work fine. Just in case, would you send here your composer.json?

leoloso commented 3 years ago

The project's composer.json is this one. (It's a WordPress plugin)

Symfony DependencyInjection is required in getpop/root (which is a standalone package, does not depend on WordPress), with this composer.json:

{
    "name": "getpop/root",
    "type": "library",
    "description": "Declaration of dependencies shared by all PoP components",
    "keywords": ["PoP", "root"],
    "homepage": "https://github.com/getpop/root",
    "license": "GPL-2.0-or-later",
    "authors": [
        {
            "name": "Leonardo Losoviz",
            "email": "leo@getpop.org",
            "homepage": "https://getpop.org"
        }
    ],
    "require": {
        "php": "^8.0",
        "symfony/config": "^5.1",
        "symfony/dependency-injection": "^5.1",
        "symfony/dotenv": "^5.1",
        "symfony/polyfill-php72": "^1.18",
        "symfony/polyfill-php73": "^1.18",
        "symfony/polyfill-php74": "^1.18",
        "symfony/polyfill-php80": "^1.18",
        "symfony/yaml": "^5.1"
    },
    "require-dev": {
        "phpstan/phpstan": "^0.12.76",
        "phpunit/phpunit": ">=9.3",
        "rector/rector": "^0.11",
        "squizlabs/php_codesniffer": "^3.0"
    },
    "autoload": {
        "psr-4": {
            "PoP\\Root\\": "src"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "PoP\\Root\\": "tests"
        }
    },
    "scripts": {
        "test": "phpunit",
        "check-style": "phpcs src tests",
        "fix-style": "phpcbf src tests",
        "analyse": "phpstan analyse"
    },
    "extra": {
        "branch-alias": {
            "dev-master": "0.9-dev"
        }
    },
    "config": {
        "sort-packages": true
    },
    "conflict": {
        "getpop/modulerouting": "<0.8.8",
        "getpop/hooks-wp": "<0.8.8",
        "getpop/loosecontracts": "<0.8.8",
        "getpop/translation": "<0.8.8",
        "getpop/mandatory-directives-by-configuration": "<0.8.8",
        "getpop/component-model": "<0.8.8",
        "getpop/filestore": "<0.8.8",
        "getpop/guzzle-helpers": "<0.8.8",
        "getpop/routing-wp": "<0.8.8",
        "getpop/translation-wp": "<0.8.8",
        "getpop/hooks": "<0.8.8",
        "getpop/engine-wp": "<0.8.8",
        "getpop/routing": "<0.8.8",
        "getpop/function-fields": "<0.8.8",
        "getpop/access-control": "<0.8.8",
        "getpop/definitions": "<0.8.8",
        "getpop/engine": "<0.8.8",
        "getpop/engine-wp-bootloader": "<0.8.8",
        "getpop/query-parsing": "<0.8.8",
        "getpop/field-query": "<0.8.8",
        "getpop/cache-control": "<0.8.8",
        "getpop/api-rest": "<0.8.8",
        "getpop/api-graphql": "<0.8.8",
        "getpop/api-endpoints": "<0.8.8",
        "getpop/api-endpoints-for-wp": "<0.8.8",
        "getpop/api": "<0.8.8",
        "getpop/api-clients": "<0.8.8",
        "getpop/api-mirrorquery": "<0.8.8",
        "pop-schema/post-category-mutations": "<0.8.8",
        "pop-schema/settings": "<0.8.8",
        "pop-schema/user-state-access-control": "<0.8.8",
        "pop-schema/comments": "<0.8.8",
        "pop-schema/users-wp": "<0.8.8",
        "pop-schema/custompostmeta-wp": "<0.8.8",
        "pop-schema/custompost-mutations": "<0.8.8",
        "pop-schema/post-tag-mutations-wp": "<0.8.8",
        "pop-schema/post-tag-mutations": "<0.8.8",
        "pop-schema/tags-wp": "<0.8.8",
        "pop-schema/posts": "<0.8.8",
        "pop-schema/custompost-tags-wp": "<0.8.8",
        "pop-schema/taxonomymeta-wp": "<0.8.8",
        "pop-schema/custompost-category-mutations": "<0.8.8",
        "pop-schema/taxonomymeta": "<0.8.8",
        "pop-schema/media-wp": "<0.8.8",
        "pop-schema/user-roles-wp": "<0.8.8",
        "pop-schema/commentmeta-wp": "<0.8.8",
        "pop-schema/taxonomyquery": "<0.8.8",
        "pop-schema/custompost-mutations-wp": "<0.8.8",
        "pop-schema/user-state-mutations": "<0.8.8",
        "pop-schema/user-state": "<0.8.8",
        "pop-schema/posts-wp": "<0.8.8",
        "pop-schema/custompostmedia-mutations": "<0.8.8",
        "pop-schema/post-categories-wp": "<0.8.8",
        "pop-schema/user-roles-access-control": "<0.8.8",
        "pop-schema/custompostmedia": "<0.8.8",
        "pop-schema/post-mutations": "<0.8.8",
        "pop-schema/user-state-mutations-wp": "<0.8.8",
        "pop-schema/user-roles": "<0.8.8",
        "pop-schema/usermeta": "<0.8.8",
        "pop-schema/queriedobject-wp": "<0.8.8",
        "pop-schema/user-avatars-wp": "<0.8.8",
        "pop-schema/taxonomyquery-wp": "<0.8.8",
        "pop-schema/customposts": "<0.8.8",
        "pop-schema/categories-wp": "<0.8.8",
        "pop-schema/meta": "<0.8.8",
        "pop-schema/comment-mutations": "<0.8.8",
        "pop-schema/schema-commons": "<0.8.8",
        "pop-schema/tags": "<0.8.8",
        "pop-schema/usermeta-wp": "<0.8.8",
        "pop-schema/commentmeta": "<0.8.8",
        "pop-schema/post-tags-wp": "<0.8.8",
        "pop-schema/custompost-categories-wp": "<0.8.8",
        "pop-schema/settings-wp": "<0.8.8",
        "pop-schema/users": "<0.8.8",
        "pop-schema/queriedobject": "<0.8.8",
        "pop-schema/customposts-wp": "<0.8.8",
        "pop-schema/taxonomies-wp": "<0.8.8",
        "pop-schema/comment-mutations-wp": "<0.8.8",
        "pop-schema/custompostmedia-wp": "<0.8.8",
        "pop-schema/menus": "<0.8.8",
        "pop-schema/block-metadata-for-wp": "<0.8.8",
        "pop-schema/post-categories": "<0.8.8",
        "pop-schema/pages-wp": "<0.8.8",
        "pop-schema/custompostmedia-mutations-wp": "<0.8.8",
        "pop-schema/user-roles-acl": "<0.8.8",
        "pop-schema/user-avatars": "<0.8.8",
        "pop-schema/comments-wp": "<0.8.8",
        "pop-schema/generic-customposts": "<0.8.8",
        "pop-schema/metaquery-wp": "<0.8.8",
        "pop-schema/pages": "<0.8.8",
        "pop-schema/menus-wp": "<0.8.8",
        "pop-schema/custompostmeta": "<0.8.8",
        "pop-schema/categories": "<0.8.8",
        "pop-schema/taxonomies": "<0.8.8",
        "pop-schema/post-category-mutations-wp": "<0.8.8",
        "pop-schema/custompost-tag-mutations": "<0.8.8",
        "pop-schema/user-state-wp": "<0.8.8",
        "pop-schema/media": "<0.8.8",
        "pop-schema/post-tags": "<0.8.8",
        "graphql-by-pop/graphiql": "<0.8.8",
        "graphql-by-pop/graphql-voyager": "<0.8.8",
        "graphql-by-pop/graphql-clients-for-wp": "<0.8.8",
        "graphql-by-pop/graphql-request": "<0.8.8",
        "graphql-by-pop/graphql-endpoint-for-wp": "<0.8.8",
        "graphql-by-pop/graphql-query": "<0.8.8",
        "graphql-by-pop/graphql-parser": "<0.8.8",
        "graphql-by-pop/graphql-server": "<0.8.8",
        "graphql-api/external-dependency-wrappers": "<0.8.8",
        "graphql-api/markdown-convertor": "<0.8.8",
        "graphql-api/extension-demo": "<0.8.8",
        "graphql-api/graphql-api-for-wp": "<0.8.8",
        "getpop/definitions-emoji": "<0.8.8",
        "getpop/static-site-generator": "<0.8.8",
        "getpop/resources": "<0.8.8",
        "getpop/definitions-base36": "<0.8.8",
        "getpop/spa": "<0.8.8",
        "getpop/component-model-configuration": "<0.8.8",
        "getpop/site-builder-api": "<0.8.8",
        "getpop/definitionpersistence": "<0.8.8",
        "getpop/application-wp": "<0.8.8",
        "getpop/resourceloader": "<0.8.8",
        "getpop/site": "<0.8.8",
        "getpop/site-wp": "<0.8.8",
        "getpop/application": "<0.8.8",
        "getpop/multisite": "<0.8.8",
        "pop-sites-wassup/form-mutations": "<0.8.8",
        "pop-sites-wassup/newsletter-mutations": "<0.8.8",
        "pop-sites-wassup/flag-mutations": "<0.8.8",
        "pop-sites-wassup/custompost-mutations": "<0.8.8",
        "pop-sites-wassup/notification-mutations": "<0.8.8",
        "pop-sites-wassup/postlink-mutations": "<0.8.8",
        "pop-sites-wassup/user-state-mutations": "<0.8.8",
        "pop-sites-wassup/gravityforms-mutations": "<0.8.8",
        "pop-sites-wassup/post-mutations": "<0.8.8",
        "pop-sites-wassup/comment-mutations": "<0.8.8",
        "pop-sites-wassup/contactus-mutations": "<0.8.8",
        "pop-sites-wassup/contactuser-mutations": "<0.8.8",
        "pop-sites-wassup/volunteer-mutations": "<0.8.8",
        "pop-sites-wassup/highlight-mutations": "<0.8.8",
        "pop-sites-wassup/stance-mutations": "<0.8.8",
        "pop-sites-wassup/socialnetwork-mutations": "<0.8.8",
        "pop-sites-wassup/share-mutations": "<0.8.8",
        "pop-sites-wassup/system-mutations": "<0.8.8",
        "pop-sites-wassup/custompostlink-mutations": "<0.8.8",
        "pop-wp-schema/posts": "<0.8.8",
        "pop-wp-schema/customposts": "<0.8.8",
        "pop-wp-schema/users": "<0.8.8",
        "pop-wp-schema/menus": "<0.8.8",
        "pop-wp-schema/pages": "<0.8.8",
        "pop-wp-schema/media": "<0.8.8"
    }
}