Skip to content

Commit fb42b7c

Browse files
committed
add more return type declare
1 parent 639d8bc commit fb42b7c

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

src/CallableResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(ContainerInterface $container)
4444
* @throws RuntimeException if the callable does not exist
4545
* @throws RuntimeException if the callable is not resolvable
4646
*/
47-
public function resolve($toResolve)
47+
public function resolve($toResolve): callable
4848
{
4949
if (\is_callable($toResolve)) {
5050
return $toResolve;
@@ -79,7 +79,7 @@ public function resolve($toResolve)
7979
* @throws \InvalidArgumentException
8080
* @throws \RuntimeException if the callable does not exist
8181
*/
82-
private function resolveCallable($class, $method = '__invoke')
82+
private function resolveCallable($class, $method = '__invoke'): callable
8383
{
8484
if ($cb = $this->container->getIfExist($class)) {
8585
return [$cb, $method];

src/CallableResolverAwareTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ trait CallableResolverAwareTrait
3131
* @throws \Psr\Container\ContainerExceptionInterface
3232
* @throws \RuntimeException If the string cannot be resolved as a callable
3333
*/
34-
protected function resolveCallable($callable)
34+
protected function resolveCallable($callable): callable
3535
{
3636
if (!$this->container instanceof ContainerInterface) {
3737
return $callable;

src/Container.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function __destruct()
100100
* @return $this
101101
* @throws DependencyResolutionException
102102
*/
103-
public function set(string $id, $definition, array $opts = [])
103+
public function set(string $id, $definition, array $opts = []): self
104104
{
105105
$id = $this->_checkServiceId($id);
106106

@@ -180,7 +180,7 @@ public function set(string $id, $definition, array $opts = [])
180180
* @throws \InvalidArgumentException
181181
* @throws DependencyResolutionException
182182
*/
183-
public function sets(array $services)
183+
public function sets(array $services): self
184184
{
185185
foreach ($services as $id => $definition) {
186186
if (!$definition) {
@@ -212,7 +212,7 @@ public function sets(array $services)
212212
* @throws \InvalidArgumentException
213213
* @throws DependencyResolutionException
214214
*/
215-
public function protect(string $id, $definition, $share = false)
215+
public function protect(string $id, $definition, $share = false): self
216216
{
217217
return $this->lock($id, $definition, $share);
218218
}
@@ -226,7 +226,7 @@ public function protect(string $id, $definition, $share = false)
226226
* @throws DependencyResolutionException
227227
* @throws \InvalidArgumentException
228228
*/
229-
public function lock(string $id, $definition, $share = false)
229+
public function lock(string $id, $definition, $share = false): self
230230
{
231231
return $this->set($id, $definition, [
232232
'shared' => $share,
@@ -239,7 +239,7 @@ public function lock(string $id, $definition, $share = false)
239239
* @param ServiceProviderInterface $provider 在提供者内添加需要的服务到容器
240240
* @return $this
241241
*/
242-
public function registerServiceProvider(ServiceProviderInterface $provider)
242+
public function registerServiceProvider(ServiceProviderInterface $provider): self
243243
{
244244
$provider->register($this);
245245

@@ -250,7 +250,7 @@ public function registerServiceProvider(ServiceProviderInterface $provider)
250250
* @param array $providers
251251
* @return $this
252252
*/
253-
public function registerServiceProviders(array $providers)
253+
public function registerServiceProviders(array $providers): self
254254
{
255255
/** @var ServiceProviderInterface $provider */
256256
foreach ($providers as $provider) {

src/DIManager.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final class DIManager
3333
/**
3434
* @return Container
3535
*/
36-
public static function getDefault()
36+
public static function getDefault(): Container
3737
{
3838
return self::make('root', self::$defaultGroup);
3939
}
@@ -42,7 +42,7 @@ public static function getDefault()
4242
* @param null|string $name
4343
* @return Container
4444
*/
45-
public static function getContainer(string $name = null)
45+
public static function getContainer(string $name = null): Container
4646
{
4747
return self::make($name);
4848
}
@@ -52,7 +52,7 @@ public static function getContainer(string $name = null)
5252
* @param string $group
5353
* @return Container
5454
*/
55-
public static function make(string $name = null, string $group = null)
55+
public static function make(string $name = null, string $group = null): Container
5656
{
5757
$group = $group ?: self::$defaultGroup;
5858

@@ -100,7 +100,7 @@ public static function setDefaultGroup($group = 'di')
100100
* Method to get property Profile
101101
* @return string
102102
*/
103-
public static function getDefaultGroup()
103+
public static function getDefaultGroup(): string
104104
{
105105
return static::$defaultGroup;
106106
}

src/NameAliasTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function getAliases(): array
8686
* @param array $aliases
8787
* @return $this
8888
*/
89-
public function setAliases(array $aliases)
89+
public function setAliases(array $aliases): self
9090
{
9191
$this->aliases = $aliases;
9292

test/MakeByMethod.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
class MakeByMethod
1616
{
17-
public function factory(array $options = [])
17+
public function factory(array $options = []): SomeClass
1818
{
1919
return new SomeClass($options);
2020
}

test/MakeByStatic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
class MakeByStatic
1616
{
17-
public static function factory(array $options = [])
17+
public static function factory(array $options = []): SomeClass
1818
{
1919
return new SomeClass($options);
2020
}

0 commit comments

Comments
 (0)