-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add checks for class properties (#77)
* Tests: wrap anonymous class fixtures in methods Previously they were creating an anonymous class in the global namespace outside a function, but this is an unrealistic usage and probably is being effected by #37. This modifies the fixtures to put the class as a return value of a class method. * Tests: cover private/protected class properties * Add check for class property definition * Tests: add 'private static' to anon class fixture * Tests: Add naked static, var to class properties * Treat `var` declarations as properties * Tests: add static function var to anon fixture * Allow bare static property declaration
- Loading branch information
1 parent
4f36541
commit 22ab15e
Showing
5 changed files
with
72 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 11 additions & 7 deletions
18
VariableAnalysis/Tests/CodeAnalysis/fixtures/AnonymousClassFixture.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
<?php | ||
|
||
new class { | ||
public function sayHelloWorld() { | ||
echo 'Hello'.$this->getWorld(); | ||
} | ||
class ClassWithAnonymousClass { | ||
public function getMyClass() { | ||
return new class { | ||
public function sayHelloWorld() { | ||
echo 'Hello'.$this->getWorld(); | ||
} | ||
|
||
protected function getWorld() { | ||
return ' World!'; | ||
protected function getWorld() { | ||
return ' World!'; | ||
} | ||
}; | ||
} | ||
}; | ||
} |
25 changes: 18 additions & 7 deletions
25
VariableAnalysis/Tests/CodeAnalysis/fixtures/AnonymousClassWithPropertiesFixture.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
<?php | ||
|
||
new class { | ||
protected $storedHello; | ||
public $helloOptions = []; | ||
public function sayHelloWorld() { | ||
echo "hello world"; | ||
} | ||
}; | ||
class ClassWithAnonymousClass { | ||
public function getAnonymousClass() { | ||
return new class { | ||
protected $storedHello; | ||
private static $storedHello2; | ||
private $storedHello3; | ||
public $helloOptions = []; | ||
static $aStaticOne; | ||
var $aVarOne; | ||
public function sayHelloWorld() { | ||
echo "hello world"; | ||
} | ||
|
||
public function methodWithStaticVar() { | ||
static $myStaticVar; // should trigger unused warning | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters