phpro / grumphp

A PHP code-quality tool
MIT License
4.14k stars 430 forks source link

Call to undefined function get_debug_type() #832

Closed prudloff-insite closed 3 years ago

prudloff-insite commented 3 years ago
Q A
Version 1.1.0
Bug? yes
New feature? no
Question? no
Documentation? no
Related tickets

The 1.1.0 PHAR crashes when calling run. I don't have this issue with the 1.0.0 PHAR or with 1.1.0 installed locally by Composer.

My configuration

---
grumphp:
  ascii:
    failed: ~
    succeeded: ~
  tasks:
    composer: ~
    jsonlint: ~
    yamllint: ~
    composer_normalize:
      use_standalone: true
    xmllint:
      ignore_patterns:
        - .docksal/etc/solr/
    phpcs:
      standard: tests/phpcs.xml
      triggered_by:
        - php
        - module
        - inc
        - install
        - test
        - profile
        - theme
        - info
        - txt
        - md
    phpmd:
      ruleset:
        - tests/phpmd.xml

Note that I don't have the issue if I only keep this part of the config file:

---
grumphp:
  ascii:
    failed: ~
    succeeded: ~
  tasks:
    composer: ~
    jsonlint: ~
    yamllint: ~

Steps to reproduce:

phive install grumphp
grumphp run

Result:

PHP Fatal error:  Uncaught Error: Call to undefined function get_debug_type() in phar:///home/pierre/.phive/phars/grumphp-1.1.0.phar/vendor/symfony/options-resolver/OptionsResolver.php:975
Stack trace:
#0 phar:///home/pierre/.phive/phars/grumphp-1.1.0.phar/vendor/symfony/options-resolver/OptionsResolver.php(864): _HumbugBox7411c7c548dd\Symfony\Component\OptionsResolver\OptionsResolver->verifyTypes()
#1 phar:///home/pierre/.phive/phars/grumphp-1.1.0.phar/vendor/symfony/options-resolver/OptionsResolver.php(774): _HumbugBox7411c7c548dd\Symfony\Component\OptionsResolver\OptionsResolver->offsetGet()
#2 phar:///home/pierre/.phive/phars/grumphp-1.1.0.phar/src/Configuration/Resolver/TaskConfigResolver.php(35): _HumbugBox7411c7c548dd\Symfony\Component\OptionsResolver\OptionsResolver->resolve()
#3 phar:///home/pierre/.phive/phars/grumphp-1.1.0.phar/src/Configuration/Compiler/TaskCompilerPass.php(48): GrumPHP\Configuration\Resolver\TaskConfigResolver->resolve()
#4 phar:///home/pierre/.phive/phars/grumphp-1.1.0.phar/src/Task/Config/LazyTa in phar:///home/pierre/.phive/phars/grumphp-1.1.0.phar/vendor/symfony/options-resolver/OptionsResolver.php on line 975
veewee commented 3 years ago

Strange .. it works here. That function should be inside symfony's polyfills, which is installed in the phar. Can you give me some additional information about your system? Maybe a PHP version and a composer file of your project?

composer show

...
symfony/polyfill-php80               v1.20.0             Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
...
prudloff-insite commented 3 years ago

I am running PHP 7.3.23.

The composer.json is probably irrelevant here because it is running on a CI environment where everything is installed with phive and composer install is never called.

If I run strings tools/grumphp|grep "function get_debug_type" on the PHAR, I can indeed see the function is here:

    function get_debug_type($value) : string
    public static function get_debug_type($value) : string
veewee commented 3 years ago

It works on my end because I had the polyfills inside my local project as well. If I put it in a project without vendors, it crashes.

Will have to play around with it a bit more to find the root cause. But I am ussuming that box is able to prefix the symfony polyfills, but is not able to transform their usage in the code, since those are located in PHP's root namespace. Might need to whitelist symfony/polyfills-* from being prefixed.

veewee commented 3 years ago

@prudloff-insite : I've added a fix to the shim project. Feel free to test it out.