From 3afd1b833d4cd68a2b57a57fbf22eca60fe2f138 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Thu, 22 Aug 2024 14:24:43 +1200 Subject: [PATCH] API Strong typing for the view layer --- src/Control/RSS/RSSFeed_Entry.php | 7 - src/Dev/TaskRunner.php | 2 +- src/Forms/CompositeField.php | 2 +- src/Forms/Form.php | 8 +- src/Forms/FormField.php | 8 +- src/Forms/FormRequestHandler.php | 2 +- .../GridFieldDetailForm_ItemRequest.php | 2 +- src/Forms/NullableField.php | 2 +- src/Forms/ReadonlyField.php | 2 +- src/Forms/RequiredFields.php | 2 +- src/ORM/ArrayList.php | 6 +- src/ORM/DataList.php | 6 +- src/ORM/DataObject.php | 77 +++---- src/ORM/DataObjectInterface.php | 2 +- src/ORM/EagerLoadedList.php | 2 +- src/ORM/FieldType/DBBigInt.php | 2 +- src/ORM/FieldType/DBBoolean.php | 22 +- src/ORM/FieldType/DBClassName.php | 45 ++-- src/ORM/FieldType/DBComposite.php | 97 +++----- src/ORM/FieldType/DBCurrency.php | 32 +-- src/ORM/FieldType/DBDate.php | 103 +++------ src/ORM/FieldType/DBDatetime.php | 104 ++++----- src/ORM/FieldType/DBDecimal.php | 57 ++--- src/ORM/FieldType/DBDouble.php | 2 +- src/ORM/FieldType/DBEnum.php | 93 +++----- src/ORM/FieldType/DBField.php | 211 +++++------------ src/ORM/FieldType/DBFloat.php | 18 +- src/ORM/FieldType/DBForeignKey.php | 32 +-- src/ORM/FieldType/DBHTMLText.php | 78 +++---- src/ORM/FieldType/DBHTMLVarchar.php | 50 ++-- src/ORM/FieldType/DBInt.php | 21 +- src/ORM/FieldType/DBLocale.php | 23 +- src/ORM/FieldType/DBMoney.php | 74 ++---- src/ORM/FieldType/DBMultiEnum.php | 24 +- src/ORM/FieldType/DBPercentage.php | 18 +- src/ORM/FieldType/DBPolymorphicForeignKey.php | 28 +-- src/ORM/FieldType/DBPrimaryKey.php | 41 ++-- src/ORM/FieldType/DBString.php | 53 ++--- src/ORM/FieldType/DBText.php | 45 ++-- src/ORM/FieldType/DBTime.php | 50 ++-- src/ORM/FieldType/DBVarchar.php | 33 +-- src/ORM/FieldType/DBYear.php | 13 +- src/ORM/ListDecorator.php | 6 +- src/View/ArrayData.php | 19 +- src/View/Parsers/HTMLValue.php | 7 +- src/View/Parsers/ShortcodeParser.php | 2 +- src/View/SSTemplateParser.peg | 4 +- src/View/SSTemplateParser.php | 11 +- src/View/SSViewer_FromString.php | 5 +- src/View/ViewableData.php | 214 ++++++------------ src/View/ViewableData_Customised.php | 29 ++- src/View/ViewableData_Debugger.php | 18 +- .../ViewableDataContainsTest/TestObject.php | 8 +- tests/php/ORM/DBClassNameTest.php | 4 +- .../php/ORM/DBCompositeTest/DBDoubleMoney.php | 2 +- tests/php/ORM/DBFieldTest/TestDataObject.php | 4 +- tests/php/ORM/DBFieldTest/TestDbField.php | 7 +- tests/php/ORM/DBStringTest/MyStringField.php | 2 +- tests/php/ORM/DataObjectTest.php | 22 +- .../MockDynamicAssignmentDBField.php | 6 +- tests/php/ORM/DecimalTest.php | 8 +- tests/php/ORM/DecimalTest/TestObject.php | 1 - tests/php/View/ArrayDataTest.php | 2 +- tests/php/View/SSViewerTest.php | 17 +- tests/php/View/SSViewerTest/TestFixture.php | 14 +- tests/php/View/ViewableDataTest.php | 14 +- tests/php/View/ViewableDataTest/Castable.php | 2 +- tests/php/View/ViewableDataTest/Caster.php | 2 +- .../View/ViewableDataTest/RequiresCasting.php | 2 +- .../View/ViewableDataTest/UnescapedCaster.php | 2 +- 70 files changed, 685 insertions(+), 1248 deletions(-) diff --git a/src/Control/RSS/RSSFeed_Entry.php b/src/Control/RSS/RSSFeed_Entry.php index 5713b84026b..ff6da977f43 100644 --- a/src/Control/RSS/RSSFeed_Entry.php +++ b/src/Control/RSS/RSSFeed_Entry.php @@ -17,13 +17,6 @@ */ class RSSFeed_Entry extends ViewableData { - /** - * The object that represents the item, it contains all the data. - * - * @var mixed - */ - protected $failover; - /** * Name of the title field of feed entries * diff --git a/src/Dev/TaskRunner.php b/src/Dev/TaskRunner.php index 216d6b31327..ecd87c1a26b 100644 --- a/src/Dev/TaskRunner.php +++ b/src/Dev/TaskRunner.php @@ -236,7 +236,7 @@ public function canInit(): bool } return count($this->getTaskList()) > 0; } - + public function providePermissions(): array { return [ diff --git a/src/Forms/CompositeField.php b/src/Forms/CompositeField.php index 15d9abb7a22..7c1cab23f10 100644 --- a/src/Forms/CompositeField.php +++ b/src/Forms/CompositeField.php @@ -514,7 +514,7 @@ public function makeFieldReadonly($field) return false; } - public function debug() + public function debug(): string { $class = static::class; $result = "$class ($this->name)