Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Add generic types #1261

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions code/Control/UserDefinedFormAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions code/Control/UserDefinedFormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
/**
* Controller for the {@link UserDefinedForm} page type.
*
* @package userforms
* @extends PageController<UserDefinedForm>
*/
class UserDefinedFormController extends PageController
{
Expand Down Expand Up @@ -200,7 +200,6 @@ public function generateConditionalJavascript()
$watch = [];

if ($formFields) {
/** @var EditableFormField $field */
foreach ($formFields as $field) {
if ($result = $field->formatDisplayRules()) {
$watch[] = $result;
Expand Down
2 changes: 2 additions & 0 deletions code/Extension/UpgradePolymorphicExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<UserDefinedForm>
*/
class UpgradePolymorphicExtension extends DataExtension
{
Expand Down
7 changes: 4 additions & 3 deletions code/Extension/UserFormFieldEditorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions code/Extension/UserFormFileExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<File&static>
*/
class UserFormFileExtension extends DataExtension
{
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions code/Extensions/UsedOnTableExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -11,10 +12,11 @@

/**
* Update DataObjects on the file "Used On" table
*
* @extends Extension<UsedOnTable>
*/
class UsedOnTableExtension extends Extension
{

/**
* Link submitted file fields to their parent page
*
Expand All @@ -26,7 +28,6 @@ public function updateUsageDataObject(?DataObject &$dataObject)
if (!($dataObject instanceof SubmittedFileField)) {
return;
}
/** @var SubmittedForm $submittedForm */
$submittedForm = $dataObject->Parent();
if (!$submittedForm) {
$dataObject = null;
Expand Down
2 changes: 0 additions & 2 deletions code/FormField/UserFormsCheckboxSetField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
1 change: 0 additions & 1 deletion code/FormField/UserFormsCompositeField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion code/Model/EditableCustomRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions code/Model/EditableFormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 4 additions & 5 deletions code/Model/Recipient/EmailRecipient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -715,7 +714,7 @@ protected function getEmailReplyToCMSFields()
}

/**
* @return DataList|null
* @return DataList<EditableMultipleOptionField>|null
*/
protected function getMultiOptionFields()
{
Expand All @@ -726,7 +725,7 @@ protected function getMultiOptionFields()
}

/**
* @return ArrayList|null
* @return ArrayList<EditableFormField>|null
*/
protected function getValidSubjectFields()
{
Expand All @@ -745,7 +744,7 @@ protected function getValidSubjectFields()
}

/**
* @return DataList|null
* @return DataList<EditableEmailField>|null
*/
protected function getValidEmailFromFields()
{
Expand All @@ -758,7 +757,7 @@ protected function getValidEmailFromFields()
}

/**
* @return ArrayList|DataList|null
* @return ArrayList<EditableFormField>|DataList<EditableFormField>|null
*/
protected function getValidEmailToFields()
{
Expand Down
2 changes: 1 addition & 1 deletion code/Model/Recipient/UserFormRecipientItemRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function preview()
/**
* Get some placeholder field values to display in the preview
*
* @return ArrayList
* @return ArrayList<ArrayData>
*/
protected function getPreviewFieldData()
{
Expand Down
2 changes: 1 addition & 1 deletion code/Task/RecoverUploadLocationsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ private function getQuery()
* Returns DataList object containing every
* uploaded file record
*
* @return DataList
* @return DataList<SubmittedFileField>
*/
private function getCountQuery()
{
Expand Down
1 change: 0 additions & 1 deletion code/Task/UserFormsColumnCleanTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion code/UserForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<EmailRecipient>
*/
public function FilteredEmailRecipients($data = null, $form = null)
{
Expand Down