Skip to content

Commit 881a921

Browse files
committed
code example fixed
1 parent 181261e commit 881a921

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,31 @@ composer require linna/typed-array
2424
use Linna\TypedArray;
2525

2626
//correct, only int passed to constructor.
27-
$array = new TypedArray('int', [1, 2, 3, 4]);
27+
$intArray = new TypedArray('int', [1, 2, 3, 4]);
2828

2929
//correct, int assigned
30-
$array[] = 5;
30+
$intArray[] = 5;
3131

3232
//throw InvalidArgumentException, string assigned.
33-
$array[] = 'a';
33+
$intArray[] = 'a';
3434

3535
//throw InvalidArgumentException, mixed array passed to constructor.
36-
$array = new TypedArray('int', [1, 'a', 3, 4]);
36+
$otherIntArray = new TypedArray('int', [1, 'a', 3, 4]);
3737

3838
//correct, only Foo class instances passed to constructor.
39-
$array = new TypedArray(Foo::class, [
39+
$fooArray = new TypedArray(Foo::class, [
4040
new Foo(),
4141
new Foo()
4242
]);
4343

4444
//correct, Foo() instance assigned.
45-
$array[] = new Foo();
45+
$fooArray[] = new Foo();
4646

4747
//throw InvalidArgumentException, Bar() instance assigned.
48-
$array[] = new Bar();
48+
$fooArray[] = new Bar();
4949

5050
//throw InvalidArgumentException, mixed array of instances passed to constructor.
51-
$array = new TypedArray(Foo::class, [
51+
$otherFooArray = new TypedArray(Foo::class, [
5252
new Foo(),
5353
new Bar()
5454
]);

0 commit comments

Comments
 (0)