@@ -33,13 +33,13 @@ public static function tearDownAfterClass(): void
3333 * @param mixed $default default value to use when param is not set.
3434 * @return mixed the value of the configuration param
3535 */
36- public static function getParam ($ name , $ default = null )
36+ public static function getParam ($ name , mixed $ default = null )
3737 {
3838 if (static ::$ params === null ) {
3939 static ::$ params = require __DIR__ . '/data/config.php ' ;
4040 }
4141
42- return isset ( static ::$ params [$ name ]) ? static :: $ params [ $ name ] : $ default ;
42+ return static ::$ params [$ name ] ?? $ default ;
4343 }
4444
4545 /**
@@ -90,9 +90,9 @@ protected function mockWebApplication($config = [], $appClass = '\yii\web\Applic
9090
9191 protected function getVendorPath ()
9292 {
93- $ vendor = dirname (dirname ( __DIR__ ) ) . '/vendor ' ;
93+ $ vendor = dirname (__DIR__ , 2 ) . '/vendor ' ;
9494 if (!is_dir ($ vendor )) {
95- $ vendor = dirname (dirname ( dirname ( dirname ( __DIR__ ))) );
95+ $ vendor = dirname (__DIR__ , 4 );
9696 }
9797
9898 return $ vendor ;
@@ -141,11 +141,9 @@ protected function assertEqualsAnyWhitespace($expected, $actual, $message = ''){
141141 * Used on objects, it asserts that two variables reference
142142 * the same object.
143143 *
144- * @param mixed $expected
145- * @param mixed $actual
146144 * @param string $message
147145 */
148- protected function assertSameAnyWhitespace ($ expected , $ actual , $ message = '' ){
146+ protected function assertSameAnyWhitespace (mixed $ expected , mixed $ actual , $ message = '' ){
149147 if (is_string ($ expected )) {
150148 $ expected = $ this ->sanitizeWhitespaces ($ expected );
151149 }
@@ -159,14 +157,12 @@ protected function assertSameAnyWhitespace($expected, $actual, $message = ''){
159157 /**
160158 * Asserts that a haystack contains a needle ignoring line endings.
161159 *
162- * @param mixed $needle
163- * @param mixed $haystack
164160 * @param string $message
165161 */
166- protected function assertContainsWithoutLE ($ needle , $ haystack , $ message = '' )
162+ protected function assertContainsWithoutLE (mixed $ needle , mixed $ haystack , $ message = '' )
167163 {
168- $ needle = str_replace ("\r\n" , "\n" , $ needle );
169- $ haystack = str_replace ("\r\n" , "\n" , $ haystack );
164+ $ needle = str_replace ("\r\n" , "\n" , ( string ) $ needle );
165+ $ haystack = str_replace ("\r\n" , "\n" , ( string ) $ haystack );
170166
171167 $ this ->assertStringContainsString ($ needle , $ haystack , $ message );
172168 }
@@ -179,7 +175,7 @@ protected function assertContainsWithoutLE($needle, $haystack, $message = '')
179175 * @return string
180176 */
181177 protected function sanitizeWhitespaces ($ string ){
182- return preg_replace ("/[\pZ\pC]/u " , " " , $ string );
178+ return preg_replace ("/[\pZ\pC]/u " , " " , ( string ) $ string );
183179 }
184180
185181 /**
@@ -253,11 +249,9 @@ protected function getInaccessibleProperty($object, $propertyName, $revoke = tru
253249 /**
254250 * Asserts that value is one of expected values.
255251 *
256- * @param mixed $actual
257- * @param array $expected
258252 * @param string $message
259253 */
260- public function assertIsOneOf ($ actual , array $ expected , $ message = '' )
254+ public function assertIsOneOf (mixed $ actual , array $ expected , $ message = '' ): void
261255 {
262256 self ::assertThat ($ actual , new IsOneOfAssert ($ expected ), $ message );
263257 }
@@ -272,9 +266,9 @@ protected function switchDbConnection($db)
272266 if (isset ($ databases [$ db ])) {
273267 $ database = $ databases [$ db ];
274268 Yii::$ app ->db ->close ();
275- Yii::$ app ->db ->dsn = isset ( $ database ['dsn ' ]) ? $ database [ ' dsn ' ] : null ;
276- Yii::$ app ->db ->username = isset ( $ database ['username ' ]) ? $ database [ ' username ' ] : null ;
277- Yii::$ app ->db ->password = isset ( $ database ['password ' ]) ? $ database [ ' password ' ] : null ;
269+ Yii::$ app ->db ->dsn = $ database ['dsn ' ] ?? null ;
270+ Yii::$ app ->db ->username = $ database ['username ' ] ?? null ;
271+ Yii::$ app ->db ->password = $ database ['password ' ] ?? null ;
278272 }
279273 }
280274}
0 commit comments