Skip to content

Commit 06783dc

Browse files
committed
documentation updated
1 parent 7fd2a32 commit 06783dc

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ use Linna\TypedArray;
3030
//correct, only int passed to array.
3131
$array = new TypedArray('int', [1, 2, 3, 4]);
3232
$array[] = 5;
33+
//throw InvalidArgumentException.
34+
$array[] = 'a';
3335

3436
//throw InvalidArgumentException.
3537
$array = new TypedArray('int', [1, 'a', 3, 4]);
36-
//throw InvalidArgumentException.
37-
$array[] = 'a';
3838
```
3939
> **Note:** Allowed types are: *array*, *bool*, *callable*, *float*, *int*, *object*, *string*.
4040
@@ -48,14 +48,14 @@ $array = new TypedObjectArray(Foo::class, [
4848
new Foo()
4949
]);
5050
$array[] = new Foo();
51+
//throw InvalidArgumentException.
52+
$array[] = new Bar();
5153

5254
//throw InvalidArgumentException.
5355
$array = new TypedObjectArray(Foo::class, [
5456
new Foo(),
5557
new Bar()
5658
]);
57-
//throw InvalidArgumentException.
58-
$array[] = new Bar();
5959
```
6060
## Performance consideration
6161
Compared to the parent class [ArrayObject](http://php.net/manual/en/class.arrayobject.php) typed arrays are slower on writing

src/TypedArray.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ class TypedArray extends ArrayObject
4545
* //correct, only int passed to array.
4646
* $array = new TypedArray('int', [1, 2, 3, 4]);
4747
* $array[] = 5;
48+
* //throw InvalidArgumentException.
49+
* $array[] = 'a';
4850
*
4951
* //throw InvalidArgumentException.
5052
* $array = new TypedArray('int', [1, 'a', 3, 4]);
51-
* //throw InvalidArgumentException.
52-
* $array[] = 'a';
5353
* </code></pre>
5454
*
5555
* <b>Note</b>: Allowed types are only <i>array</i>, <i>bool</i>, <i>callable</i>,

src/TypedObjectArray.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ class TypedObjectArray extends ArrayObject
3535
* new Foo()
3636
* ]);
3737
* $array[] = new Foo();
38+
* //throw InvalidArgumentException.
39+
* $array[] = new Bar();
3840
*
3941
* //throw InvalidArgumentException.
4042
* $array = new TypedObjectArray(Foo::class, [
4143
* new Foo(),
4244
* new Bar()
4345
* ]);
44-
* //throw InvalidArgumentException.
45-
* $array[] = new Bar();
4646
* </code></pre>
4747
*
4848
* <b>Note</b>: Allowed types are only <i>existing classes</i>.

0 commit comments

Comments
 (0)