question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Case which is not consistent with Zend PHP parser

See original GitHub issue
f(&$a = 1);

It should throw a parse error:

Parse error: syntax error, unexpected '&'

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alexander-akaitcommented, Aug 15, 2019

I mean we should handle all cases except syntax error, for example:

php -r "[&\$a] = [1];"
PHP Fatal error:  [] and list() assignments cannot be by reference in Command line code on line 1
php -r "\$a = &time();"
PHP Notice:  Only variables should be assigned by reference in Command line code on line 1

should be parsed

1reaction
ichiriaccommented, Aug 15, 2019

Hi @eou

In php 7 - some by reference usage becomes deprecated - Some examples :

php -r "[&\$a] = [1];"
PHP Fatal error:  [] and list() assignments cannot be by reference in Command line code on line 1

php -r "&\$a = \$foo;"
PHP Parse error:  syntax error, unexpected '&', expecting end of file in Command line code on line 1

php -r "\$a = &time();"
PHP Notice:  Only variables should be assigned by reference in Command line code on line 1

php -r "\$a = &new Date();"
PHP Parse error:  syntax error, unexpected 'new' (T_NEW) in Command line code on line 1

php -r "print(&\$a);"
PHP Parse error:  syntax error, unexpected '&' in Command line code on line 1

php -r "print(\$a = &\$b);"
=> PASS

php -r "\$a = &\$b;"
=> PASS
Read more comments on GitHub >

github_iconTop Results From Across the Web

PHP parser errors in Zend Framework - Stack Overflow
I just updated my project library folder (with an external to ZF svn) to ZF version 1.11. I'm now getting al kinds of...
Read more >
Writing PHP Extensions - Zend Technologies
Knowing how to use and write PHP extensions is a critical PHP development skill that can save significant time and enable you to...
Read more >
include - Manual - PHP
Files are included based on the file path given or, if none is given, the include_path specified. If the file isn't found in...
Read more >
PHP - Wikipedia
PHP is a general-purpose scripting language geared toward web development. ... The standard PHP interpreter, powered by the Zend Engine, is free software ......
Read more >
Zend Framework Coding Standard for PHP
This document provides guidelines for code formatting and documentation to individuals and teams contributing to Zend Framework. Many developers using Zend ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found