Skip to content

Commit 0c27677

Browse files
[12.x] docs: document container respecting property default values (#10250)
* docs: document container respecting property default values See: laravel/framework#53522 * formatting * Formatting --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent e181b1c commit 0c27677

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

upgrade.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
- [Carbon 3](#carbon-3)
3030
- [Concurrency Result Index Mapping](#concurrency-result-index-mapping)
31+
- [Container Class Dependency Resolution](#container-class-dependency-resolution)
3132
- [Image Validation Now Excludes SVGs](#image-validation)
3233
- [Multi-Schema Database Inspecting](#multi-schema-database-inspecting)
3334
- [Nested Array Request Merging](#nested-array-request-merging)
@@ -109,6 +110,31 @@ $result = Concurrency::run([
109110
// ['task-1' => 2, 'task-2' => 4]
110111
```
111112

113+
<a name="container"></a>
114+
### Container
115+
116+
<a name="container-class-dependency-resolution"></a>
117+
#### Container Class Dependency Resolution
118+
119+
**Likelihood Of Impact: Low**
120+
121+
The dependency injection container now respects the default value of class properties when resolving a class instance. If you were previously relying on the container to resolve a class instance without the default value, you may need to adjust your application to account for this new behavior:
122+
123+
```php
124+
class Example
125+
{
126+
public function __construct(public ?Carbon $date = null) {}
127+
}
128+
129+
$example = resolve(Example::class);
130+
131+
// <= 11.x
132+
$example->date instanceof Carbon;
133+
134+
// >= 12.x
135+
$example->date === null;
136+
```
137+
112138
<a name="database"></a>
113139
### Database
114140

0 commit comments

Comments
 (0)