MNT Update generic inheritance for DataExtension
- 'static' type should only be used on the bottom level, otherwise it can give a weird type 'DataExtension<DataObject|Hierachy>|DataObject|Hierachy' for example - phpstan doesn't like intersection types (&) during testing, will possibly need the open source silverstripe-phpstan to complete the types as they currently resolve to 'never'
This commit is contained in:
parent
1c01e52415
commit
4573923bf9
|
@ -14,7 +14,7 @@ use Exception;
|
|||
* An extension that adds additional functionality to a {@link DataObject}.
|
||||
*
|
||||
* @template T of DataObject
|
||||
* @extends Extension<T|static>
|
||||
* @extends Extension<T>
|
||||
*/
|
||||
abstract class DataExtension extends Extension
|
||||
{
|
||||
|
|
|
@ -23,8 +23,8 @@ use SilverStripe\View\ViewableData;
|
|||
* obvious example of this is SiteTree.
|
||||
*
|
||||
* @property int $ParentID
|
||||
* @property DataObject|Hierarchy $owner
|
||||
* @method DataObject Parent()
|
||||
* @extends DataExtension<DataObject|static>
|
||||
*/
|
||||
class Hierarchy extends DataExtension
|
||||
{
|
||||
|
@ -119,8 +119,7 @@ class Hierarchy extends DataExtension
|
|||
public function validate(ValidationResult $validationResult)
|
||||
{
|
||||
// The object is new, won't be looping.
|
||||
/** @var DataObject|Hierarchy $owner */
|
||||
$owner = $this->owner;
|
||||
$owner = $this->getOwner();
|
||||
if (!$owner->ID) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
namespace SilverStripe\Type\Tests\Source;
|
||||
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
|
||||
/**
|
||||
* @extends Extension<ExtensibleMockOne|ExtensibleMockTwo|static>
|
||||
* @extends DataExtension<ExtensibleMockOne|ExtensibleMockTwo|static>
|
||||
*/
|
||||
class ExtensionMockTwo extends Extension implements TestOnly
|
||||
class ExtensionMockTwo extends DataExtension implements TestOnly
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue