suncat2000 / MobileDetectBundle

Symfony 2/3/4 bundle for detect mobile devices, manage mobile view and redirect to the mobile and tablet version.
397 stars 153 forks source link

Issue when building an old project with PHP 7 #120

Closed kinow closed 6 years ago

kinow commented 6 years ago

Hello,

Today I had to build a relatively old project at work, that was using this bundle's version 0.9.* in composer.json. I am building the app on Ubuntu LTS, PHP 7. I got the following error in my build.

> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
PHP Fatal error:  Cannot use Doctrine\Tests\Common\Annotations\True as True because 'True' is a special class name in /home/kinow/Development/php/workspace/niwaweather/vendor/suncat/mobile-detect-bundle/SunCat/MobileDetectBundle/EventListener/RequestListener.php on line 22
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception

  [RuntimeException]                                                                                                                                                                                              
  An error occurred when executing the "'cache:clear --no-warmup'" command:                                                                                                                                       
  PHP Fatal error:  Cannot use Doctrine\Tests\Common\Annotations\True as True because 'True' is a special class name in /home/kinow/Development/php/workspace/niwaweather/vendor/suncat/mobile-detect-bundle/Sun  
  Cat/MobileDetectBundle/EventListener/RequestListener.php on line 22

Not really writing much PHP nowadays, nor keeping up to date with latest changes. But hacking the RequestListener.php file, I could successfully build & run the app by removing the True import, and removing the only place it was used, a documentation line with a return True.

Is it something that can be fixed in the bundle? We are still building against PHP 5.x, but planning to update our CI & environments to PHP 7.

Thanks Bruno

xabbuh commented 6 years ago

This code cannot be found in the current version of the bundle anymore. So I guess that updating (some of) your dependencies will pull in versions that are compatible with PHP 7 (it looks like doctrine/annotations may be another package you need to update).

kinow commented 6 years ago

Oh, true indeed. Checked RequestListener.php and couldn't find that import any more. Closing it. Thanks @xabbuh !