@@ -42,7 +42,7 @@ |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | if (!isset(static::$methodArgs[$name])) { |
45 | - throw new \BadMethodCallException($name . ' is not a valid method'); |
|
45 | + throw new \BadMethodCallException($name.' is not a valid method'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | $numArgs = \count($arguments); |
@@ -111,11 +111,11 @@ |
||
111 | 111 | |
112 | 112 | // resource |
113 | 113 | if (\is_resource($value)) { |
114 | - return \get_resource_type($value) . ' resource #' . (int) $value; |
|
114 | + return \get_resource_type($value).' resource #'.(int) $value; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | if (\is_object($value)) { |
118 | - return \get_class($value) . ' Object'; |
|
118 | + return \get_class($value).' Object'; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | return ''; |
@@ -82,32 +82,32 @@ |
||
82 | 82 | \gettype($value) === (self::$typeMapping[$type] ?? $type) |
83 | 83 | || |
84 | 84 | ( |
85 | - $type === 'scalar' |
|
85 | + $type === 'scalar' |
|
86 | 86 | && |
87 | 87 | \is_scalar($value) |
88 | - ) |
|
88 | + ) |
|
89 | 89 | || |
90 | 90 | ( |
91 | - $type === 'callable' |
|
91 | + $type === 'callable' |
|
92 | 92 | && |
93 | 93 | \is_callable($value) |
94 | - ) |
|
94 | + ) |
|
95 | 95 | || |
96 | 96 | ( |
97 | - $type === 'numeric' |
|
97 | + $type === 'numeric' |
|
98 | 98 | && |
99 | 99 | ( |
100 | - \is_float($value) |
|
100 | + \is_float($value) |
|
101 | 101 | || |
102 | 102 | \is_int($value) |
103 | - ) |
|
104 | - ) |
|
103 | + ) |
|
104 | + ) |
|
105 | 105 | || |
106 | 106 | ( |
107 | - $type === 'resource' |
|
107 | + $type === 'resource' |
|
108 | 108 | && |
109 | 109 | \is_resource($value) |
110 | - ); |
|
110 | + ); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -26,7 +26,7 @@ |
||
26 | 26 | */ |
27 | 27 | public function throwException($expectedTypes, $value, $type): \Throwable |
28 | 28 | { |
29 | - throw new \TypeError("Invalid type: expected to be of type {{$expectedTypes}}, instead got value `" . \print_r($value, true) . "` with type {{$type}}."); |
|
29 | + throw new \TypeError("Invalid type: expected to be of type {{$expectedTypes}}, instead got value `".\print_r($value, true)."` with type {{$type}}."); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -290,9 +290,9 @@ |
||
290 | 290 | $return = static::create(); |
291 | 291 | $jsonObject = \json_decode($json, false); |
292 | 292 | $mapper = new \Arrayy\Mapper\Json(); |
293 | - $mapper->undefinedPropertyHandler = static function ($object, $key, $jsonValue) use ($return) { |
|
293 | + $mapper->undefinedPropertyHandler = static function($object, $key, $jsonValue) use ($return) { |
|
294 | 294 | if ($return->checkForMissingPropertiesInConstructor) { |
295 | - throw new \TypeError('Property mismatch - input: ' . \print_r(['key' => $key, 'jsonValue' => $jsonValue], true) . ' for object: ' . \get_class($object)); |
|
295 | + throw new \TypeError('Property mismatch - input: '.\print_r(['key' => $key, 'jsonValue' => $jsonValue], true).' for object: '.\get_class($object)); |
|
296 | 296 | } |
297 | 297 | }; |
298 | 298 |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require __DIR__ . '/../vendor/autoload.php'; |
|
4 | -require __DIR__ . '/vendor/autoload.php'; |
|
3 | +require __DIR__.'/../vendor/autoload.php'; |
|
4 | +require __DIR__.'/vendor/autoload.php'; |
|
5 | 5 | |
6 | 6 | $readmeText = (new \voku\PhpReadmeHelper\GenerateApi())->generate( |
7 | - __DIR__ . '/../src/Arrayy.php', |
|
8 | - __DIR__ . '/docs/base.md' |
|
7 | + __DIR__.'/../src/Arrayy.php', |
|
8 | + __DIR__.'/docs/base.md' |
|
9 | 9 | ); |
10 | 10 | |
11 | -file_put_contents(__DIR__ . '/../README.md', $readmeText); |
|
11 | +file_put_contents(__DIR__.'/../README.md', $readmeText); |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace Arrayy\tests; |
4 | 4 | |
5 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
5 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
6 | 6 | |
7 | 7 | /** |
8 | 8 | * @property string $type |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | if (!\is_object($object)) { |
74 | 74 | throw new \InvalidArgumentException( |
75 | - 'JsonMapper::map() requires second argument to be an object, ' . \gettype($object) . ' given.' |
|
75 | + 'JsonMapper::map() requires second argument to be an object, '.\gettype($object).' given.' |
|
76 | 76 | ); |
77 | 77 | } |
78 | 78 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $type = $this->removeNullable($type); |
122 | 122 | } elseif ($jsonValue === null) { |
123 | 123 | throw new \InvalidArgumentException( |
124 | - 'JSON property "' . $key . '" in class "' . $strClassName . '" must not be NULL' |
|
124 | + 'JSON property "'.$key.'" in class "'.$strClassName.'" must not be NULL' |
|
125 | 125 | ); |
126 | 126 | } |
127 | 127 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | if ($this->isSimpleType($type)) { |
149 | 149 | if ($type === 'string' && \is_object($jsonValue)) { |
150 | 150 | throw new \InvalidArgumentException( |
151 | - 'JSON property "' . $key . '" in class "' . $strClassName . '" is an object and cannot be converted to a string' |
|
151 | + 'JSON property "'.$key.'" in class "'.$strClassName.'" is an object and cannot be converted to a string' |
|
152 | 152 | ); |
153 | 153 | } |
154 | 154 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | if ($type === '') { |
171 | 171 | throw new \InvalidArgumentException( |
172 | - 'Empty type at property "' . $strClassName . '::$' . $key . '"' |
|
172 | + 'Empty type at property "'.$strClassName.'::$'.$key.'"' |
|
173 | 173 | ); |
174 | 174 | } |
175 | 175 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $this->isScalarType(\gettype($jsonValue)) |
204 | 204 | ) { |
205 | 205 | throw new \InvalidArgumentException( |
206 | - 'JSON property "' . $key . '" must be an array, ' . \gettype($jsonValue) . ' given' |
|
206 | + 'JSON property "'.$key.'" must be an array, '.\gettype($jsonValue).' given' |
|
207 | 207 | ); |
208 | 208 | } |
209 | 209 | |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | } |
304 | 304 | } elseif ($this->isScalarType($class)) { |
305 | 305 | throw new \InvalidArgumentException( |
306 | - 'JSON property "' . ($parent_key ?: '?') . '" is an array of type "' . $class . '" but contained a value of type "' . \gettype($jsonValue) . '"' |
|
306 | + 'JSON property "'.($parent_key ?: '?').'" is an array of type "'.$class.'" but contained a value of type "'.\gettype($jsonValue).'"' |
|
307 | 307 | ); |
308 | 308 | } elseif (\is_a($class, \ArrayObject::class, true)) { |
309 | 309 | /** @noinspection PhpSillyAssignmentInspection - phpstan helper */ |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | } |
360 | 360 | |
361 | 361 | //create a full qualified namespace |
362 | - return '\\' . $strNs . '\\' . $type; |
|
362 | + return '\\'.$strNs.'\\'.$type; |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | /** |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | */ |
664 | 664 | private function isNullable($type): bool |
665 | 665 | { |
666 | - return \stripos('|' . $type . '|', '|null|') !== false; |
|
666 | + return \stripos('|'.$type.'|', '|null|') !== false; |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | /** |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | } |
681 | 681 | |
682 | 682 | return \substr( |
683 | - \str_ireplace('|null|', '|', '|' . $type . '|'), |
|
683 | + \str_ireplace('|null|', '|', '|'.$type.'|'), |
|
684 | 684 | 1, |
685 | 685 | -1 |
686 | 686 | ); |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | $constructor->getNumberOfRequiredParameters() > 0 |
729 | 729 | ) { |
730 | 730 | /** @phpstan-var TClass $return */ |
731 | - $return = $reflectClass->newInstanceWithoutConstructor(); |
|
731 | + $return = $reflectClass->newInstanceWithoutConstructor(); |
|
732 | 732 | } else { |
733 | 733 | /** @phpstan-var TClass $return */ |
734 | 734 | $return = $reflectClass->newInstance(); |
@@ -67,6 +67,6 @@ |
||
67 | 67 | */ |
68 | 68 | public function throwException($expectedTypes, $value, $type): \Throwable |
69 | 69 | { |
70 | - throw new \TypeError('Invalid type: callable failed, got value `' . \print_r($value, true) . "` with type {{$type}}."); |
|
70 | + throw new \TypeError('Invalid type: callable failed, got value `'.\print_r($value, true)."` with type {{$type}}."); |
|
71 | 71 | } |
72 | 72 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | $return = TypeCheckArray::create( |
25 | 25 | [ |
26 | 26 | Arrayy::ARRAYY_HELPER_TYPES_FOR_ALL_PROPERTIES => new TypeCheckCallback( |
27 | - static function ($value) { |
|
27 | + static function($value) { |
|
28 | 28 | return \is_string($value) && \is_numeric($value); |
29 | 29 | } |
30 | 30 | ), |