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

PHP 7.2 - deprecated "each" calls #128

Closed
remicollet opened this issue Aug 6, 2017 · 10 comments
Closed

PHP 7.2 - deprecated "each" calls #128

remicollet opened this issue Aug 6, 2017 · 10 comments

Comments

@remicollet
Copy link

remicollet commented Aug 6, 2017

  • bug report? yes
  • feature request? no
  • version: 2.4.2

Running security test suite

-- FAILED: SecurityExtension | tests/Security.DI/SecurityExtension.user.phpt
   Exited with error code 255 (expected 0)
   E_DEPRECATED: The each() function is deprecated. This message will be suppressed on further calls
@remicollet
Copy link
Author

Same issue with Forms test suite

-- FAILED: Nette\Forms HTTP data. | tests/Forms/Forms.submittedBy.phpt
   Exited with error code 255 (expected 0)
   E_DEPRECATED: The each() function is deprecated. This message will be suppressed on further calls

@dg
Copy link
Member

dg commented Aug 6, 2017

Is there file name and line where error is occured?

@remicollet
Copy link
Author

Full output

-- FAILED: /dev/shm/BUILD/security-8a3051f9b16d4d7bfa18b6b0ff6f9f6f418f9801/tests/Security.DI/SecurityExtension.user.phpt
   Exited with error code 255 (expected 0)
   E_DEPRECATED: The each() function is deprecated. This message will be suppressed on further calls
   
   in Nette/Http/RequestFactory.php(114) 
   in Nette/Http/RequestFactory.php(114) each()
   in tests/Security.DI/SecurityExtension.user.phpt(22) : eval()'d code(63) Nette\Http\RequestFactory->createHttpRequest()
   in Nette/DI/Container.php(178) Container->createServiceFoo__request()
   in Nette/DI/Container.php(104) Nette\DI\Container->createService()
   in tests/Security.DI/SecurityExtension.user.phpt(22) : eval()'d code(42) Nette\DI\Container->getService()
   in Nette/DI/Container.php(178) Container->createServiceBar__session()
   in Nette/DI/Container.php(104) Nette\DI\Container->createService()
   in tests/Security.DI/SecurityExtension.user.phpt(22) : eval()'d code(92) Nette\DI\Container->getService()
   in Nette/DI/Container.php(178) Container->createServiceSecurity__userStorage()
   in Nette/DI/Container.php(104) Nette\DI\Container->createService()
   in tests/Security.DI/SecurityExtension.user.phpt(25) Nette\DI\Container->getService()

@remicollet
Copy link
Author

AFAICS, each is only used in Nette/Http/RequestFactory.php (grep in all the framework)

@dg
Copy link
Member

dg commented Aug 6, 2017

There should be @ operator to silent notice.

@xificurk
Copy link

xificurk commented Aug 6, 2017

@dg There is, but only in 2.4-dev, there is no stable version with this fix yet.

@remicollet
Copy link
Author

silent operator = the rope to hang yourself.

-			while (list($key, $val) = each($list)) {
+			foreach ($list as $key => $val) {

@JanTvrdik
Copy link
Contributor

@remicollet See commit message of 4667ae0

foreach ($arr as &$el) fails in PHP 5.6 with single-item array

@dg
Copy link
Member

dg commented Aug 6, 2017

How it is possible that tests do not pass when there is a silent operator?

If you use your own error handler, you need to modify it as follows https://github.com/nette/code-checker/blob/master/src/bootstrap.php#L24-L26

@dg
Copy link
Member

dg commented Aug 8, 2017

fixed 4667ae0

@dg dg closed this as completed Aug 8, 2017
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

4 participants