Skip to content

Commit

Permalink
ENH Add generic types
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Jan 11, 2024
1 parent 5e6e873 commit 738eaac
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
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

0 comments on commit 738eaac

Please sign in to comment.