-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix overriding trait properties in PHPDocs
- Loading branch information
1 parent
37c29d5
commit 55a3444
Showing
6 changed files
with
132 additions
and
2 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
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Bug1216; | ||
|
||
use function PHPStan\Analyser\assertType; | ||
|
||
abstract class Foo | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
protected $foo; | ||
} | ||
|
||
trait Bar | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
protected $bar; | ||
|
||
protected $untypedBar; | ||
} | ||
|
||
/** | ||
* @property string $foo | ||
* @property string $bar | ||
* @property string $untypedBar | ||
*/ | ||
class Baz extends Foo | ||
{ | ||
|
||
public function __construct() | ||
{ | ||
assertType('string', $this->foo); | ||
assertType('string', $this->bar); | ||
assertType('string', $this->untypedBar); | ||
} | ||
|
||
} | ||
|
||
function (Baz $baz): void { | ||
assertType('string', $baz->foo); | ||
assertType('string', $baz->bar); | ||
assertType('string', $baz->untypedBar); | ||
}; |
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
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace Bug1216PropertyTest; | ||
|
||
abstract class Foo | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
protected $foo; | ||
} | ||
|
||
trait Bar | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
protected $bar; | ||
|
||
protected $untypedBar; | ||
} | ||
|
||
/** | ||
* @property string $foo | ||
* @property string $bar | ||
* @property string $untypedBar | ||
*/ | ||
class Baz extends Foo | ||
{ | ||
|
||
public function __construct() | ||
{ | ||
$this->foo = 'foo'; // OK | ||
$this->bar = 'bar'; // OK | ||
$this->untypedBar = 123; // error | ||
} | ||
|
||
} | ||
|
||
trait DecoratorTrait | ||
{ | ||
|
||
/** @var \stdClass */ | ||
public $foo; | ||
|
||
} | ||
|
||
/** | ||
* @property \Exception $foo | ||
*/ | ||
class Dummy | ||
{ | ||
|
||
use DecoratorTrait; | ||
|
||
} | ||
|
||
function (Dummy $dummy): void { | ||
$dummy->foo = new \stdClass(); | ||
}; | ||
|
||
function (Dummy $dummy): void { | ||
$dummy->foo = new \Exception(); | ||
}; |