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

Compile error Declaration of [...] must be compatible with [...] #1024

Closed
PauchardThomas opened this issue Dec 21, 2018 · 4 comments
Closed

Comments

@PauchardThomas
Copy link

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no

Hello, got this issue when trying to return content from API REST

message: "Compile Error: Declaration of JMS\Serializer\JsonSerializationVisitor::startVisitingObject(JMS\Serializer\Metadata\ClassMetadata $metadata, JMS\Serializer\object $data, array $type): void must be compatible with JMS\Serializer\Visitor\SerializationVisitorInterface::startVisitingObject(JMS\Serializer\Metadata\ClassMetadata $metadata, JMS\Serializer\Visitor\object $data, array $type): void"

Trace :

vendor/jms/serializer/src/JsonSerializationVisitor.php

My composer.json :

"require" : {
"php": ">=5.5.9",
"adelplace/onesignal-bundle": "^1.1",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"friendsofsymfony/rest-bundle": "dev-master",
"friendsofsymfony/user-bundle": "^2.0",
"incenteev/composer-parameter-handler": "^2.0",
"jms/serializer-bundle": "2.0.1",
"mashape/unirest-php": "^3.0",
"nc/elephantio-bundle": "^2.1",
"nelmio/api-doc-bundle": "3.3",
"paragonie/random_compat": "2.0.9",
"php-http/guzzle6-adapter": "^1.1",
"phpunit/phpunit": "^7.4",
"redjanym/fcm-bundle": "^1.1",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^5.0.0",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.6.4",
"symfony/symfony": "3.4.*",
"symfony/webpack-encore-bundle": "^1.0",
"twig/twig": "^1.0||^2.0"
},
"require-dev" : {
"sensio/generator-bundle" : "^3.0",
"symfony/phpunit-bridge" : "^3.0"
},

My API works on my local machine but got this issue on my test server. (Both with php 7.2.x)

Any idea ?

@goetas
Copy link
Collaborator

goetas commented Dec 21, 2018

the production PHP version and dev version should be the same. If is not so, your composer file might contain libraries that can not run on your production env (as in this case, jms/serialzer v2.0 requires at lease php 7.2 thats why works locally and not on production).

@PauchardThomas
Copy link
Author

You right ! when i did php -v : it was on 7.2 but with phpinfo(); was on 7.1

I updated php and works fine now 👍

Thank you.

@eilsongithub
Copy link

eilsongithub commented Mar 20, 2019

Dear Pauchard Thomas, how did you update ... the same thing happens to me ... in php-v I have 7.2 and in phpinfo () I have 7.1

in localhost

@PauchardThomas
Copy link
Author

@eilsongithub You might have multiple php instances. Look at this link

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

3 participants