From ca972ff5f2fa1d059a542b0afb3921ae285b9ef1 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Fri, 19 Jan 2024 10:29:08 +1300 Subject: [PATCH] ENH Add generic types (#1261) --- code/Control/UserDefinedFormAdmin.php | 4 ---- code/Control/UserDefinedFormController.php | 3 +-- code/Extension/UpgradePolymorphicExtension.php | 2 ++ code/Extension/UserFormFieldEditorExtension.php | 7 ++++--- code/Extension/UserFormFileExtension.php | 4 ++-- code/Extensions/UsedOnTableExtension.php | 5 +++-- code/FormField/UserFormsCheckboxSetField.php | 2 -- code/FormField/UserFormsCompositeField.php | 1 - code/Model/EditableCustomRule.php | 1 - code/Model/EditableFormField.php | 2 -- .../EditableFormField/EditableMultipleOptionField.php | 1 - code/Model/Recipient/EmailRecipient.php | 9 ++++----- code/Model/Recipient/UserFormRecipientItemRequest.php | 2 +- code/Task/RecoverUploadLocationsHelper.php | 2 +- code/Task/UserFormsColumnCleanTask.php | 1 - code/UserForm.php | 2 +- 16 files changed, 19 insertions(+), 29 deletions(-) diff --git a/code/Control/UserDefinedFormAdmin.php b/code/Control/UserDefinedFormAdmin.php index 91aee8f52..7cc75c246 100644 --- a/code/Control/UserDefinedFormAdmin.php +++ b/code/Control/UserDefinedFormAdmin.php @@ -60,7 +60,6 @@ class UserDefinedFormAdmin extends LeftAndMain */ private static function getRestrictedAccessField(string $folder, string $title) { - /** @var TextField $textField */ $textField = TextField::create('CreateFolder', ''); /** @var Folder $formSubmissionsFolder */ @@ -121,7 +120,6 @@ public function confirmfolderformschema(HTTPRequest $request) if ($editableFormField instanceof EditableFileField) { $folderId = $editableFormField->FolderID; } - /** @var Folder $folder */ $folder = Folder::get()->byID($folderId); if (!$folder) { $folder = $this->getFormSubmissionFolder(); @@ -222,7 +220,6 @@ public function confirmfolder(array $data, Form $form, HTTPRequest $request) if (!$id) { throw new HTTPResponse_Exception(_t(__CLASS__.'.INVALID_REQUEST', 'This request was invalid.'), 400); } - /** @var EditableFileField $editableFileField */ $editableFormField = EditableFormField::get()->byID($id); if (!$editableFormField) { $editableFormField = Versioned::get_by_stage(EditableFormField::class, Versioned::DRAFT)->byID($id); @@ -276,7 +273,6 @@ public function getfoldergrouppermissions() { $folderID = $this->getRequest()->requestVar('FolderID'); if ($folderID) { - /** @var Folder $folder */ $folder = Folder::get()->byID($folderID); if (!$folder) { throw new HTTPResponse_Exception(_t(__CLASS__.'.INVALID_REQUEST', 'This request was invalid.'), 400); diff --git a/code/Control/UserDefinedFormController.php b/code/Control/UserDefinedFormController.php index 201cc1884..383769054 100644 --- a/code/Control/UserDefinedFormController.php +++ b/code/Control/UserDefinedFormController.php @@ -38,7 +38,7 @@ /** * Controller for the {@link UserDefinedForm} page type. * - * @package userforms + * @extends PageController */ class UserDefinedFormController extends PageController { @@ -200,7 +200,6 @@ public function generateConditionalJavascript() $watch = []; if ($formFields) { - /** @var EditableFormField $field */ foreach ($formFields as $field) { if ($result = $field->formatDisplayRules()) { $watch[] = $result; diff --git a/code/Extension/UpgradePolymorphicExtension.php b/code/Extension/UpgradePolymorphicExtension.php index e40bd9a1b..222123447 100644 --- a/code/Extension/UpgradePolymorphicExtension.php +++ b/code/Extension/UpgradePolymorphicExtension.php @@ -23,6 +23,8 @@ * certain amount of manual checking is required to ensure that upgrades are performed smoothly. * * @internal This API is likely to be removed in later major versions of silverstripe/userforms + * + * @extends DataExtension */ class UpgradePolymorphicExtension extends DataExtension { diff --git a/code/Extension/UserFormFieldEditorExtension.php b/code/Extension/UserFormFieldEditorExtension.php index a1ede8358..62b37e160 100644 --- a/code/Extension/UserFormFieldEditorExtension.php +++ b/code/Extension/UserFormFieldEditorExtension.php @@ -15,6 +15,7 @@ use SilverStripe\Forms\GridField\GridFieldToolbarHeader; use SilverStripe\ORM\DataExtension; use SilverStripe\ORM\DataList; +use SilverStripe\ORM\DataObject; use SilverStripe\UserForms\Form\GridFieldAddClassesButton; use SilverStripe\UserForms\Model\EditableFormField; use SilverStripe\UserForms\Model\EditableFormField\EditableFieldGroup; @@ -228,11 +229,11 @@ public function onAfterUnpublish() /** * When duplicating a UserDefinedForm, duplicate all of its fields and display rules * - * @see \SilverStripe\ORM\DataObject::duplicate - * @param \SilverStripe\ORM\DataObject $oldPage + * @see DataObject::duplicate + * @param DataObject $oldPage * @param bool $doWrite * @param string $manyMany - * @return \SilverStripe\ORM\DataObject + * @return DataObject */ public function onAfterDuplicate($oldPage, $doWrite, $manyMany) { diff --git a/code/Extension/UserFormFileExtension.php b/code/Extension/UserFormFileExtension.php index 3e00d658c..82f5a60ab 100644 --- a/code/Extension/UserFormFileExtension.php +++ b/code/Extension/UserFormFileExtension.php @@ -10,11 +10,12 @@ use SilverStripe\ORM\Queries\SQLUpdate; use SilverStripe\UserForms\Control\UserDefinedFormController; use SilverStripe\UserForms\Model\Submission\SubmittedFileField; -use SilverStripe\Versioned\Versioned; /** * @property string $UserFormUpload * @method SubmittedFileField SubmittedFileField() + * + * @extends DataExtension */ class UserFormFileExtension extends DataExtension { @@ -45,7 +46,6 @@ class UserFormFileExtension extends DataExtension */ public function updateTrackedFormUpload(&$value): void { - /** @var File|Versioned|UserFormFileExtension $file */ $file = $this->owner; if ($file->UserFormUpload != self::USER_FORM_UPLOAD_UNKNOWN) { $value = $file->UserFormUpload == self::USER_FORM_UPLOAD_TRUE; diff --git a/code/Extensions/UsedOnTableExtension.php b/code/Extensions/UsedOnTableExtension.php index 734fe7486..e9c084f71 100644 --- a/code/Extensions/UsedOnTableExtension.php +++ b/code/Extensions/UsedOnTableExtension.php @@ -2,6 +2,7 @@ namespace SilverStripe\UserForms\Extensions; +use SilverStripe\Admin\Forms\UsedOnTable; use SilverStripe\Core\Extension; use SilverStripe\ORM\DataObject; use SilverStripe\UserForms\Model\EditableFormField; @@ -11,10 +12,11 @@ /** * Update DataObjects on the file "Used On" table + * + * @extends Extension */ class UsedOnTableExtension extends Extension { - /** * Link submitted file fields to their parent page * @@ -26,7 +28,6 @@ public function updateUsageDataObject(?DataObject &$dataObject) if (!($dataObject instanceof SubmittedFileField)) { return; } - /** @var SubmittedForm $submittedForm */ $submittedForm = $dataObject->Parent(); if (!$submittedForm) { $dataObject = null; diff --git a/code/FormField/UserFormsCheckboxSetField.php b/code/FormField/UserFormsCheckboxSetField.php index 7d9092f2d..8242d4c6a 100644 --- a/code/FormField/UserFormsCheckboxSetField.php +++ b/code/FormField/UserFormsCheckboxSetField.php @@ -33,8 +33,6 @@ public function getValidationAttributesHTML() /** * jQuery validate requires that the value of the option does not contain * the actual value of the input. - * - * @return ArrayList */ public function getOptions() { diff --git a/code/FormField/UserFormsCompositeField.php b/code/FormField/UserFormsCompositeField.php index c1bf8ac29..7a8cd6c2f 100644 --- a/code/FormField/UserFormsCompositeField.php +++ b/code/FormField/UserFormsCompositeField.php @@ -40,7 +40,6 @@ public function processNext(EditableFormField $field) if (get_class($field) === EditableFormField::class || !$field->getFormField()) { return $this; } - /** @var EditableFormField $formField */ $formField = $field->getFormField(); // Save this field diff --git a/code/Model/EditableCustomRule.php b/code/Model/EditableCustomRule.php index 66afe78b5..08fa1b407 100644 --- a/code/Model/EditableCustomRule.php +++ b/code/Model/EditableCustomRule.php @@ -152,7 +152,6 @@ public function canUnpublish($member = null) */ public function buildExpression() { - /** @var EditableFormField $formFieldWatch */ $formFieldWatch = $this->ConditionField(); //Encapsulated the action to the object $action = $formFieldWatch->getJsEventHandler(); diff --git a/code/Model/EditableFormField.php b/code/Model/EditableFormField.php index 9f0799a8a..08d2dd21f 100755 --- a/code/Model/EditableFormField.php +++ b/code/Model/EditableFormField.php @@ -950,10 +950,8 @@ public function formatDisplayRules() ]; // Check for field dependencies / default - /** @var EditableCustomRule $rule */ foreach ($this->DisplayRules() as $rule) { // Get the field which is effected - /** @var EditableFormField $formFieldWatch */ $formFieldWatch = DataObject::get_by_id(EditableFormField::class, $rule->ConditionFieldID); // Skip deleted fields if (!$formFieldWatch) { diff --git a/code/Model/EditableFormField/EditableMultipleOptionField.php b/code/Model/EditableFormField/EditableMultipleOptionField.php index ab284820e..feb2a9810 100644 --- a/code/Model/EditableFormField/EditableMultipleOptionField.php +++ b/code/Model/EditableFormField/EditableMultipleOptionField.php @@ -122,7 +122,6 @@ public function duplicate(bool $doWrite = true, array|null $relations = null): s $clonedNode = parent::duplicate(true); foreach ($this->Options() as $field) { - /** @var EditableOption $newField */ $newField = $field->duplicate(false); $newField->ParentID = $clonedNode->ID; $newField->Version = 0; diff --git a/code/Model/Recipient/EmailRecipient.php b/code/Model/Recipient/EmailRecipient.php index dbf39f5f3..0923a076e 100644 --- a/code/Model/Recipient/EmailRecipient.php +++ b/code/Model/Recipient/EmailRecipient.php @@ -464,7 +464,6 @@ public function canSend($data, $form) // Check all rules $isAnd = $this->CustomRulesCondition === 'And'; foreach ($customRules as $customRule) { - /** @var EmailRecipientCondition $customRule */ $matches = $customRule->matches($data); if ($isAnd && !$matches) { return false; @@ -715,7 +714,7 @@ protected function getEmailReplyToCMSFields() } /** - * @return DataList|null + * @return DataList|null */ protected function getMultiOptionFields() { @@ -726,7 +725,7 @@ protected function getMultiOptionFields() } /** - * @return ArrayList|null + * @return ArrayList|null */ protected function getValidSubjectFields() { @@ -745,7 +744,7 @@ protected function getValidSubjectFields() } /** - * @return DataList|null + * @return DataList|null */ protected function getValidEmailFromFields() { @@ -758,7 +757,7 @@ protected function getValidEmailFromFields() } /** - * @return ArrayList|DataList|null + * @return ArrayList|DataList|null */ protected function getValidEmailToFields() { diff --git a/code/Model/Recipient/UserFormRecipientItemRequest.php b/code/Model/Recipient/UserFormRecipientItemRequest.php index bdfe544a5..38fe2b5ac 100644 --- a/code/Model/Recipient/UserFormRecipientItemRequest.php +++ b/code/Model/Recipient/UserFormRecipientItemRequest.php @@ -48,7 +48,7 @@ public function preview() /** * Get some placeholder field values to display in the preview * - * @return ArrayList + * @return ArrayList */ protected function getPreviewFieldData() { diff --git a/code/Task/RecoverUploadLocationsHelper.php b/code/Task/RecoverUploadLocationsHelper.php index 1961c830c..75764f819 100644 --- a/code/Task/RecoverUploadLocationsHelper.php +++ b/code/Task/RecoverUploadLocationsHelper.php @@ -560,7 +560,7 @@ private function getQuery() * Returns DataList object containing every * uploaded file record * - * @return DataList + * @return DataList */ private function getCountQuery() { diff --git a/code/Task/UserFormsColumnCleanTask.php b/code/Task/UserFormsColumnCleanTask.php index b20731410..e62a086ba 100644 --- a/code/Task/UserFormsColumnCleanTask.php +++ b/code/Task/UserFormsColumnCleanTask.php @@ -30,7 +30,6 @@ class UserFormsColumnCleanTask extends MigrationTask */ public function run($request) { - /** @var \SilverStripe\ORM\DataObjectSchema $schema */ $schema = DataObject::getSchema(); foreach ($this->tables as $db) { diff --git a/code/UserForm.php b/code/UserForm.php index e29414dab..2fcffc704 100644 --- a/code/UserForm.php +++ b/code/UserForm.php @@ -350,7 +350,7 @@ public function getSubmissionsGridField() * Converts the RelationList to an ArrayList so that manipulation * of the original source data isn't possible. * - * @return ArrayList + * @return ArrayList */ public function FilteredEmailRecipients($data = null, $form = null) {