Bug 241750 - The PHP parser incorrectly says that it cannot redeclare member variables
Summary: The PHP parser incorrectly says that it cannot redeclare member variables
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: PHP (show other bugs)
Version: git master
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-14 17:22 UTC by Alexander
Modified: 2018-08-17 15:09 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 5.3.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander 2010-06-14 17:22:27 UTC
Version:           SVN (using KDE 4.4.3) 
OS:                Linux

This happens with KDevelop+related stuff (git master as of 2010-06-14).

Note: You have to _type_ this. Simply pasting this code doesn't always show the problem.

To reproduce, type the following:
class A {
};

Now type this inside the curly braces:

	function f() 
	{
		$this->mem = 0;
	}

	var $mem;

At this point KDevelop says "Cannot redeclare int mem (about the "var $mem; line"), already declared in ... (the $this->mem = 0; line)".
$mem in "var $mem" has an error squiggle, and "$this->mem" is highlighted as a definition.

If you paste the whole chunk, then "var $mem" is read as definition and the error is gone.

Reproducible: Always


Actual Results:  
The newly-typed "var $mem;" should be regarded as a definition, not the earlier "$this->mem = 0".


openSUSE 11.1 x86_64, gcc 4.3.2. KDE installed from OBS,
KDevelop/kdevplatform/plugins compiled manually.
Comment 1 Milian Wolff 2010-06-14 19:48:58 UTC
fixed in 1.0 branch, will merge into master laster, thanks.
Comment 2 Milian Wolff 2012-03-15 23:03:19 UTC
reopening, pasting something like this into a file triggers this issue:

<?php
class T { }
class B {
    function x() {
        $this->a = 1;
    }
    var $a = 1;
}
Comment 3 Heinz Wiesinger 2018-08-17 15:09:26 UTC
Git commit 42d3c0e577e2e4168a4e87d8ab9deceb8e692fd3 by Heinz Wiesinger.
Committed on 17/08/2018 at 15:08.
Pushed by wiesinger into branch '5.3'.

Improved type detection for object properties.

Summary:
This should solve long standing bugs that make kdev-php difficult
to use with common PHP frameworks.

* Properly resolve namespaced identifiers for type information in the phpdoc block
* Default type for class properties without assigned value is now NULL instead of 'mixed'
  (if no other type is specified in the phpdoc block)
* The NULL type is replaced on first assignment to the property.
Related: bug 295866
FIXED-IN: 5.3.0

Reviewers: brauch

Reviewed By: brauch

Subscribers: brauch, kdevelop-devel

Tags: #kdevelop

Differential Revision: https://phabricator.kde.org/D14876

M  +92   -26   duchain/builders/declarationbuilder.cpp
M  +14   -3    duchain/builders/typebuilder.cpp
M  +10   -2    duchain/expressionvisitor.cpp
M  +97   -11   duchain/tests/duchain.cpp
M  +2    -0    duchain/tests/duchain.h
M  +16   -0    duchain/tests/uses.cpp
M  +1    -0    duchain/tests/uses.h

https://commits.kde.org/kdev-php/42d3c0e577e2e4168a4e87d8ab9deceb8e692fd3