From f722f2bb4857752d69f092e92af51e458b350b4f Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Fri, 12 Jan 2024 10:52:22 +1300 Subject: [PATCH] ENH Add generic types --- src/Extensions/ElementalAreaUsedOnTableExtension.php | 6 ++++-- src/Extensions/ElementalAreasExtension.php | 3 ++- src/Extensions/ElementalCMSMainExtension.php | 4 ++++ src/Extensions/ElementalContentControllerExtension.php | 5 ++++- src/Extensions/ElementalLeftAndMainExtension.php | 5 ++++- src/Extensions/ElementalPageExtension.php | 2 ++ .../GridFieldAddNewMultiClassHandlerExtension.php | 4 ++-- src/Extensions/GridFieldDetailFormItemRequestExtension.php | 4 ++++ src/Models/ElementalArea.php | 5 +++-- 9 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/Extensions/ElementalAreaUsedOnTableExtension.php b/src/Extensions/ElementalAreaUsedOnTableExtension.php index 93ed86c8..0fd8ff33 100644 --- a/src/Extensions/ElementalAreaUsedOnTableExtension.php +++ b/src/Extensions/ElementalAreaUsedOnTableExtension.php @@ -8,10 +8,13 @@ use SilverStripe\ORM\ValidationException; use DNADesign\Elemental\Models\ElementalArea; use DNADesign\Elemental\Models\BaseElement; +use SilverStripe\Admin\Forms\UsedOnTable; +/** + * @extends DataExtension + */ class ElementalAreaUsedOnTableExtension extends DataExtension { - /** * Hides ElementalArea's from the "Used On" tab when viewing files * @@ -56,7 +59,6 @@ public function updateUsageAncestorDataObjects(array &$ancestorDataObjects, Data try { // BaseElement::getPage() caches results so there's no performance decrease from // also calling it in updateUsageExcludeDataObject() - /** @var SiteTree $page */ if ($page = $dataObject->getPage()) { $ancestorDataObjects[] = $page; } diff --git a/src/Extensions/ElementalAreasExtension.php b/src/Extensions/ElementalAreasExtension.php index 19878e89..67c8d081 100644 --- a/src/Extensions/ElementalAreasExtension.php +++ b/src/Extensions/ElementalAreasExtension.php @@ -42,7 +42,8 @@ * 'ElementalArea2' * ); * - * @package elemental + * @template T of DataObject + * @extends DataExtension */ class ElementalAreasExtension extends DataExtension { diff --git a/src/Extensions/ElementalCMSMainExtension.php b/src/Extensions/ElementalCMSMainExtension.php index d03667e3..530b8135 100644 --- a/src/Extensions/ElementalCMSMainExtension.php +++ b/src/Extensions/ElementalCMSMainExtension.php @@ -2,10 +2,14 @@ namespace DNADesign\Elemental\Extensions; +use SilverStripe\CMS\Controllers\CMSMain; use SilverStripe\Core\Extension; use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\Form; +/** + * @extends Extension + */ class ElementalCMSMainExtension extends Extension { /** diff --git a/src/Extensions/ElementalContentControllerExtension.php b/src/Extensions/ElementalContentControllerExtension.php index cd642195..2d71b8e1 100644 --- a/src/Extensions/ElementalContentControllerExtension.php +++ b/src/Extensions/ElementalContentControllerExtension.php @@ -6,7 +6,11 @@ use SilverStripe\ORM\DataObject; use DNADesign\Elemental\Models\ElementalArea; use DNADesign\Elemental\Extensions\ElementalAreasExtension; +use SilverStripe\CMS\Controllers\ContentController; +/** + * @extends Extension + */ class ElementalContentControllerExtension extends Extension { /** @@ -25,7 +29,6 @@ public function handleElement() return false; } - /** @var DataObject $elementOwner */ $elementOwner = $this->owner->data(); if (!$elementOwner->hasExtension(ElementalAreasExtension::class)) { diff --git a/src/Extensions/ElementalLeftAndMainExtension.php b/src/Extensions/ElementalLeftAndMainExtension.php index bd1a4560..81d8ba0e 100644 --- a/src/Extensions/ElementalLeftAndMainExtension.php +++ b/src/Extensions/ElementalLeftAndMainExtension.php @@ -2,12 +2,15 @@ namespace DNADesign\Elemental\Extensions; +use SilverStripe\Admin\LeftAndMain; use SilverStripe\Core\Extension; use SilverStripe\View\Requirements; +/** + * @extends Extension + */ class ElementalLeftAndMainExtension extends Extension { - public function init() { Requirements::add_i18n_javascript('dnadesign/silverstripe-elemental:client/lang'); diff --git a/src/Extensions/ElementalPageExtension.php b/src/Extensions/ElementalPageExtension.php index 78f87780..e775f508 100644 --- a/src/Extensions/ElementalPageExtension.php +++ b/src/Extensions/ElementalPageExtension.php @@ -12,6 +12,8 @@ /** * @property int ElementalAreaID * @method ElementalArea ElementalArea() + * + * @extends ElementalAreasExtension */ class ElementalPageExtension extends ElementalAreasExtension { diff --git a/src/Extensions/GridFieldAddNewMultiClassHandlerExtension.php b/src/Extensions/GridFieldAddNewMultiClassHandlerExtension.php index 7276d97f..1da3c610 100644 --- a/src/Extensions/GridFieldAddNewMultiClassHandlerExtension.php +++ b/src/Extensions/GridFieldAddNewMultiClassHandlerExtension.php @@ -5,10 +5,10 @@ use SilverStripe\Core\Extension; use SilverStripe\Forms\Form; use DNADesign\Elemental\Models\BaseElement; +use Symbiote\GridFieldExtensions\GridFieldAddNewMultiClassHandler; /** - * Class GridFieldAddNewMultiClassHandlerExtension - * @package DNADesign\Elemental\Extensions + * @extends Extension */ class GridFieldAddNewMultiClassHandlerExtension extends Extension { diff --git a/src/Extensions/GridFieldDetailFormItemRequestExtension.php b/src/Extensions/GridFieldDetailFormItemRequestExtension.php index 45b2ea85..2e562f63 100644 --- a/src/Extensions/GridFieldDetailFormItemRequestExtension.php +++ b/src/Extensions/GridFieldDetailFormItemRequestExtension.php @@ -4,8 +4,12 @@ use DNADesign\Elemental\Models\BaseElement; use SilverStripe\Core\Extension; +use SilverStripe\Forms\GridField\GridFieldDetailForm_ItemRequest; use SilverStripe\ORM\FieldType\DBField; +/** + * @extends Extension + */ class GridFieldDetailFormItemRequestExtension extends Extension { public function updateBreadcrumbs($crumbs) diff --git a/src/Models/ElementalArea.php b/src/Models/ElementalArea.php index 48626001..f0642a33 100644 --- a/src/Models/ElementalArea.php +++ b/src/Models/ElementalArea.php @@ -2,6 +2,7 @@ namespace DNADesign\Elemental\Models; +use DNADesign\Elemental\Controllers\ElementController; use DNADesign\Elemental\Extensions\ElementalAreasExtension; use DNADesign\Elemental\TopPage\DataExtension; use SilverStripe\Core\ClassInfo; @@ -124,7 +125,7 @@ public function setOwnerPageCached(DataObject $page) /** * A cache-aware accessor for the elements - * @return ArrayList|HasManyList|BaseElement[] + * @return HasManyList */ public function Elements() { @@ -160,7 +161,7 @@ public function Breadcrumbs() * its' controller, making it easier to access and process form logic and * actions stored in {@link ElementController}. * - * @return ArrayList + * @return ArrayList * @throws \Exception */ public function ElementControllers()