@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | // +---------------------------------------------------------------------- |
| 9 | 9 | // | Author: liu21st <[email protected]> |
| 10 | 10 | // +---------------------------------------------------------------------- |
| 11 | -declare (strict_types = 1); |
|
| 11 | +declare(strict_types=1); |
|
| 12 | 12 | |
| 13 | 13 | namespace think; |
| 14 | 14 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | return $this->make($abstract); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - throw new ClassNotFoundException('class not exists: ' . $abstract, $abstract); |
|
| 133 | + throw new ClassNotFoundException('class not exists: '.$abstract, $abstract); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | } else { |
| 301 | 301 | $function .= '()'; |
| 302 | 302 | } |
| 303 | - throw new Exception('function not exists: ' . $function, 0, $e); |
|
| 303 | + throw new Exception('function not exists: '.$function, 0, $e); |
|
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | 306 | |
@@ -328,12 +328,12 @@ discard block |
||
| 328 | 328 | } catch (ReflectionException $e) { |
| 329 | 329 | if (is_array($method)) { |
| 330 | 330 | $class = is_object($method[0]) ? get_class($method[0]) : $method[0]; |
| 331 | - $callback = $class . '::' . $method[1]; |
|
| 331 | + $callback = $class.'::'.$method[1]; |
|
| 332 | 332 | } else { |
| 333 | 333 | $callback = $method; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - throw new Exception('method not exists: ' . $callback . '()', 0, $e); |
|
| 336 | + throw new Exception('method not exists: '.$callback.'()', 0, $e); |
|
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | |
| 400 | 400 | return $object; |
| 401 | 401 | } catch (ReflectionException $e) { |
| 402 | - throw new ClassNotFoundException('class not exists: ' . $class, $class, $e); |
|
| 402 | + throw new ClassNotFoundException('class not exists: '.$class, $class, $e); |
|
| 403 | 403 | } |
| 404 | 404 | } |
| 405 | 405 | |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | } elseif ($param->isDefaultValueAvailable()) { |
| 461 | 461 | $args[] = $param->getDefaultValue(); |
| 462 | 462 | } else { |
| 463 | - throw new InvalidArgumentException('method param miss:' . $name); |
|
| 463 | + throw new InvalidArgumentException('method param miss:'.$name); |
|
| 464 | 464 | } |
| 465 | 465 | } |
| 466 | 466 | |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | public static function parseName(string $name = null, int $type = 0, bool $ucfirst = true): string |
| 481 | 481 | { |
| 482 | 482 | if ($type) { |
| 483 | - $name = preg_replace_callback('/_([a-zA-Z])/', function ($match) { |
|
| 483 | + $name = preg_replace_callback('/_([a-zA-Z])/', function($match) { |
|
| 484 | 484 | return strtoupper($match[1]); |
| 485 | 485 | }, $name); |
| 486 | 486 | return $ucfirst ? ucfirst($name) : lcfirst($name); |
@@ -513,13 +513,13 @@ discard block |
||
| 513 | 513 | */ |
| 514 | 514 | public static function factory(string $name, string $namespace = '', ...$args) |
| 515 | 515 | { |
| 516 | - $class = false !== strpos($name, '\\') ? $name : $namespace . ucwords($name); |
|
| 516 | + $class = false !== strpos($name, '\\') ? $name : $namespace.ucwords($name); |
|
| 517 | 517 | |
| 518 | 518 | if (class_exists($class)) { |
| 519 | 519 | return Container::getInstance()->invokeClass($class, $args); |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | - throw new ClassNotFoundException('class not exists:' . $class, $class); |
|
| 522 | + throw new ClassNotFoundException('class not exists:'.$class, $class); |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | /** |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | Container::setInstance($container); |
| 59 | 59 | |
| 60 | - $container->bind('name', function () { |
|
| 60 | + $container->bind('name', function() { |
|
| 61 | 61 | return 'Taylor'; |
| 62 | 62 | }); |
| 63 | 63 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $this->expectExceptionMessage('class not exists: name'); |
| 75 | 75 | $container->get('name'); |
| 76 | 76 | |
| 77 | - $container->bind('name', function () { |
|
| 77 | + $container->bind('name', function() { |
|
| 78 | 78 | return 'Taylor'; |
| 79 | 79 | }); |
| 80 | 80 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | $container = new Container; |
| 87 | 87 | |
| 88 | - $container->bind('name', function () { |
|
| 88 | + $container->bind('name', function() { |
|
| 89 | 89 | return 'Taylor'; |
| 90 | 90 | }); |
| 91 | 91 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | { |
| 101 | 101 | $container = new Container; |
| 102 | 102 | |
| 103 | - $container->bind('name', function () { |
|
| 103 | + $container->bind('name', function() { |
|
| 104 | 104 | return 'Taylor'; |
| 105 | 105 | }); |
| 106 | 106 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | $this->assertSame($object, Container::getInstance()); |
| 194 | 194 | |
| 195 | - Container::setInstance(function () { |
|
| 195 | + Container::setInstance(function() { |
|
| 196 | 196 | return $this; |
| 197 | 197 | }); |
| 198 | 198 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | $this->expectException(Exception::class); |
| 213 | 213 | $this->expectExceptionMessageRegExp('/function not exists: {Closure}@.+#L\d+-\d+/'); |
| 214 | 214 | $container = new Container; |
| 215 | - $container->invokeFunction(function () { |
|
| 215 | + $container->invokeFunction(function() { |
|
| 216 | 216 | throw new \ReflectionException('test exception'); |
| 217 | 217 | }); |
| 218 | 218 | } |
@@ -231,17 +231,17 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | $container->invokeMethod([$stub, 'some']); |
| 233 | 233 | |
| 234 | - $this->assertSame($container, $container->invokeMethod(Taylor::class . '::test')); |
|
| 234 | + $this->assertSame($container, $container->invokeMethod(Taylor::class.'::test')); |
|
| 235 | 235 | |
| 236 | 236 | $reflect = new ReflectionMethod($container, 'exists'); |
| 237 | 237 | |
| 238 | 238 | $this->assertTrue($container->invokeReflectMethod($container, $reflect, [Container::class])); |
| 239 | 239 | |
| 240 | - $this->assertSame($container, $container->invoke(function (Container $container) { |
|
| 240 | + $this->assertSame($container, $container->invoke(function(Container $container) { |
|
| 241 | 241 | return $container; |
| 242 | 242 | })); |
| 243 | 243 | |
| 244 | - $this->assertSame($container, $container->invoke(Taylor::class . '::test')); |
|
| 244 | + $this->assertSame($container, $container->invoke(Taylor::class.'::test')); |
|
| 245 | 245 | |
| 246 | 246 | $object = $container->invokeClass(SomeClass::class); |
| 247 | 247 | $this->assertInstanceOf(SomeClass::class, $object); |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | $stdClass = new stdClass(); |
| 251 | 251 | |
| 252 | - $container->invoke(function (Container $container, stdClass $stdObject, $key1, $lowKey, $key2 = 'default') use ($stdClass) { |
|
| 252 | + $container->invoke(function(Container $container, stdClass $stdObject, $key1, $lowKey, $key2 = 'default') use ($stdClass) { |
|
| 253 | 253 | $this->assertEquals('value1', $key1); |
| 254 | 254 | $this->assertEquals('default', $key2); |
| 255 | 255 | $this->assertEquals('value2', $lowKey); |