@@ -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 | /** |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | { |
| 305 | 305 | if (is_array($method)) { |
| 306 | 306 | [$class, $method] = $method; |
| 307 | - $class = is_object($class) ? $class : $this->invokeClass($class); |
|
| 307 | + $class = is_object($class) ? $class : $this->invokeClass($class); |
|
| 308 | 308 | } else { |
| 309 | 309 | // 静态方法 |
| 310 | 310 | [$class, $method] = explode('::', $method); |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | try { |
| 374 | 374 | $reflect = new ReflectionClass($class); |
| 375 | 375 | } catch (ReflectionException $e) { |
| 376 | - throw new ClassNotFoundException('class not exists: ' . $class, $class, $e); |
|
| 376 | + throw new ClassNotFoundException('class not exists: '.$class, $class, $e); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | if ($reflect->hasMethod('__make')) { |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | } elseif ($param->isDefaultValueAvailable()) { |
| 453 | 453 | $args[] = $param->getDefaultValue(); |
| 454 | 454 | } else { |
| 455 | - throw new InvalidArgumentException('method param miss:' . $name); |
|
| 455 | + throw new InvalidArgumentException('method param miss:'.$name); |
|
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | 458 | |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | */ |
| 471 | 471 | public static function factory(string $name, string $namespace = '', ...$args) |
| 472 | 472 | { |
| 473 | - $class = false !== strpos($name, '\\') ? $name : $namespace . ucwords($name); |
|
| 473 | + $class = false !== strpos($name, '\\') ? $name : $namespace.ucwords($name); |
|
| 474 | 474 | |
| 475 | 475 | return Container::getInstance()->invokeClass($class, $args); |
| 476 | 476 | } |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | public function __construct(string $message, string $func = '', Throwable $previous = null) |
| 14 | 14 | { |
| 15 | 15 | $this->message = $message; |
| 16 | - $this->func = $func; |
|
| 16 | + $this->func = $func; |
|
| 17 | 17 | |
| 18 | 18 | parent::__construct($message, 0, $previous); |
| 19 | 19 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | Container::setInstance($container); |
| 65 | 65 | |
| 66 | - $container->bind('name', function () { |
|
| 66 | + $container->bind('name', function() { |
|
| 67 | 67 | return 'Taylor'; |
| 68 | 68 | }); |
| 69 | 69 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $this->expectExceptionMessage('class not exists: name'); |
| 81 | 81 | $container->get('name'); |
| 82 | 82 | |
| 83 | - $container->bind('name', function () { |
|
| 83 | + $container->bind('name', function() { |
|
| 84 | 84 | return 'Taylor'; |
| 85 | 85 | }); |
| 86 | 86 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | { |
| 92 | 92 | $container = new Container; |
| 93 | 93 | |
| 94 | - $container->bind('name', function () { |
|
| 94 | + $container->bind('name', function() { |
|
| 95 | 95 | return 'Taylor'; |
| 96 | 96 | }); |
| 97 | 97 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | { |
| 107 | 107 | $container = new Container; |
| 108 | 108 | |
| 109 | - $container->bind('name', function () { |
|
| 109 | + $container->bind('name', function() { |
|
| 110 | 110 | return 'Taylor'; |
| 111 | 111 | }); |
| 112 | 112 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | $this->assertSame($object, Container::getInstance()); |
| 200 | 200 | |
| 201 | - Container::setInstance(function () { |
|
| 201 | + Container::setInstance(function() { |
|
| 202 | 202 | return $this; |
| 203 | 203 | }); |
| 204 | 204 | |
@@ -210,10 +210,10 @@ discard block |
||
| 210 | 210 | $container = new Container(); |
| 211 | 211 | $container->bind(Container::class, $container); |
| 212 | 212 | |
| 213 | - $container->resolving(function (SomeClass $taylor, Container $container) { |
|
| 213 | + $container->resolving(function(SomeClass $taylor, Container $container) { |
|
| 214 | 214 | $taylor->count++; |
| 215 | 215 | }); |
| 216 | - $container->resolving(SomeClass::class, function (SomeClass $taylor, Container $container) { |
|
| 216 | + $container->resolving(SomeClass::class, function(SomeClass $taylor, Container $container) { |
|
| 217 | 217 | $taylor->count++; |
| 218 | 218 | }); |
| 219 | 219 | |
@@ -252,19 +252,19 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | $this->assertEquals('48', $container->invoke('ord', ['0'])); |
| 254 | 254 | |
| 255 | - $this->assertSame($container, $container->invoke(Taylor::class . '::test', [])); |
|
| 255 | + $this->assertSame($container, $container->invoke(Taylor::class.'::test', [])); |
|
| 256 | 256 | |
| 257 | - $this->assertSame($container, $container->invokeMethod(Taylor::class . '::test')); |
|
| 257 | + $this->assertSame($container, $container->invokeMethod(Taylor::class.'::test')); |
|
| 258 | 258 | |
| 259 | 259 | $reflect = new ReflectionMethod($container, 'exists'); |
| 260 | 260 | |
| 261 | 261 | $this->assertTrue($container->invokeReflectMethod($container, $reflect, [Container::class])); |
| 262 | 262 | |
| 263 | - $this->assertSame($container, $container->invoke(function (Container $container) { |
|
| 263 | + $this->assertSame($container, $container->invoke(function(Container $container) { |
|
| 264 | 264 | return $container; |
| 265 | 265 | })); |
| 266 | 266 | |
| 267 | - $this->assertSame($container, $container->invoke(Taylor::class . '::test')); |
|
| 267 | + $this->assertSame($container, $container->invoke(Taylor::class.'::test')); |
|
| 268 | 268 | |
| 269 | 269 | $object = $container->invokeClass(SomeClass::class); |
| 270 | 270 | $this->assertInstanceOf(SomeClass::class, $object); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | |
| 273 | 273 | $stdClass = new stdClass(); |
| 274 | 274 | |
| 275 | - $container->invoke(function (Container $container, stdClass $stdObject, $key1, $lowKey, $key2 = 'default') use ($stdClass) { |
|
| 275 | + $container->invoke(function(Container $container, stdClass $stdObject, $key1, $lowKey, $key2 = 'default') use ($stdClass) { |
|
| 276 | 276 | $this->assertEquals('value1', $key1); |
| 277 | 277 | $this->assertEquals('default', $key2); |
| 278 | 278 | $this->assertEquals('value2', $lowKey); |