KnpLabs / Gaufrette

PHP library that provides a filesystem abstraction layer − will be a feast for your files!

Home Page:http://knplabs.github.io/Gaufrette

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ContextErrorException when using PHP 7.3.0

manuelkiessling opened this issue · comments

Since switching to PHP 7.3.0, I'm getting the following error when using Gaufrette 0.6.0 and 0.7.0:

PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ContextErrorException: Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in vendor/knplabs/gaufrette/src/Gaufrette/Util/Path.php:30

Looks like changing https://github.com/KnpLabs/Gaufrette/blob/master/src/Gaufrette/Util/Path.php#L30 from continue to break might be enough to fix this.

I used update-alternatives --config to set the php version to 7.2 adn installed all php7.2-* packages and it got resolved.

Any chance this may get resolved besides downgrading to 7.2? I'm using Xampp so this will be a royal pain to move back to 7.2. :(

By the by changing continue to break didn't handle the problem.

Hello,
Which gaufrette version are you using ? This should be fixed since v0.8.0.

I'm not able to reproduce using PHP 7.3 on the current master:

$ PHP_VERSION=7.3 make clear-deps build install-deps
$ docker/run-task php7.3 vendor/bin/phpspec run spec/Gaufrette/Util/PathSpec.php

                                      100%                                       3
1 specs
3 examples (3 passed)
9ms

However, when replacing the continue 2; by continue; on line 30, the error comes back :

Gaufrette/Util/Path                                                   
   9  - it checks if path is absolute
      warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in
      /app/src/Gaufrette/Util/Path.php line 30

                      66%                                33%           3
1 specs
3 examples (2 passed, 1 broken)
9ms

Hi,
I am technically not using gaufrette. I have knplabs installed in my symfony3 app, and the error listed in this issue came up. What I did was upgrade php 7.0 to 7.3. By the by I am running this on Windows 10 using Xampp, which could be part of the problem as well.

I have symfony2 framework running no XAMPP-php5x when upgrade to XAMPP-php7x I have the same error:

"Fatal error: Uncaught Symfony\Component\Debug\Exception\ContextErrorException: Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\phantom\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php:2636 Stack trace: #0 C:\xampp\htdocs\phantom\vendor\composer\ClassLoader.php(444): Symfony\Component\Debug\ErrorHandler->handleError(2, '"continue" targ...', 'C:\\xampp\\htdocs...', 2636, Array) #1 C:\xampp\htdocs\phantom\vendor\composer\ClassLoader.php(444): include() #2 C:\xampp\htdocs\phantom\vendor\composer\ClassLoader.php(322): Composer\Autoload\includeFile('C:\\xampp\\htdocs...') #3 [internal function]: Composer\Autoload\ClassLoader->loadClass('Doctrine\\ORM\\Un...') #4 C:\xampp\htdocs\phantom\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php(160): spl_autoload_call('Doctrine\\ORM\\Un...') #5 C:\xampp\htdocs\phantom\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php(850): Doctrine\ORM\EntityManager->__construct(Object(Doctrine\DBAL\Connection), Object(Doctr in C:\xampp\htdocs\phantom\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php on line 2636"

Solution is:

Just read the error and change it as suggested by the error message. For example I changed return; to return 2; in 2 places of file UnitOfWork.php (this class is used in ORM of Doctrine). Issue resolved.

Dung.

Just read the error and change it as suggested by the error message. For example I changed return; to return 2; in 2 places of file UnitOfWork.php (this class is used in ORM of Doctrine). Issue resolved.

This one works for me.

Thanks
Maneesh Tiwari