@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $attribute = uniqid(); |
| 32 | 32 | $format = uniqid(); |
| 33 | - $args = [ uniqid() => uniqid() ]; |
|
| 33 | + $args = [uniqid() => uniqid()]; |
|
| 34 | 34 | $this->errors->add($attribute, $format, $args); |
| 35 | 35 | $this->assertEquals(1, $this->errors->count()); |
| 36 | 36 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | public function test_add_with_true() |
| 46 | 46 | { |
| 47 | 47 | $attribute = uniqid(); |
| 48 | - $args = [ uniqid() => uniqid() ]; |
|
| 48 | + $args = [uniqid() => uniqid()]; |
|
| 49 | 49 | $this->errors->add($attribute, true, $args); |
| 50 | 50 | $this->assertEquals(1, $this->errors->count()); |
| 51 | 51 | |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | public function test_add_with_error() |
| 61 | 61 | { |
| 62 | - $error = new Error(uniqid(), [ uniqid() => uniqid() ]); |
|
| 62 | + $error = new Error(uniqid(), [uniqid() => uniqid()]); |
|
| 63 | 63 | $attribute = uniqid(); |
| 64 | - $this->errors->add($attribute, $error, [ uniqid() => uniqid() ]); |
|
| 64 | + $this->errors->add($attribute, $error, [uniqid() => uniqid()]); |
|
| 65 | 65 | $this->assertEquals(1, $this->errors->count()); |
| 66 | 66 | |
| 67 | 67 | $errors = $this->errors[$attribute]; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | public function test_add_generic() |
| 73 | 73 | { |
| 74 | - $error = new Error(uniqid(), [ uniqid() => uniqid() ]); |
|
| 74 | + $error = new Error(uniqid(), [uniqid() => uniqid()]); |
|
| 75 | 75 | $this->errors->add_generic($error); |
| 76 | 76 | $errors = $this->errors[null]; |
| 77 | 77 | $this->assertSame($error, reset($errors)); |
@@ -80,10 +80,10 @@ discard block |
||
| 80 | 80 | public function test_array_access_interface() |
| 81 | 81 | { |
| 82 | 82 | $errors = $this->errors; |
| 83 | - $err1 = new Error(uniqid(), [ uniqid() => uniqid() ]); |
|
| 84 | - $err2 = new Error(uniqid(), [ uniqid() => uniqid() ]); |
|
| 85 | - $err3 = new Error(uniqid(), [ uniqid() => uniqid() ]); |
|
| 86 | - $err4 = new Error(uniqid(), [ uniqid() => uniqid() ]); |
|
| 83 | + $err1 = new Error(uniqid(), [uniqid() => uniqid()]); |
|
| 84 | + $err2 = new Error(uniqid(), [uniqid() => uniqid()]); |
|
| 85 | + $err3 = new Error(uniqid(), [uniqid() => uniqid()]); |
|
| 86 | + $err4 = new Error(uniqid(), [uniqid() => uniqid()]); |
|
| 87 | 87 | $attribute = uniqid(); |
| 88 | 88 | $errors[] = $err1; |
| 89 | 89 | $errors[] = $err2; |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | $this->assertTrue(isset($errors[null])); |
| 94 | 94 | $this->assertTrue(isset($errors[$attribute])); |
| 95 | - $this->assertSame([ $err1, $err2 ], $errors[null]); |
|
| 96 | - $this->assertSame([ $err3, $err4 ], $errors[$attribute]); |
|
| 95 | + $this->assertSame([$err1, $err2], $errors[null]); |
|
| 96 | + $this->assertSame([$err3, $err4], $errors[$attribute]); |
|
| 97 | 97 | |
| 98 | 98 | unset($errors[null]); |
| 99 | 99 | $this->assertSame([], $errors[null]); |
@@ -118,15 +118,15 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | foreach ($errors as $a => $e) |
| 120 | 120 | { |
| 121 | - $iterator_errors[] = [ $a => $e ]; |
|
| 121 | + $iterator_errors[] = [$a => $e]; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | $this->assertSame([ |
| 125 | 125 | |
| 126 | - [ ErrorCollection::GENERIC => $err1 ], |
|
| 127 | - [ ErrorCollection::GENERIC => $err2 ], |
|
| 128 | - [ $attribute => $err3 ], |
|
| 129 | - [ $attribute => $err4 ], |
|
| 126 | + [ErrorCollection::GENERIC => $err1], |
|
| 127 | + [ErrorCollection::GENERIC => $err2], |
|
| 128 | + [$attribute => $err3], |
|
| 129 | + [$attribute => $err4], |
|
| 130 | 130 | |
| 131 | 131 | ], $iterator_errors); |
| 132 | 132 | } |
@@ -146,19 +146,19 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | $iterator_errors = []; |
| 148 | 148 | |
| 149 | - $errors->each(function ($error, $attribute, $collection) use (&$iterator_errors, $errors) { |
|
| 149 | + $errors->each(function($error, $attribute, $collection) use (&$iterator_errors, $errors) { |
|
| 150 | 150 | |
| 151 | 151 | $this->assertSame($errors, $collection); |
| 152 | - $iterator_errors[] = [ $attribute => $error ]; |
|
| 152 | + $iterator_errors[] = [$attribute => $error]; |
|
| 153 | 153 | |
| 154 | 154 | }); |
| 155 | 155 | |
| 156 | 156 | $this->assertSame([ |
| 157 | 157 | |
| 158 | - [ ErrorCollection::GENERIC => $err1 ], |
|
| 159 | - [ ErrorCollection::GENERIC => $err2 ], |
|
| 160 | - [ $attribute => $err3 ], |
|
| 161 | - [ $attribute => $err4 ], |
|
| 158 | + [ErrorCollection::GENERIC => $err1], |
|
| 159 | + [ErrorCollection::GENERIC => $err2], |
|
| 160 | + [$attribute => $err3], |
|
| 161 | + [$attribute => $err4], |
|
| 162 | 162 | |
| 163 | 163 | ], $iterator_errors); |
| 164 | 164 | } |
@@ -179,10 +179,10 @@ discard block |
||
| 179 | 179 | $arg4 = uniqid(); |
| 180 | 180 | $attribute = uniqid(); |
| 181 | 181 | $errors = $this->errors; |
| 182 | - $errors->add($attribute, $format, [ 'arg' => $arg3 ]); |
|
| 183 | - $errors->add_generic($format, [ 'arg' => $arg1 ]); |
|
| 184 | - $errors->add($attribute, $format, [ 'arg' => $arg4 ]); |
|
| 185 | - $errors->add_generic($format, [ 'arg' => $arg2 ]); |
|
| 182 | + $errors->add($attribute, $format, ['arg' => $arg3]); |
|
| 183 | + $errors->add_generic($format, ['arg' => $arg1]); |
|
| 184 | + $errors->add($attribute, $format, ['arg' => $arg4]); |
|
| 185 | + $errors->add_generic($format, ['arg' => $arg2]); |
|
| 186 | 186 | |
| 187 | 187 | $this->assertSame(json_encode([ |
| 188 | 188 | |
@@ -26,10 +26,10 @@ discard block |
||
| 26 | 26 | $attribute = uniqid(); |
| 27 | 27 | |
| 28 | 28 | $errors = (new ErrorCollection) |
| 29 | - ->add($attribute, $format, [ 'arg' => $arg3 ]) |
|
| 30 | - ->add_generic($format, [ 'arg' => $arg1 ]) |
|
| 31 | - ->add($attribute, $format, [ 'arg' => $arg4 ]) |
|
| 32 | - ->add_generic($format, [ 'arg' => $arg2 ]) |
|
| 29 | + ->add($attribute, $format, ['arg' => $arg3]) |
|
| 30 | + ->add_generic($format, ['arg' => $arg1]) |
|
| 31 | + ->add($attribute, $format, ['arg' => $arg4]) |
|
| 32 | + ->add_generic($format, ['arg' => $arg2]) |
|
| 33 | 33 | ; |
| 34 | 34 | |
| 35 | 35 | $renderer = new RenderedErrorCollection($errors); |
@@ -37,15 +37,15 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | foreach ($renderer as $a => $r) |
| 39 | 39 | { |
| 40 | - $rendered[] = [ $a, $r ]; |
|
| 40 | + $rendered[] = [$a, $r]; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $this->assertSame([ |
| 44 | 44 | |
| 45 | - [ ErrorCollection::GENERIC, "error: {$arg1}" ], |
|
| 46 | - [ ErrorCollection::GENERIC, "error: {$arg2}" ], |
|
| 47 | - [ $attribute, "error: {$arg3}" ], |
|
| 48 | - [ $attribute, "error: {$arg4}" ], |
|
| 45 | + [ErrorCollection::GENERIC, "error: {$arg1}"], |
|
| 46 | + [ErrorCollection::GENERIC, "error: {$arg2}"], |
|
| 47 | + [$attribute, "error: {$arg3}"], |
|
| 48 | + [$attribute, "error: {$arg4}"], |
|
| 49 | 49 | |
| 50 | 50 | ], $rendered); |
| 51 | 51 | } |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | $attribute = uniqid(); |
| 61 | 61 | |
| 62 | 62 | $errors = (new ErrorCollection) |
| 63 | - ->add($attribute, $format, [ 'arg' => $arg3 ]) |
|
| 64 | - ->add_generic($format, [ 'arg' => $arg1 ]) |
|
| 65 | - ->add($attribute, $format, [ 'arg' => $arg4 ]) |
|
| 66 | - ->add_generic($format, [ 'arg' => $arg2 ]) |
|
| 63 | + ->add($attribute, $format, ['arg' => $arg3]) |
|
| 64 | + ->add_generic($format, ['arg' => $arg1]) |
|
| 65 | + ->add($attribute, $format, ['arg' => $arg4]) |
|
| 66 | + ->add_generic($format, ['arg' => $arg2]) |
|
| 67 | 67 | ; |
| 68 | 68 | |
| 69 | - $renderer = new RenderedErrorCollection($errors, function (Error $error) { |
|
| 69 | + $renderer = new RenderedErrorCollection($errors, function(Error $error) { |
|
| 70 | 70 | |
| 71 | 71 | return strrev($error); |
| 72 | 72 | |
@@ -76,15 +76,15 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | foreach ($renderer as $a => $r) |
| 78 | 78 | { |
| 79 | - $rendered[] = [ $a, $r ]; |
|
| 79 | + $rendered[] = [$a, $r]; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | $this->assertSame([ |
| 83 | 83 | |
| 84 | - [ ErrorCollection::GENERIC, strrev("error: {$arg1}") ], |
|
| 85 | - [ ErrorCollection::GENERIC, strrev("error: {$arg2}") ], |
|
| 86 | - [ $attribute, strrev("error: {$arg3}") ], |
|
| 87 | - [ $attribute, strrev("error: {$arg4}") ], |
|
| 84 | + [ErrorCollection::GENERIC, strrev("error: {$arg1}")], |
|
| 85 | + [ErrorCollection::GENERIC, strrev("error: {$arg2}")], |
|
| 86 | + [$attribute, strrev("error: {$arg3}")], |
|
| 87 | + [$attribute, strrev("error: {$arg4}")], |
|
| 88 | 88 | |
| 89 | 89 | ], $rendered); |
| 90 | 90 | } |
@@ -236,7 +236,7 @@ |
||
| 236 | 236 | */ |
| 237 | 237 | public function to_array() |
| 238 | 238 | { |
| 239 | - return array_filter(array_merge([ self::GENERIC => [] ], $this->collection)); |
|
| 239 | + return array_filter(array_merge([self::GENERIC => []], $this->collection)); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |