Skip to content

Commit 0920832

Browse files
committed
Add documentation for newInstance
1 parent fd515f2 commit 0920832

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).<Paste>
44

55
## [Unreleased]
66

7+
## [0.2.2] - 2016-03-18
8+
### Added
9+
- `newInstance()`
10+
711
## [0.2.1] - 2016-03-13
812
### Added
9-
- `callStatic`
13+
- `callStatic()`
1014

1115
## [0.2.0] - 2016-02-07
1216
### Added

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,30 @@ function ($value) {
214214
return strpos('Tom: My name is Tom', $value, 4);
215215
}
216216
```
217+
218+
#### T\newInstance(string $className, array $arguments = [__])
219+
220+
```php
221+
T\newInstance(Widget::class);
222+
223+
// Is equivalent to:
224+
225+
function ($value) {
226+
return new Widget($value);
227+
}
228+
```
229+
230+
You can also provide a list of arguments using `__` as the placeholder for where
231+
you want the value inserted:
232+
233+
```php
234+
use const TomPHP\Transform\__;
235+
236+
T\newInstance(Widget, ['first', __, 'last']);
237+
238+
// Is equivalent to:
239+
240+
function ($value) {
241+
return new Widget('first', $value, 'last');
242+
}
243+
```

0 commit comments

Comments
 (0)