-
Notifications
You must be signed in to change notification settings - Fork 67
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
DOC Update typehints in docs #569
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,14 +11,16 @@ title: 6.0.0 (unreleased) | |
- [Changes to default cache adapters](#caching) | ||
- [Changes to scaffolded form fields](#scaffolded-fields) | ||
- [`SiteTree` uses form field scaffolding](#sitetree-scaffolding) | ||
- [Other new features](#other-new-features) | ||
- [Changes to the templating/view layer](#view-layer) | ||
- [Other new features and small changes](#other-new-features) | ||
- [Dependency changes](#dependency-changes) | ||
- [`intervention/image` has been upgraded from v2 to v3](#intervention-image) | ||
- [Bug fixes](#bug-fixes) | ||
- [API changes](#api-changes) | ||
- [Most extension hook methods are now protected](#hooks-protected) | ||
- [Strict typing for `Factory` implementations](#factory-strict-typing) | ||
- [General changes](#api-general) | ||
- [Full list of removed and changed API (by module, alphabetically)](#api-removed-and-changed) | ||
|
||
## Features and enhancements | ||
|
||
|
@@ -181,12 +183,27 @@ SilverStripe\UserForms\Model\UserDefinedForm: | |
|
||
</details> | ||
|
||
### Other new features | ||
### Changes to the templating/view layer {#view-layer} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Other new features" renamed and is now below the new section (more details in comment where it's being added). Giving the new section a nice broad name because I'll use this section for the overall changelog info for the template layer refactor. |
||
|
||
- Native indexed PHP arrays can now be passed into templates and iterated over with `<% loop $MyArray %>`. Under the hood they are wrapped in [`ArrayList`](api:SilverStripe\View\ViewableData), so you can get the count using `$Count` and use `<% if $ArrayList %>` as a shortcut for `<% if $ArrayList.Count %>`. Other functionality from `ArrayList` such as filtering and sorting cannot be used on arrays since they don't have keys to filter or sort against. | ||
#### Strong typing for `ViewableData` and `DBField` | ||
|
||
Many of the properties and methods in [`ViewableData`](api:SilverStripe\View\ViewableData), [`DBField`](api:SilverStripe\ORM\FieldType\DBField), and their immediate subclasses have been given strong typehints. Previously, these only had typehints in the PHPDoc which meant that any arbitrary values could be assigned or returned. | ||
|
||
Most of the strong types are either identical to the old PHPDoc types, or match what was already actually being assigned to, passed into, and returned from those APIs. | ||
|
||
In some cases, where a string was expected but sometimes `null` was being used, we have explicitly strongly typed the API to `string`. This matches [similar changes PHP made in PHP 8.1](https://php.watch/versions/8.1/internal-func-non-nullable-null-deprecation) and will help avoid passing `null` values in to functions that expect a string. | ||
|
||
The one change we specifically want to call out is for [`ViewableData::obj()`](api:SilverStripe\View\ViewableData::obj()). This method will now explicitly return `null` if there is no field, property, method, etc to represent the field you're trying to get an object for. This is a change from the old behaviour, where an empty `DBField` instance would be returned even though there's no way for any non-null value to be available for that field. | ||
|
||
See the [full list of removed and changed API](#api-removed-and-changed) to see all of the API with updated typing. | ||
|
||
### Other new features and small changes {#other-new-features} | ||
|
||
Comment on lines
+200
to
+201
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Renamed because the note about the default value isn't really a new feature, but there's also no need for it to have its own section. |
||
- Native indexed PHP arrays can now be passed into templates and iterated over with `<% loop $MyArray %>`. Under the hood they are wrapped in [`ArrayList`](api:SilverStripe\ORM\ArrayList), so you can get the count using `$Count` and use `<% if $ArrayList %>` as a shortcut for `<% if $ArrayList.Count %>`. Other functionality from `ArrayList` such as filtering and sorting cannot be used on arrays since they don't have keys to filter or sort against. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just changing a link from |
||
- Modules no longer need to have a root level `_config.php` or `_config` directory to be recognised as a Silverstripe CMS module. They will now be recognised as a module if they have a `composer.json` file with a `type` of `silverstripe-vendormodule` or `silverstripe-theme`. | ||
- A new [`DataObject::getCMSEditLink()`](api:SilverStripe\ORM\DataObject::getCMSEditLink()) method has been added, which returns `null` by default. This provides more consistency for that method which has previously been inconsistently applied to various subclasses of `DataObject`. See [managing records](/developer_guides/model/managing_records/#getting-an-edit-link) for more details about providing sane values for this method in your own subclasses. | ||
- The `CMSEditLink()` method on many `DataObject` subclasses has been renamed to `getCMSEditLink()`. | ||
- Previously if an invalid default value was provided for a [`DBDecimal`](api:SilverStripe\ORM\FieldType\DBDecimal) database column, it would silently set the defalt value to `0`. This will now throw an exception instead, so that you're aware your configured value is invalid and can correct it. | ||
|
||
## Dependency changes | ||
|
||
|
@@ -296,6 +313,8 @@ Injector::inst()->load([ | |
- [`FieldList`](api:SilverStripe\Forms\FieldList) is now strongly typed. Methods that previously allowed any iterable variables to be passed, namely [`FieldList::addFieldsToTab()`](api:SilverStripe\Forms\FieldList::addFieldsToTab()) and [`FieldList::removeFieldsFromTab()`](api:SilverStripe\Forms\FieldList::removeFieldsFromTab()), now require an array to be passed instead. | ||
- [`BaseElement::getDescription()`](api:DNADesign\Elemental\Models\BaseElement::getDescription()) has been removed. If you had implemented this method in your custom elemental blocks, either set the [`description`](api:DNADesign\Elemental\Models\BaseElement->description) configuration property or override the [`getTypeNice()`](api:DNADesign\Elemental\Models\BaseElement::getTypeNice()) method. | ||
|
||
### Full list of removed and changed API (by module, alphabetically) {#api-removed-and-changed} | ||
|
||
<!--- Changes below this line will be automatically regenerated --> | ||
|
||
<!--- Changes above this line will be automatically regenerated --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the name and anchor we gave this section for CMS 5.
Adding now so I can link to it.