Skip to content
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

Collector not compatible with Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface #385

Closed
tinwe123 opened this issue Aug 13, 2020 · 9 comments

Comments

@tinwe123
Copy link

PHP version: 7.1.33

Description
During composer install then clearing cache in symfony application i got fatal error

How to reproduce

Possible Solution
public function collect(Request $request, Response $response, \Exception $exception = null)
instead
public function collect(Request $request, Response $response, $exception = null)

PHP Fatal error: Declaration of Http\HttplugBundle\Collector\Collector::collect(Symfony\Component\HttpFoundation\R
equest $request, Symfony\Component\HttpFoundation\Response $response, $exception = NULL) must be compatible with Sy
mfony\Component\HttpKernel\DataCollector\DataCollectorInterface::collect(Symfony\Component\HttpFoundation\Request $
request, Symfony\Component\HttpFoundation\Response $response, ?Exception $exception = NULL) in /vendor/php-http/httplug-bundle/src/Collector/Collector.php on line 191

@xabbuh
Copy link
Member

xabbuh commented Aug 13, 2020

Which version of the bundle do you use? 1.1.6.0 is the latest version supporting PHP 7.1 and the code looks different there.

@eduard-sukharev
Copy link

eduard-sukharev commented Aug 19, 2020

I double this: I get incompatibility fatal error.
Relevant composer.json parts:

{
"require": {
    "php": ">=7.1",
    "symfony/symfony": "^3.4",
    "php-http/guzzle6-adapter": "^2.0",
    "php-http/httplug-bundle": "^1.18"
}
}

Symfony 3.4.43 with httplug 2.2.0 and httplug-bundle 1.18 installed.
The reason is that \Http\HttplugBundle\Collector\Collector::collect does not define the last $exception parameter to be of type ?Exception

Works fine on 1.17.0

@xabbuh
Copy link
Member

xabbuh commented Aug 19, 2020

Which PHP version do you use when you run into this issue?

@lies
Copy link

lies commented Aug 26, 2020

I have some problem.
Symfony 3.4
httplug-bundle 1.18
php 7.2

@dbu
Copy link
Collaborator

dbu commented Aug 27, 2020

in #387 i make the lowest version test with php 7.2. the test is green with 7.2, so either we are missing a test on that collector or something weird is going on.

we do test the collector: https://github.com/php-http/HttplugBundle/blob/master/tests/Unit/Collector/CollectorTest.php

why does this not fail during the tests?

@xabbuh
Copy link
Member

xabbuh commented Aug 27, 2020

@lies Are you sure that this is happening on PHP 7.2? Please note that the PHP version used on the command-line may be different from the one used when serving your application over HTTP.

@ek-yrabiller
Copy link

ek-yrabiller commented Oct 23, 2020

Problem confirmed here.

PHP 7.1.33, but composer config.platform.php is PHP 7.2.5.
Symfony 3.4.5 (problematic file)
HttplugBundle 1.19.0 (problematic file)

I can confirm also that the bug appeared in 1.18.0.

@xabbuh
Copy link
Member

xabbuh commented Oct 23, 2020

Well, If you are running your application on PHP 7.1, you must not set the platform PHP version to 7.2 as you will get non-compatible dependencies then.

@dbu
Copy link
Collaborator

dbu commented Oct 26, 2020

if you hack around with the platform configuration, i recommend you set your requirements, as well as indirect requirements, to exact version numbers that you know work together. (e.g. find in the httplug bundle changelog where we drop support for php 7.1 and pin your requirement to php-http/httplug-bundle to the version that came right before that).

@dbu dbu closed this as completed Oct 26, 2020
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

6 participants