44
55namespace Codeception \Module \Laravel ;
66
7+ use Illuminate \Contracts \Foundation \Application ;
8+
79trait InteractsWithContainer
810{
911 /**
1012 * Clear the registered application handlers.
1113 *
12- * ``` php
14+ * ```php
1315 * <?php
1416 * $I->clearApplicationHandlers();
1517 * ```
@@ -21,19 +23,17 @@ public function clearApplicationHandlers(): void
2123
2224 /**
2325 * Provides access the Laravel application object.
24- *
25- * @return \Illuminate\Contracts\Foundation\Application
2626 */
27- public function getApplication ()
27+ public function getApplication (): Application
2828 {
2929 return $ this ->app ;
3030 }
3131
3232 /**
3333 * Return an instance of a class from the Laravel service container.
34- * (https://laravel.com/docs/master /container)
34+ * (https://laravel.com/docs/7.x /container)
3535 *
36- * ``` php
36+ * ```php
3737 * <?php
3838 * // In Laravel
3939 * App::bind('foo', function($app) {
@@ -46,7 +46,6 @@ public function getApplication()
4646 * // Will return an instance of FooBar, also works for singletons.
4747 * ```
4848 *
49- * @param string $class
5049 * @return mixed
5150 */
5251 public function grabService (string $ class )
@@ -58,14 +57,12 @@ public function grabService(string $class)
5857 * Register a handler than can be used to modify the Laravel application object after it is initialized.
5958 * The Laravel application object will be passed as an argument to the handler.
6059 *
61- * ``` php
60+ * ```php
6261 * <?php
6362 * $I->haveApplicationHandler(function($app) {
6463 * $app->make('config')->set(['test_value' => '10']);
6564 * });
6665 * ```
67- *
68- * @param callable $handler
6966 */
7067 public function haveApplicationHandler (callable $ handler ): void
7168 {
@@ -74,9 +71,9 @@ public function haveApplicationHandler(callable $handler): void
7471
7572 /**
7673 * Add a binding to the Laravel service container.
77- * (https://laravel.com/docs/master /container)
74+ * (https://laravel.com/docs/7.x /container)
7875 *
79- * ``` php
76+ * ```php
8077 * <?php
8178 * $I->haveBinding('My\Interface', 'My\Implementation');
8279 * ```
@@ -92,9 +89,9 @@ public function haveBinding(string $abstract, $concrete = null, bool $shared = f
9289
9390 /**
9491 * Add a contextual binding to the Laravel service container.
95- * (https://laravel.com/docs/master /container)
92+ * (https://laravel.com/docs/7.x /container)
9693 *
97- * ``` php
94+ * ```php
9895 * <?php
9996 * $I->haveContextualBinding('My\Class', '$variable', 'value');
10097 *
@@ -115,26 +112,23 @@ public function haveContextualBinding(string $concrete, string $abstract, $imple
115112
116113 /**
117114 * Add an instance binding to the Laravel service container.
118- * (https://laravel.com/docs/master /container)
115+ * (https://laravel.com/docs/7.x /container)
119116 *
120- * ``` php
117+ * ```php
121118 * <?php
122119 * $I->haveInstance('App\MyClass', new App\MyClass());
123120 * ```
124- *
125- * @param string $abstract
126- * @param mixed $instance
127121 */
128- public function haveInstance (string $ abstract , $ instance ): void
122+ public function haveInstance (string $ abstract , object $ instance ): void
129123 {
130124 $ this ->client ->haveInstance ($ abstract , $ instance );
131125 }
132126
133127 /**
134128 * Add a singleton binding to the Laravel service container.
135- * (https://laravel.com/docs/master /container)
129+ * (https://laravel.com/docs/7.x /container)
136130 *
137- * ``` php
131+ * ```php
138132 * <?php
139133 * $I->haveSingleton('App\MyInterface', 'App\MySingleton');
140134 * ```
@@ -147,10 +141,7 @@ public function haveSingleton(string $abstract, $concrete): void
147141 $ this ->client ->haveBinding ($ abstract , $ concrete , true );
148142 }
149143
150- /**
151- * @param \Illuminate\Contracts\Foundation\Application $app
152- */
153- public function setApplication ($ app ): void
144+ public function setApplication (Application $ app ): void
154145 {
155146 $ this ->app = $ app ;
156147 }
0 commit comments