| Summary: |
Parsing error when assing using array syntax to $this 'Cannot re-assign $this' |
| Product: |
[Applications] kdevelop
|
Reporter: |
Andrew Udvare <audvare> |
| Component: |
Language Support: PHP | Assignee: |
kdevelop-bugs-null |
| Status: |
RESOLVED
FIXED
|
|
|
| Severity: |
normal
|
CC: |
alexander, jan.pavlicek
|
| Priority: |
NOR
|
|
|
| Version First Reported In: |
git master | |
|
| Target Milestone: |
--- | |
|
| Platform: |
Compiled Sources | |
|
| OS: |
All | |
|
| URL: |
http://i.imgur.com/1u9a7By.png
|
|
Latest Commit:
|
https://cgit.kde.org/kdev-php.git/commit/?id=dd90e850afdc541b6edbd16eec74eaad8a4b49ae
|
Version Fixed/Implemented In:
|
5.1.0
|
|
Sentry Crash Report:
|
|
| |
Laravel seems to use this valid syntax (PHP interpreter accepts it): $this['env'] = 'some value'; as opposed to using the -> because -> would resolve to a property on the class whereas [] notation will call the \ArrayAccess methods (offsetGet(), offsetSet(), etc). Reproducible: Always Steps to Reproduce: 1. Create a file in project with these contents and allow parser to run. <?php class Test implements \ArrayAccess { private $a = array(); // ArrayAccess methods function offsetExists($key) { return array_key_exists($key, $this->a); } function offsetGet($key) { return $this->a[$key]; } function offsetSet($key, $val) { $this->a[$key] = $val; } function offsetUnset($key) { unset($this->a[$key]); } /** * @return string */ function useThisWithArraySyntax() { $this['key'] = 'some value'; } } 2. Note that $this in the useThisWithArraySyntax() method is red underlined. Actual Results: $this is incorrectly underlined as invalid syntax: 'Cannot re-assign $this' Expected Results: $this with array (bracket) notation should be considered valid syntax. It does something other than what -> (or ::) does in PHP. Real file: https://github.com/laravel/framework/blob/5.0/src/Illuminate/Foundation/Application.php#L435