@@ -98,7 +98,7 @@ class YamlRunnerTest extends \PHPUnit\Framework\TestCase
98
98
*
99
99
* @return string
100
100
*/
101
- public static function getHost ()
101
+ public static function getHost (): string
102
102
{
103
103
if (isset ($ _SERVER ['ES_TEST_HOST ' ]) === true ) {
104
104
return $ _SERVER ['ES_TEST_HOST ' ];
@@ -136,7 +136,7 @@ public function setUp()
136
136
* @dataProvider yamlProvider
137
137
* @group sync
138
138
*/
139
- public function testIntegration ($ testProcedure , $ skip , $ setupProcedure , $ fileName )
139
+ public function testIntegration ($ testProcedure , bool $ skip , $ setupProcedure , string $ fileName )
140
140
{
141
141
if ($ skip ) {
142
142
static ::markTestIncomplete ($ testProcedure );
@@ -158,7 +158,7 @@ public function testIntegration($testProcedure, $skip, $setupProcedure, $fileNam
158
158
* @dataProvider yamlProvider
159
159
* @group async
160
160
*/
161
- public function testAsyncIntegration ($ testProcedure , $ skip , $ setupProcedure , $ fileName )
161
+ public function testAsyncIntegration ($ testProcedure , bool $ skip , $ setupProcedure , string $ fileName )
162
162
{
163
163
if ($ skip ) {
164
164
static ::markTestIncomplete ($ testProcedure );
@@ -179,11 +179,12 @@ public function testAsyncIntegration($testProcedure, $skip, $setupProcedure, $fi
179
179
/**
180
180
* Process a procedure
181
181
*
182
- * @param $procedure
183
- * @param $name
182
+ * @param array $procedure
183
+ * @param string $name
184
+ * @param string $fileName
184
185
* @param bool $async
185
186
*/
186
- public function processProcedure ($ procedure , $ name , $ fileName , $ async = false )
187
+ public function processProcedure (array $ procedure , string $ name , string $ fileName , bool $ async = false )
187
188
{
188
189
$ lastOperationResult = null ;
189
190
$ context = [];
@@ -208,7 +209,7 @@ public function processProcedure($procedure, $name, $fileName, $async = false)
208
209
*
209
210
* @return mixed
210
211
*/
211
- public function processOperation ($ operation , $ lastOperationResult , &$ context , $ testName , $ async = false )
212
+ public function processOperation ($ operation , $ lastOperationResult , array &$ context , string $ testName , bool $ async = false )
212
213
{
213
214
$ operationName = array_keys ((array )$ operation )[0 ];
214
215
@@ -265,14 +266,14 @@ public function processOperation($operation, $lastOperationResult, &$context, $t
265
266
* @param $operation
266
267
* @param $lastOperationResult
267
268
* @param array $context
268
- * @param $testName
269
+ * @param string $testName
269
270
* @param bool $async
270
271
*
271
272
* @throws \Exception
272
273
*
273
274
* @return mixed
274
275
*/
275
- public function operationDo ($ operation , $ lastOperationResult , &$ context , $ testName , $ async = false )
276
+ public function operationDo ($ operation , $ lastOperationResult , &$ context , string $ testName , bool $ async = false )
276
277
{
277
278
$ expectedError = null ;
278
279
$ expectedWarnings = null ;
@@ -362,7 +363,7 @@ public function operationDo($operation, $lastOperationResult, &$context, $testNa
362
363
* Obtain the response from the server
363
364
*
364
365
* @param $caller
365
- * @param $method
366
+ * @param string $method
366
367
* @param $endpointParams
367
368
* @param $expectedError
368
369
* @param $testName
@@ -371,7 +372,7 @@ public function operationDo($operation, $lastOperationResult, &$context, $testNa
371
372
*
372
373
* @return array|mixed
373
374
*/
374
- public function executeRequest ($ caller , $ method , $ endpointParams , $ expectedError , $ expectedWarnings , $ testName )
375
+ public function executeRequest ($ caller , string $ method , $ endpointParams , $ expectedError , $ expectedWarnings , string $ testName )
375
376
{
376
377
try {
377
378
$ response = $ caller ->$ method ($ endpointParams );
@@ -407,7 +408,7 @@ public function executeRequest($caller, $method, $endpointParams, $expectedError
407
408
*
408
409
* @throws \Exception
409
410
*
410
- * @return bool|mixed[]
411
+ * @return bool|mixed[]|null
411
412
*/
412
413
public function executeAsyncExistRequest ($ caller , $ method , $ endpointParams , $ expectedError , $ expectedWarnings , $ testName )
413
414
{
@@ -480,11 +481,11 @@ public function checkForWarnings($expectedWarnings)
480
481
/**
481
482
* Check if a field in the last operation is false
482
483
*
483
- * @param $operation
484
+ * @param string $operation
484
485
* @param $lastOperationResult
485
- * @param $testName
486
+ * @param string $testName
486
487
*/
487
- public function operationIsFalse ($ operation , $ lastOperationResult , &$ context , $ testName )
488
+ public function operationIsFalse (string $ operation , $ lastOperationResult , &$ context , string $ testName )
488
489
{
489
490
$ value = (bool )$ this ->resolveValue ($ lastOperationResult , $ operation , $ context );
490
491
$ msg = "Failed to assert that a value is false in test \"$ testName \"\n"
@@ -500,9 +501,9 @@ public function operationIsFalse($operation, $lastOperationResult, &$context, $t
500
501
*
501
502
* @param $operation
502
503
* @param $lastOperationResult
503
- * @param $testName
504
+ * @param string $testName
504
505
*/
505
- public function operationIsTrue ($ operation , $ lastOperationResult , &$ context , $ testName )
506
+ public function operationIsTrue (string $ operation , $ lastOperationResult , &$ context , string $ testName )
506
507
{
507
508
$ value = $ this ->resolveValue ($ lastOperationResult , $ operation , $ context );
508
509
@@ -522,9 +523,9 @@ public function operationIsTrue($operation, $lastOperationResult, &$context, $te
522
523
*
523
524
* @param $operation
524
525
* @param $lastOperationResult
525
- * @param $testName
526
+ * @param string $testName
526
527
*/
527
- public function operationMatch ($ operation , $ lastOperationResult , &$ context , $ testName )
528
+ public function operationMatch ($ operation , $ lastOperationResult , &$ context , string $ testName )
528
529
{
529
530
$ key = key ($ operation );
530
531
@@ -558,9 +559,9 @@ public function operationMatch($operation, $lastOperationResult, &$context, $tes
558
559
*
559
560
* @param $operation
560
561
* @param $lastOperationResult
561
- * @param $testName
562
+ * @param string $testName
562
563
*/
563
- public function operationGreaterThanOrEqual ($ operation , $ lastOperationResult , &$ context , $ testName )
564
+ public function operationGreaterThanOrEqual ($ operation , $ lastOperationResult , &$ context , string $ testName )
564
565
{
565
566
$ value = $ this ->resolveValue ($ lastOperationResult , key ($ operation ), $ context );
566
567
$ expected = current ($ operation );
@@ -575,9 +576,9 @@ public function operationGreaterThanOrEqual($operation, $lastOperationResult, &$
575
576
*
576
577
* @param $operation
577
578
* @param $lastOperationResult
578
- * @param $testName
579
+ * @param string $testName
579
580
*/
580
- public function operationGreaterThan ($ operation , $ lastOperationResult , &$ context , $ testName )
581
+ public function operationGreaterThan ($ operation , $ lastOperationResult , &$ context , string $ testName )
581
582
{
582
583
$ value = $ this ->resolveValue ($ lastOperationResult , key ($ operation ), $ context );
583
584
$ expected = current ($ operation );
@@ -592,9 +593,9 @@ public function operationGreaterThan($operation, $lastOperationResult, &$context
592
593
*
593
594
* @param $operation
594
595
* @param $lastOperationResult
595
- * @param $testName
596
+ * @param string $testName
596
597
*/
597
- public function operationLessThanOrEqual ($ operation , $ lastOperationResult , &$ context , $ testName )
598
+ public function operationLessThanOrEqual ($ operation , $ lastOperationResult , &$ context , string $ testName )
598
599
{
599
600
$ value = $ this ->resolveValue ($ lastOperationResult , key ($ operation ), $ context );
600
601
$ expected = current ($ operation );
@@ -609,9 +610,9 @@ public function operationLessThanOrEqual($operation, $lastOperationResult, &$con
609
610
*
610
611
* @param $operation
611
612
* @param $lastOperationResult
612
- * @param $testName
613
+ * @param string $testName
613
614
*/
614
- public function operationLessThan ($ operation , $ lastOperationResult , &$ context , $ testName )
615
+ public function operationLessThan ($ operation , $ lastOperationResult , &$ context , string $ testName )
615
616
{
616
617
$ value = $ this ->resolveValue ($ lastOperationResult , key ($ operation ), $ context );
617
618
$ expected = current ($ operation );
@@ -626,9 +627,9 @@ public function operationLessThan($operation, $lastOperationResult, &$context, $
626
627
*
627
628
* @param $operation
628
629
* @param $lastOperationResult
629
- * @param $testName
630
+ * @param string $testName
630
631
*/
631
- public function operationLength ($ operation , $ lastOperationResult , &$ context , $ testName )
632
+ public function operationLength ($ operation , $ lastOperationResult , &$ context , string $ testName )
632
633
{
633
634
$ value = $ this ->resolveValue ($ lastOperationResult , key ($ operation ), $ context );
634
635
$ expected = current ($ operation );
@@ -644,9 +645,9 @@ public function operationLength($operation, $lastOperationResult, &$context, $te
644
645
* @param $operation
645
646
* @param $lastOperationResult
646
647
* @param $context
647
- * @param $testName
648
+ * @param string $testName
648
649
*/
649
- public function operationSet ($ operation , $ lastOperationResult , &$ context , $ testName )
650
+ public function operationSet ($ operation , $ lastOperationResult , &$ context , string $ testName )
650
651
{
651
652
$ key = key ($ operation );
652
653
$ value = $ this ->resolveValue ($ lastOperationResult , $ key , $ context );
@@ -662,9 +663,9 @@ public function operationSet($operation, $lastOperationResult, &$context, $testN
662
663
*
663
664
* @param $operation
664
665
* @param $lastOperationResult
665
- * @param $testName
666
+ * @param string $testName
666
667
*/
667
- public function operationSkip ($ operation , $ lastOperationResult , $ testName )
668
+ public function operationSkip ($ operation , $ lastOperationResult , string $ testName )
668
669
{
669
670
if (is_object ($ operation ) !== true ) {
670
671
return $ lastOperationResult ;
@@ -711,12 +712,12 @@ public function operationSkip($operation, $lastOperationResult, $testName)
711
712
* Assert an expected error
712
713
*
713
714
* @param \Exception $exception
714
- * @param $expectedError
715
- * @param $testName
715
+ * @param string $expectedError
716
+ * @param string $testName
716
717
*
717
- * @return array
718
+ * @return array|null
718
719
*/
719
- private function assertException (\Exception $ exception , $ expectedError , $ testName )
720
+ private function assertException (\Exception $ exception , string $ expectedError , string $ testName )
720
721
{
721
722
if (is_string ($ expectedError ) && preg_match ('#^/.+?/$# ' , $ expectedError )) {
722
723
$ this ->assertRegExp ($ expectedError , $ exception ->getMessage (), 'Failed to catch error in test ' . $ testName );
@@ -754,7 +755,7 @@ private function assertException(\Exception $exception, $expectedError, $testNam
754
755
*
755
756
* @return array
756
757
*/
757
- public function yamlProvider ()
758
+ public function yamlProvider (): array
758
759
{
759
760
$ this ->yaml = new Yaml ();
760
761
$ path = __DIR__ . '/../../../util/elasticsearch/rest-api-spec/src/main/resources/rest-api-spec/test ' ;
@@ -786,7 +787,7 @@ public function yamlProvider()
786
787
*
787
788
* @return array
788
789
*/
789
- private function mapEndpoint ($ method , $ namespace = null )
790
+ private function mapEndpoint (string $ method , $ namespace = null ): array
790
791
{
791
792
if (null === $ namespace && array_key_exists ($ method , static ::$ endpointMapping )) {
792
793
return static ::$ endpointMapping [$ method ];
@@ -875,11 +876,11 @@ private function resolveValue($result, $field, &$context)
875
876
/**
876
877
* Format a regex for PHP
877
878
*
878
- * @param $regex
879
+ * @param string $regex
879
880
*
880
881
* @return string
881
882
*/
882
- private function formatRegex ($ regex )
883
+ private function formatRegex (string $ regex ): string
883
884
{
884
885
$ regex = trim ($ regex );
885
886
$ regex = substr ($ regex , 1 , -1 );
@@ -897,9 +898,8 @@ private function formatRegex($regex)
897
898
*
898
899
* @return array
899
900
*/
900
- private function splitDocument ($ file , $ path , $ filter = null )
901
+ private function splitDocument (SplFileInfo $ file , string $ path , string $ filter = null ): array
901
902
{
902
-
903
903
$ fileContent = $ file ->getContents ();
904
904
// cleanup some bad comments
905
905
$ fileContent = str_replace ('"# ' , '" # ' , $ fileContent );
@@ -1045,7 +1045,7 @@ private function clean()
1045
1045
$ this ->waitForYellow ();
1046
1046
}
1047
1047
1048
- private function rmDirRecursively ($ dir )
1048
+ private function rmDirRecursively (string $ dir )
1049
1049
{
1050
1050
if (!is_dir ($ dir )) {
1051
1051
return ;
0 commit comments