Bug 276603 - $this in foreach value is parse error.
Summary: $this in foreach value is parse error.
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: PHP (show other bugs)
Version: git master
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: 4.2.0
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-27 11:43 UTC by jay
Modified: 2011-07-25 20:05 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jay 2011-06-27 11:43:49 UTC
Version:           git master (using KDE 4.6.2) 
OS:                Linux

foreach( $a as $this->_b ){}

Expected token ")" after $this.


Reproducible: Always

Steps to Reproduce:
<?php
$a = Array( 1, 2);
foreach( $a as $this->_b ){}
?>


Expected Results:  
No error :)
Comment 1 Niko Sams 2011-06-27 14:04:06 UTC
*that* is valid php code?
Doesn't make any sense!

...but if php supports it, we have too of course :/
Comment 2 jay 2011-06-27 14:12:41 UTC
it is a valid code.
It's just unusual.

It's used, for example when you use the value in som internal method, and you dont have a input parameter in it.
Or if you wan't to keep the last value for postprocessing.

Smarty uses it a lot in compiled code.
Comment 3 Milian Wolff 2011-07-25 20:05:42 UTC
Git commit 5bc3469d16a7185d8040193e7ce89bde25cbde26 by Milian Wolff.
Committed on 25/07/2011 at 22:04.
Pushed by mwolff into branch 'master'.

follow php syntax by allow more constructs in foreach statements

BUG: 276603

M  +10   -5    duchain/builders/usebuilder.cpp
M  +28   -0    duchain/tests/duchain.cpp
M  +15   -15   duchain/builders/declarationbuilder.cpp
M  +1    -0    duchain/tests/duchain.h
M  +2    -2    parser/php.g

http://commits.kde.org/kdev-php/5bc3469d16a7185d8040193e7ce89bde25cbde26