diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index be2babe7f..23a167e7a 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,6 +1,9 @@ exclude('app/cdash/config') ->exclude('bootstrap/cache') ->exclude('node_modules') @@ -9,23 +12,25 @@ ->exclude('_build') ->exclude('resources') ->exclude('public') + ->exclude('app/cdash/tests/kwtest/simpletest') ->notPath('app/cdash/tests/config.test.local.php') - ->in(__DIR__) -; + ->in(__DIR__); -$config = new PhpCsFixer\Config(); +$config = new Config(); return $config->setRules([ - '@PSR12' => true, - '@PHP82Migration' => true, - '@Symfony' => true, - 'yoda_style' => false, - 'blank_line_before_statement' => false, - 'phpdoc_summary' => false, - 'concat_space' => ['spacing' => 'one'], - 'increment_style' => ['style' => 'post'], - 'fully_qualified_strict_types' => ['import_symbols' => true], - 'global_namespace_import' => ['import_classes' => true, 'import_constants' => null, 'import_functions' => null], - 'phpdoc_align' => ['align' => 'left'], - ]) - ->setFinder($finder) -; + '@PSR12' => true, + '@PSR12:risky' => true, + '@PHP82Migration' => true, + '@PHP82Migration:risky' => true, + '@Symfony' => true, + 'yoda_style' => false, + 'blank_line_before_statement' => false, + 'phpdoc_summary' => false, + 'concat_space' => ['spacing' => 'one'], + 'increment_style' => ['style' => 'post'], + 'fully_qualified_strict_types' => ['import_symbols' => true], + 'global_namespace_import' => ['import_classes' => true, 'import_constants' => null, 'import_functions' => null], + 'phpdoc_align' => ['align' => 'left'], + 'declare_strict_types' => false, // TODO: turn this back on. Currently causes errors... + 'void_return' => false, // TODO: turn this back on. Currently causes errors... +])->setFinder($finder); diff --git a/app/Http/Controllers/BuildController.php b/app/Http/Controllers/BuildController.php index 667717427..7814e3396 100644 --- a/app/Http/Controllers/BuildController.php +++ b/app/Http/Controllers/BuildController.php @@ -666,9 +666,7 @@ public function viewUpdatePageContent(): JsonResponse $directoryarray = array_unique($directoryarray); - usort($directoryarray, function ($a, $b) { - return $a > $b ? 1 : 0; - }); + usort($directoryarray, fn ($a, $b) => $a > $b ? 1 : 0); usort($updatearray1, function ($a, $b) { // Extract directory $filenamea = $a['filename']; @@ -1009,9 +1007,7 @@ public function apiViewBuildError(): JsonResponse } if ($this->build->IsParentBuild()) { - $response['numSubprojects'] = count(array_unique(array_map(function ($buildError) { - return $buildError['subprojectid']; - }, $response['errors']))); + $response['numSubprojects'] = count(array_unique(array_map(fn ($buildError) => $buildError['subprojectid'], $response['errors']))); } $pageTimer->end($response); diff --git a/app/Http/Controllers/BuildPropertiesController.php b/app/Http/Controllers/BuildPropertiesController.php index faacfd5a7..7e24493cb 100644 --- a/app/Http/Controllers/BuildPropertiesController.php +++ b/app/Http/Controllers/BuildPropertiesController.php @@ -116,9 +116,7 @@ public function apiBuildProperties(): JsonResponse } $response['defecttypes'] = $defect_types; - $defect_types = array_filter($defect_types, function ($defect_type) { - return $defect_type['selected']; - }); + $defect_types = array_filter($defect_types, fn ($defect_type) => $defect_type['selected']); // Construct an SQL SELECT clause for the requested types of defects. $defect_keys = []; diff --git a/app/Http/Controllers/CoverageController.php b/app/Http/Controllers/CoverageController.php index 382bac15a..25721ca5f 100644 --- a/app/Http/Controllers/CoverageController.php +++ b/app/Http/Controllers/CoverageController.php @@ -1794,9 +1794,7 @@ public function apiCompareCoverage(): JsonResponse if (!empty($subproject_groups)) { // At this point it is safe to remove any empty $coveragegroups from our response. - $coveragegroups_response = array_filter($coveragegroups, function ($group) { - return $group['label'] === 'Total' || !empty($group['coverages']); - }); + $coveragegroups_response = array_filter($coveragegroups, fn ($group) => $group['label'] === 'Total' || !empty($group['coverages'])); // Report coveragegroups as a list, not an associative array. $coveragegroups_response = array_values($coveragegroups_response); diff --git a/app/Http/Controllers/RemoteProcessingController.php b/app/Http/Controllers/RemoteProcessingController.php index 5a22829d1..632f4f114 100644 --- a/app/Http/Controllers/RemoteProcessingController.php +++ b/app/Http/Controllers/RemoteProcessingController.php @@ -111,7 +111,7 @@ public function requeueSubmissionFile(): Response // Requeue the file with exponential backoff. PendingSubmissions::IncrementForBuildId($buildid); - $delay = (int) pow(config('cdash.retry_base'), $retry_handler->Retries); + $delay = ((int) config('cdash.retry_base')) ** $retry_handler->Retries; ProcessSubmission::dispatch($filename, $projectid, $buildid, md5_file(Storage::path("inbox/{$filename}")))->delay(now()->addSeconds($delay)); return response('OK', Response::HTTP_OK); } diff --git a/app/Jobs/ProcessSubmission.php b/app/Jobs/ProcessSubmission.php index bbd0ec77e..82f4e46cd 100644 --- a/app/Jobs/ProcessSubmission.php +++ b/app/Jobs/ProcessSubmission.php @@ -116,7 +116,7 @@ private function requeueSubmissionFile($buildid): bool // Requeue the file with exponential backoff. PendingSubmissions::IncrementForBuildId($this->buildid); - $delay = pow(config('cdash.retry_base'), $retry_handler->Retries); + $delay = ((int) config('cdash.retry_base')) ** $retry_handler->Retries; if (config('queue.default') === 'sqs-fifo') { // Special handling for sqs-fifo, which does not support per-message delays. sleep(10); diff --git a/app/Utils/RepositoryUtils.php b/app/Utils/RepositoryUtils.php index 3ff53b2b7..1a7126369 100644 --- a/app/Utils/RepositoryUtils.php +++ b/app/Utils/RepositoryUtils.php @@ -709,7 +709,7 @@ public static function linkify_compiler_output($projecturl, $source_dir, $revisi } // Make sure we specify a protocol so this isn't interpreted as a relative path. - if (strpos($projecturl, '//') === false) { + if (!str_contains($projecturl, '//')) { $projecturl = '//' . $projecturl; } $repo_link = "limitSQL; $builds = DB::select($sql, $query_params); - return array_map(function ($item) { - return (array) $item; - }, $builds); + return array_map(fn ($item) => (array) $item, $builds); } public function getDynamicBuilds(): array diff --git a/app/cdash/app/Controller/Api/QueryTests.php b/app/cdash/app/Controller/Api/QueryTests.php index bb4c03683..7c1ad4d38 100644 --- a/app/cdash/app/Controller/Api/QueryTests.php +++ b/app/cdash/app/Controller/Api/QueryTests.php @@ -86,7 +86,7 @@ private function rowSurvivesTestOutputFilter($row, &$build) $match_length = 0; foreach ($this->testOutputExclude as $exclude) { - if (strpos($test_output, $exclude) !== false) { + if (str_contains($test_output, $exclude)) { return false; } } diff --git a/app/cdash/app/Controller/Api/TestOverview.php b/app/cdash/app/Controller/Api/TestOverview.php index ead663ab8..afb4bb91d 100644 --- a/app/cdash/app/Controller/Api/TestOverview.php +++ b/app/cdash/app/Controller/Api/TestOverview.php @@ -163,7 +163,7 @@ public function getResponse() if ($status === 'passed') { $all_tests[$test_name]['passed']++; - } elseif (strpos($row['details'], 'Timeout') !== false) { + } elseif (str_contains($row['details'], 'Timeout')) { $all_tests[$test_name]['timeout']++; } else { $all_tests[$test_name]['failed']++; diff --git a/app/cdash/app/Lib/Repository/GitHub.php b/app/cdash/app/Lib/Repository/GitHub.php index e1a8b4b31..c7207e379 100644 --- a/app/cdash/app/Lib/Repository/GitHub.php +++ b/app/cdash/app/Lib/Repository/GitHub.php @@ -75,7 +75,7 @@ public function __construct(Project $project) $repositories = $this->project->GetRepositories(); foreach ($repositories as $repo) { - if (strpos($repo['url'], 'github.com') !== false) { + if (str_contains($repo['url'], 'github.com')) { $this->installationId = $repo['username']; break; } @@ -182,9 +182,7 @@ public function setStatus($options): void } $commitHash = $options['commit_hash']; - $params = array_filter($options, function ($key) { - return in_array($key, ['state', 'context', 'description', 'target_url'], true); - }, ARRAY_FILTER_USE_KEY); + $params = array_filter($options, fn ($key) => in_array($key, ['state', 'context', 'description', 'target_url'], true), ARRAY_FILTER_USE_KEY); $statuses = $this->apiClient ->api('repo') @@ -256,9 +254,7 @@ public function dedupeAndSortBuildRows($rows) } $build_names[$build_name][] = $row; } - $build_names = array_filter($build_names, function ($k, $v) { - return count($k) > 1; - }, ARRAY_FILTER_USE_BOTH); + $build_names = array_filter($build_names, fn ($k, $v) => count($k) > 1, ARRAY_FILTER_USE_BOTH); // Find the ids of all the older builds that should not be included // in our report. @@ -293,9 +289,7 @@ public function dedupeAndSortBuildRows($rows) } // Alphabetize this array by build name. - usort($output_rows, function ($a, $b) { - return strcmp((string) $a['name'], (string) $b['name']); - }); + usort($output_rows, fn ($a, $b) => strcmp((string) $a['name'], (string) $b['name'])); return $output_rows; } diff --git a/app/cdash/app/Model/BuildErrorFilter.php b/app/cdash/app/Model/BuildErrorFilter.php index 0c5233636..35516af35 100644 --- a/app/cdash/app/Model/BuildErrorFilter.php +++ b/app/cdash/app/Model/BuildErrorFilter.php @@ -120,7 +120,7 @@ private function FilterText($subject, $filterString) { if ($filterString) { foreach (preg_split("/\R/", $filterString) as $filter) { - if (strpos($subject, $filter) !== false) { + if (str_contains($subject, $filter)) { return true; } } diff --git a/app/cdash/app/Model/BuildUpdate.php b/app/cdash/app/Model/BuildUpdate.php index 169149d7e..47c8858ec 100644 --- a/app/cdash/app/Model/BuildUpdate.php +++ b/app/cdash/app/Model/BuildUpdate.php @@ -425,9 +425,7 @@ public function FillFromBuildId(): bool $this->AddFile($file); } - usort($this->Files, function ($file1, $file2) { - return Str::afterLast('/', $file1->Filename) <=> Str::afterLast('/', $file2->Filename); - }); + usort($this->Files, fn ($file1, $file2) => Str::afterLast('/', $file1->Filename) <=> Str::afterLast('/', $file2->Filename)); return true; } diff --git a/app/cdash/app/Model/Repository.php b/app/cdash/app/Model/Repository.php index 4cc343b3e..5a083d47d 100644 --- a/app/cdash/app/Model/Repository.php +++ b/app/cdash/app/Model/Repository.php @@ -54,7 +54,7 @@ public static function getViewers() $self = new ReflectionClass(__CLASS__); $viewers = []; foreach ($self->getConstants() as $key => $text) { - if (strpos($key, 'VIEWER_') === 0) { + if (str_starts_with($key, 'VIEWER_')) { $value = strtolower(substr($key, strlen('VIEWER_'))); $viewers[$text] = $value; } diff --git a/app/cdash/include/Collection/CollectionCollection.php b/app/cdash/include/Collection/CollectionCollection.php index 862052d5c..e78ec38e0 100644 --- a/app/cdash/include/Collection/CollectionCollection.php +++ b/app/cdash/include/Collection/CollectionCollection.php @@ -24,7 +24,7 @@ class CollectionCollection extends Collection */ public function add(Collection $collection) { - $this->addItem($collection, get_class($collection)); + $this->addItem($collection, $collection::class); return $this; } } diff --git a/app/cdash/include/Collection/SubscriptionBuilderCollection.php b/app/cdash/include/Collection/SubscriptionBuilderCollection.php index 51f0cfd87..0a9d0d6dc 100644 --- a/app/cdash/include/Collection/SubscriptionBuilderCollection.php +++ b/app/cdash/include/Collection/SubscriptionBuilderCollection.php @@ -23,7 +23,7 @@ class SubscriptionBuilderCollection extends Collection { public function add(SubscriptionBuilderInterface $builder) { - $this->addItem($builder, get_class($builder)); + $this->addItem($builder, $builder::class); return $this; } } diff --git a/app/cdash/include/Test/UseCase/DynamicAnalysisUseCase.php b/app/cdash/include/Test/UseCase/DynamicAnalysisUseCase.php index cab2e9c43..98b1194eb 100644 --- a/app/cdash/include/Test/UseCase/DynamicAnalysisUseCase.php +++ b/app/cdash/include/Test/UseCase/DynamicAnalysisUseCase.php @@ -202,7 +202,7 @@ private function createResults(array &$properties): void $faker = $this->getFaker(); $num_defects = $faker->randomDigit; for ($i = 0; $i < $num_defects; $i++) { - $random = rand(0, 4); + $random = random_int(0, 4); $properties['Results'][] = [ 'type' => $posibilities[$random], 'value' => $faker->randomNumber(1), diff --git a/app/cdash/include/Test/UseCase/UpdateUseCase.php b/app/cdash/include/Test/UseCase/UpdateUseCase.php index 539fd3bd5..3b292fb03 100644 --- a/app/cdash/include/Test/UseCase/UpdateUseCase.php +++ b/app/cdash/include/Test/UseCase/UpdateUseCase.php @@ -289,7 +289,7 @@ public function createRevisionHash(): string public function randomizeCheckinDate(): string { - $random = rand(1, 9 * 60 * 60) + (9 * 60 * 60); // seconds between 8am and 5pm + $random = random_int(1, 9 * 60 * 60) + (9 * 60 * 60); // seconds between 8am and 5pm $time = strtotime("yesterday +{$random} seconds"); return date('Y-m-d H:i:s -0500', $time); } diff --git a/app/cdash/include/Test/UseCase/UseCase.php b/app/cdash/include/Test/UseCase/UseCase.php index 166f4d387..0bb2383a1 100644 --- a/app/cdash/include/Test/UseCase/UseCase.php +++ b/app/cdash/include/Test/UseCase/UseCase.php @@ -255,9 +255,7 @@ public function createChildElementsFromKeys(DOMElement $parent, array $attribute { $subset = array_filter( $attributes, - function ($key) use ($keys) { - return empty($keys) || in_array($key, $keys); - }, + fn ($key) => empty($keys) || in_array($key, $keys), ARRAY_FILTER_USE_KEY ); diff --git a/app/cdash/include/common.php b/app/cdash/include/common.php index 4f7f125b6..46af2c030 100644 --- a/app/cdash/include/common.php +++ b/app/cdash/include/common.php @@ -935,9 +935,7 @@ function extract_tar(string $filename, string $dirName): bool */ function deepEncodeHTMLEntities(&$structure): void { - $encode = function ($string) { - return htmlspecialchars($string, ENT_QUOTES, 'UTF-8', false); - }; + $encode = fn ($string) => htmlspecialchars($string, ENT_QUOTES, 'UTF-8', false); if (is_object($structure)) { $properties = get_object_vars($structure); diff --git a/app/cdash/include/dailyupdates.php b/app/cdash/include/dailyupdates.php index 9896a9cf6..277c77219 100644 --- a/app/cdash/include/dailyupdates.php +++ b/app/cdash/include/dailyupdates.php @@ -482,7 +482,7 @@ function get_svn_repository_commits($svnroot, $dates, $username = '', $password $previous_revision = ''; // Look if we have a A or a M - if (strpos(substr($ff, 0, 5), 'A') !== false) { + if (str_contains(substr($ff, 0, 5), 'A')) { $previous_revision = '-1'; // newly added file so we marked it as no prior revision } diff --git a/app/cdash/include/filterdataFunctions.php b/app/cdash/include/filterdataFunctions.php index ac1ec7a70..e44e9fae1 100644 --- a/app/cdash/include/filterdataFunctions.php +++ b/app/cdash/include/filterdataFunctions.php @@ -1160,7 +1160,7 @@ function generate_filter_sql($filter, $pageSpecificFilters) // Time durations can either be specified as a number of seconds, // or as a string representing a time interval. - if (strpos($field, 'duration') !== false) { + if (str_contains($field, 'duration')) { $input_value = trim($sql_value, "'"); $sql_value = get_seconds_from_interval($input_value); if ($input_value !== $sql_value && $field === 'updateduration') { diff --git a/app/cdash/tests/bootstrap.php b/app/cdash/tests/bootstrap.php index aef926d97..33fb1abe0 100644 --- a/app/cdash/tests/bootstrap.php +++ b/app/cdash/tests/bootstrap.php @@ -1,6 +1,6 @@ project->CvsUrl = 'https://github.com/foo/bar'; $this->project->expects($this->once()) ->method('GetRepositories') - ->willReturnCallback(function () { - return $this->repo; - }); + ->willReturnCallback(fn () => $this->repo); } public function testGetRepositoryInterfaceReturnsGitHubService() diff --git a/app/cdash/tests/cdash_test_case.php b/app/cdash/tests/cdash_test_case.php index 7b1969f3c..b7d732794 100644 --- a/app/cdash/tests/cdash_test_case.php +++ b/app/cdash/tests/cdash_test_case.php @@ -13,7 +13,7 @@ // of getcwd() value: // global $cdashpath; -$cdashpath = str_replace('\\', '/', dirname(dirname(__FILE__))); +$cdashpath = str_replace('\\', '/', dirname(__FILE__, 2)); set_include_path($cdashpath . PATH_SEPARATOR . get_include_path()); require_once 'tests/kwtest/kw_web_tester.php'; // KWWebTestCase diff --git a/app/cdash/tests/kwtest/kw_web_tester.php b/app/cdash/tests/kwtest/kw_web_tester.php index c9adb470d..f99ed24b2 100644 --- a/app/cdash/tests/kwtest/kw_web_tester.php +++ b/app/cdash/tests/kwtest/kw_web_tester.php @@ -105,7 +105,7 @@ public function tearDown() $this->stopCodeCoverage(); unset($_SERVER['Authorization']); foreach (array_keys($_SERVER) as $key) { - if (strpos($key, 'HTTP_') === 0) { + if (str_starts_with($key, 'HTTP_')) { unset($_SERVER[$key]); } } @@ -135,7 +135,7 @@ public function stopCodeCoverage() $file = config('cdash.coverage_dir') . DIRECTORY_SEPARATOR . md5($_SERVER['SCRIPT_FILENAME']); file_put_contents( - $file . '.' . md5(uniqid(rand(), true)) . '.' . get_class(), + $file . '.' . md5(uniqid(random_int(0, getrandmax()), true)) . '.' . get_class(), serialize($data) ); } @@ -151,7 +151,7 @@ public function stopCodeCoverage() */ public function findString($mystring, $findme) { - if (strpos($mystring, $findme) === false) { + if (!str_contains($mystring, $findme)) { return false; } return true; @@ -288,9 +288,7 @@ public function loginActingAs() $user = $this->getUser($this->actingAs['email']); Auth::shouldReceive('check')->andReturn(true); Auth::shouldReceive('user')->andReturn($user); - Auth::shouldReceive('userResolver')->andReturn(function () use ($user) { - return $user; - }); + Auth::shouldReceive('userResolver')->andReturn(fn () => $user); Auth::shouldReceive('id')->andReturn($user->id); Auth::shouldReceive('guard')->andReturnSelf(); Auth::shouldReceive('shouldUse')->andReturn('web'); @@ -582,7 +580,7 @@ public function expectsPageRequiresLogin($page) $this->logout(); $content = $this->get("{$this->url}{$page}"); - if (strpos($content, '
') === false) { + if (!str_contains($content, '')) { $this->fail('Login not found when expected'); return false; } @@ -718,7 +716,7 @@ private function setQueryParameters($url) if (!empty($query)) { foreach (explode('&', $query) as $parameter) { - if (strpos($parameter, '=') !== false) { + if (str_contains($parameter, '=')) { [$key, $value] = explode('=', $parameter); $this->setRequestKeyValuePair($parameters, $key, $value); } else { diff --git a/app/cdash/tests/manageCoverageTest.php b/app/cdash/tests/manageCoverageTest.php index 7613b5b2a..5523ddcd8 100644 --- a/app/cdash/tests/manageCoverageTest.php +++ b/app/cdash/tests/manageCoverageTest.php @@ -54,7 +54,7 @@ public function testManageCoverageTest() $this->login(); $content = $this->connect($this->url . "/manageCoverage.php?buildid=$buildid&projectid=$projectid"); - if (strpos($content, 'simple.cxx') === false) { + if (!str_contains($content, 'simple.cxx')) { $this->fail("'simple.cxx' not found when expected for buildid=" . $buildid); return 1; } diff --git a/app/cdash/tests/singletest.php b/app/cdash/tests/singletest.php index aea877723..165481498 100644 --- a/app/cdash/tests/singletest.php +++ b/app/cdash/tests/singletest.php @@ -11,7 +11,7 @@ require_once 'tests/kwtest/kw_test_manager.php'; $env_contents = file_get_contents(dirname(__FILE__) . '/../../../.env'); -if (strpos($env_contents, 'DB_DATABASE=cdash4simpletest') === false) { +if (!str_contains($env_contents, 'DB_DATABASE=cdash4simpletest')) { echo "We cannot test cdash because test database is not cdash4simpletest\n"; exit(1); } diff --git a/app/cdash/tests/test_attachedfiles.php b/app/cdash/tests/test_attachedfiles.php index c2f20541e..ed2fbf4d8 100644 --- a/app/cdash/tests/test_attachedfiles.php +++ b/app/cdash/tests/test_attachedfiles.php @@ -66,7 +66,7 @@ public function testAttachedFiles() } $contents = file_get_contents($decompressed_file); - $this->assertTrue(strpos($contents, 'This is my test output') !== false); + $this->assertTrue(str_contains($contents, 'This is my test output')); unlink($downloaded_file); unlink($decompressed_file); diff --git a/app/cdash/tests/test_authtoken.php b/app/cdash/tests/test_authtoken.php index 5623b3fb5..7d5a60346 100644 --- a/app/cdash/tests/test_authtoken.php +++ b/app/cdash/tests/test_authtoken.php @@ -159,7 +159,7 @@ public function normalSubmit($headers) $file = dirname(__FILE__) . '/data/InsightExperimentalExample/Insight_Experimental_Build.xml'; $url = "{$this->url}/submit.php?project=AuthTokenProject"; $result = $this->uploadfile($url, $file, $headers); - if (!$result || strpos($result, 'OK') === false) { + if (!$result || !str_contains($result, 'OK')) { return false; } return true; @@ -204,7 +204,7 @@ public function putSubmit($headers) $file = dirname(__FILE__) . '/data/gcov.tar'; $puturl = $this->url . "/submit.php?type=GcovTar&md5=5454e16948a1d58d897e174b75cc5633&filename=gcov.tar&buildid={$this->PostBuildId}"; $put_result = $this->uploadfile($puturl, $file, $headers); - if (strpos($put_result, '{"status":0}') === false) { + if (!str_contains($put_result, '{"status":0}')) { return false; } return true; diff --git a/app/cdash/tests/test_autoremovebuilds.php b/app/cdash/tests/test_autoremovebuilds.php index 89a11c7b2..365832cdc 100644 --- a/app/cdash/tests/test_autoremovebuilds.php +++ b/app/cdash/tests/test_autoremovebuilds.php @@ -25,7 +25,7 @@ public function testAutoRemoveBuilds() $output = ob_get_contents(); ob_end_clean(); - if (strpos($output, 'Usage: php') === false) { + if (!str_contains($output, 'Usage: php')) { $this->fail("Expected output not found from autoRemoveBuilds.php.\n$output\n"); } @@ -39,10 +39,10 @@ public function testAutoRemoveBuilds() $output = ob_get_contents(); ob_end_clean(); - if (strpos($output, 'removing builds for InsightExample') === false) { + if (!str_contains($output, 'removing builds for InsightExample')) { $this->fail("Expected output not found from autoRemoveBuilds.php.\n$output\n"); $error = 1; - } elseif (strpos($output, 'removing old buildids') === false) { + } elseif (!str_contains($output, 'removing old buildids')) { $this->fail("Autoremovebuilds failed to remove old build by buildgroup setting.\n$output\n"); $error = 1; } else { diff --git a/app/cdash/tests/test_bazeljson.php b/app/cdash/tests/test_bazeljson.php index adc841c0b..a47a601b9 100644 --- a/app/cdash/tests/test_bazeljson.php +++ b/app/cdash/tests/test_bazeljson.php @@ -66,7 +66,7 @@ public function testBazelJSON() $output = $jsonobj['test']['output']; $not_expected = 'Executed 2 out of 2 tests'; - if (strpos($output, $not_expected) !== false) { + if (str_contains($output, $not_expected)) { $this->fail('Unexpected output! Should not include test summary'); } @@ -295,7 +295,7 @@ public function testBazelTestFailed() $output = $jsonobj['test']['output']; $expected = 'FAIL: testDrakeFindResourceOrThrowInInstall (__main__.TestCommonInstall)'; - if (strpos($output, $expected) === false) { + if (!str_contains($output, $expected)) { $this->fail("Expected output to include '$expected'"); } @@ -351,7 +351,7 @@ public function testBazelTimeout() $output = $jsonobj['test']['output']; $expected = 'TIMEOUT'; - if (strpos($output, $expected) === false) { + if (!str_contains($output, $expected)) { $this->fail("Expected output to include '$expected'"); } @@ -523,7 +523,7 @@ public function testShardTest() // Check Details $expected = 'Completed'; - if (strpos($jsonobj['test']['details'], $expected) === false) { + if (!str_contains($jsonobj['test']['details'], $expected)) { $this->fail("Expected output to include '$expected'"); } @@ -580,12 +580,12 @@ public function testShardTestFailures() $output = $jsonobj['test']['output']; $expected = '//automotive/maliput/multilane:multilane_builder_test'; - if (strpos($output, $expected) === false) { + if (!str_contains($output, $expected)) { $this->fail("Expected output to include '$expected'"); } $expected = 'multilane/multilane_builder_test/test.log'; - if (strpos($output, $expected) === false) { + if (!str_contains($output, $expected)) { $this->fail("Expected output to include '$expected'"); } @@ -612,13 +612,13 @@ public function testShardTestFailures() $output = $jsonobj['test']['output']; $expected = 'automotive/maliput/multilane:multilane_lanes_test'; - if (strpos($output, $expected) === false) { + if (!str_contains($output, $expected)) { $this->fail("Expected output to include '$expected'"); } // Check Details $expected = 'Completed (Failed)'; - if (strpos($jsonobj['test']['details'], $expected) === false) { + if (!str_contains($jsonobj['test']['details'], $expected)) { $this->fail("Expected output to include '$expected'"); } @@ -675,36 +675,36 @@ public function testShardTestTimeout() $output = $jsonobj['test']['output']; $expected = 'Note: This is test shard 8 of 10.'; - if (strpos($output, $expected) === false) { + if (!str_contains($output, $expected)) { $this->fail("Expected output to include '$expected'"); } $expected = 'Note: This is test shard 9 of 10.'; - if (strpos($output, $expected) === false) { + if (!str_contains($output, $expected)) { $this->fail("Expected output to include '$expected'"); } $expected = 'Note: This is test shard 10 of 10.'; - if (strpos($output, $expected) === false) { + if (!str_contains($output, $expected)) { $this->fail("Expected output to include '$expected'"); } // 'TIMEOUT' has markup, skip looking for that to make test simpler $expected = 'in 3 out of 10 in 60.1s'; - if (strpos($output, $expected) === false) { + if (!str_contains($output, $expected)) { $this->fail("Expected output to include '$expected'"); } $expected = 'Stats over 10 runs'; - if (strpos($output, $expected) === false) { + if (!str_contains($output, $expected)) { $this->fail("Expected output to include '$expected'"); } // Check Details $expected = 'Completed (Timeout)'; - if (strpos($jsonobj['test']['details'], $expected) === false) { + if (!str_contains($jsonobj['test']['details'], $expected)) { $this->fail("Expected output to include '$expected'"); } // Check time - should be sum of all shards $expected = '3m 5s 750ms'; - if (strpos($jsonobj['test']['time'], $expected) === false) { + if (!str_contains($jsonobj['test']['time'], $expected)) { $this->fail("Expected time to be $expected, found {$jsonobj['test']['time']}"); } diff --git a/app/cdash/tests/test_branchcoverage.php b/app/cdash/tests/test_branchcoverage.php index d1f0dcef7..361cebcb0 100644 --- a/app/cdash/tests/test_branchcoverage.php +++ b/app/cdash/tests/test_branchcoverage.php @@ -105,7 +105,7 @@ protected function putSubmit($token = null) $headers = ["Authorization: Bearer {$token}"]; } $put_result = $this->uploadfile($puturl, $filename, $headers); - if (strpos($put_result, '{"status":0}') === false) { + if (!str_contains($put_result, '{"status":0}')) { $this->fail( "status:0 not found in PUT results:\n$put_result\n"); return 1; @@ -118,7 +118,7 @@ protected function verifyResults() // Make sure that it recorded the source file's label in our submission. $content = $this->get($url); - if (strpos($content, 'Foo') === false) { + if (!str_contains($content, 'Foo')) { $msg = '\"Foo\" not found when expected' . PHP_EOL . 'URL: ' . $url; $this->fail($msg); @@ -134,7 +134,7 @@ protected function verifyResults() // Make sure branch coverage is being displayed properly. $content = $this->get($this->url . "/viewCoverageFile.php?buildid=$this->buildid&fileid=$fileid"); - if (strpos($content, ' 1/2 7 | if (x <= 0)') === false) { + if (!str_contains($content, ' 1/2 7 | if (x <= 0)')) { $this->fail('\" 1/2 7 | if (x <= 0)\" not found when expected'); return 1; } diff --git a/app/cdash/tests/test_buildconfigure.php b/app/cdash/tests/test_buildconfigure.php index e9a0a3a91..17704d6a3 100644 --- a/app/cdash/tests/test_buildconfigure.php +++ b/app/cdash/tests/test_buildconfigure.php @@ -29,7 +29,7 @@ public function testBuildConfigure() $this->fail('configure with invalid buildid should not exist'); } $log_contents = file_get_contents($this->logfilename); - if (strpos($log_contents, 'BuildId is not numeric') === false) { + if (!str_contains($log_contents, 'BuildId is not numeric')) { $this->fail("'BuildId is not numeric' not found from Exists()"); } @@ -38,7 +38,7 @@ public function testBuildConfigure() $this->fail('Configure exists with null buildid'); } $log_contents = file_get_contents($this->logfilename); - if (strpos($log_contents, 'BuildId not set') === false) { + if (!str_contains($log_contents, 'BuildId not set')) { $this->fail("'BuildId is not numeric' not found from Exists()"); } diff --git a/app/cdash/tests/test_buildoverview.php b/app/cdash/tests/test_buildoverview.php index b3262620f..98d166327 100644 --- a/app/cdash/tests/test_buildoverview.php +++ b/app/cdash/tests/test_buildoverview.php @@ -22,7 +22,7 @@ public function testBuildOverview() return 1; } $this->get($this->url . '/buildOverview.php?project=InsightExample'); - if (strpos($this->getBrowser()->getContentAsText(), 'Build summary') === false) { + if (!str_contains($this->getBrowser()->getContentAsText(), 'Build summary')) { $this->fail("'Build summary' not found when expected"); return 1; } diff --git a/app/cdash/tests/test_buildproperties.php b/app/cdash/tests/test_buildproperties.php index 878bf5508..bb75c40b3 100644 --- a/app/cdash/tests/test_buildproperties.php +++ b/app/cdash/tests/test_buildproperties.php @@ -70,7 +70,7 @@ public function testUploadBuildProperties() foreach ($this->Builds as $name => $build) { $numpass = 0; $numfail = 0; - if (strpos($name, 'failedtest') !== false) { + if (str_contains($name, 'failedtest')) { $testcreator->testStatus = 'failed'; $numfail = 1; } else { diff --git a/app/cdash/tests/test_configureappend.php b/app/cdash/tests/test_configureappend.php index 96fd26728..bc45d41cf 100644 --- a/app/cdash/tests/test_configureappend.php +++ b/app/cdash/tests/test_configureappend.php @@ -62,8 +62,8 @@ public function testConfigureAppend() $this->assertEqual($configure->status, 3); $log = $configure->log; - $this->assertTrue(strpos($log, 'This is the first part of my configure') !== false); - $this->assertTrue(strpos($log, 'This is the second part of my configure') !== false); + $this->assertTrue(str_contains($log, 'This is the first part of my configure')); + $this->assertTrue(str_contains($log, 'This is the second part of my configure')); $this->assertEqual($build_results[0]->configureerrors, 3); $this->assertEqual($build_results[0]->configurewarnings, 5); diff --git a/app/cdash/tests/test_coveragedirectories.php b/app/cdash/tests/test_coveragedirectories.php index 167d69ef0..7bc892c4c 100644 --- a/app/cdash/tests/test_coveragedirectories.php +++ b/app/cdash/tests/test_coveragedirectories.php @@ -58,7 +58,7 @@ public function testCoverageDirectories() return; } - if (strpos($jsonobj['aaData'][0][0], 'hello.cpp') === false) { + if (!str_contains($jsonobj['aaData'][0][0], 'hello.cpp')) { $this->fail('utils/ directory does not contain hello.cpp'); return; } @@ -106,7 +106,7 @@ public function testCoverageDirectories() ]; foreach ($expected_page_1 as $i => $value) { - if (strpos($jsonobj['aaData'][$i][0], $value) === false) { + if (!str_contains($jsonobj['aaData'][$i][0], $value)) { $this->fail("Index $i is not $value"); return; } diff --git a/app/cdash/tests/test_crosssubprojectcoverage.php b/app/cdash/tests/test_crosssubprojectcoverage.php index af867cbfd..0c57cc9d3 100644 --- a/app/cdash/tests/test_crosssubprojectcoverage.php +++ b/app/cdash/tests/test_crosssubprojectcoverage.php @@ -122,7 +122,7 @@ public function submitResults($subproject, $starttime, $endtime, $md5) $filename = "$this->DataDir/$subproject/gcov.tar"; $put_result = $this->uploadfile($puturl, $filename); - if (strpos($put_result, '{"status":0}') === false) { + if (!str_contains($put_result, '{"status":0}')) { $this->fail( "status:0 not found in PUT results:\n$put_result\n"); return 1; diff --git a/app/cdash/tests/test_csvexport.php b/app/cdash/tests/test_csvexport.php index ec9729442..961c0c9a9 100644 --- a/app/cdash/tests/test_csvexport.php +++ b/app/cdash/tests/test_csvexport.php @@ -32,7 +32,7 @@ public function testExportToCSV() // Verify expected contents. $expected = 'DashboardSendTest,0.05,"Completed (OTHER_FAULT)",Failed'; - if (strpos($content, $expected) === false) { + if (!str_contains($content, $expected)) { $this->fail('Expected content not found in CSV output'); } } diff --git a/app/cdash/tests/test_disabledtests.php b/app/cdash/tests/test_disabledtests.php index 80fd7c8d1..1d4999e76 100644 --- a/app/cdash/tests/test_disabledtests.php +++ b/app/cdash/tests/test_disabledtests.php @@ -66,10 +66,10 @@ public function testDisabledTests() // Verify email was sent for the missing exe but not for the disabled test. $log_contents = file_get_contents($this->logfilename); - if (strpos($log_contents, 'ThisTestFails') === false) { + if (!str_contains($log_contents, 'ThisTestFails')) { $this->fail("No email sent for test 'ThisTestFails'"); } - if (strpos($log_contents, 'ThisTestIsDisabled') !== false) { + if (str_contains($log_contents, 'ThisTestIsDisabled')) { $this->fail("Erroneous email sent for test 'ThisTestIsDisabled'"); } diff --git a/app/cdash/tests/test_donehandler.php b/app/cdash/tests/test_donehandler.php index f8edea760..43a8a6c6e 100644 --- a/app/cdash/tests/test_donehandler.php +++ b/app/cdash/tests/test_donehandler.php @@ -105,7 +105,7 @@ private function performTest($remote = false) $files = Storage::files('parsed'); $contents = file_get_contents(Storage::path($files[0])); - $this->assertTrue(strpos($contents, 'Done retries="5"') !== false); + $this->assertTrue(str_contains($contents, 'Done retries="5"')); unlink($tmpfname); DatabaseCleanupUtils::removeBuild($build->Id); diff --git a/app/cdash/tests/test_dynamicanalysislogs.php b/app/cdash/tests/test_dynamicanalysislogs.php index 30ec5e2dd..26d42188d 100644 --- a/app/cdash/tests/test_dynamicanalysislogs.php +++ b/app/cdash/tests/test_dynamicanalysislogs.php @@ -59,11 +59,11 @@ public function testDynamicAnalysisLogs() $this->fail('Failed to fill dynamic analysis object'); } - if (strpos($DA->Log, 'Memcheck, a memory error detector') === false) { + if (!str_contains($DA->Log, 'Memcheck, a memory error detector')) { $this->fail('Failed to find beginning of log'); } - if (strpos($DA->Log, 'Goodbye world') === false) { + if (!str_contains($DA->Log, 'Goodbye world')) { $this->fail('Failed to find end of log'); } } diff --git a/app/cdash/tests/test_filterblocks.php b/app/cdash/tests/test_filterblocks.php index 1eb2f147f..213c95d7a 100644 --- a/app/cdash/tests/test_filterblocks.php +++ b/app/cdash/tests/test_filterblocks.php @@ -72,7 +72,7 @@ public function testFilterBlocksAreRemovedWhenNoSubFiltersRemain() // Verify the link to the child build is what we expect (no filter block). $build = $buildgroup['builds'][0]; $expected = 'filtercount=2&showfilters=1&field1=subprojects&compare1=92&value1=Teuchos&field2=subprojects&compare2=92&value2=Mesquite&filtercombine=and'; - $this->assertTrue(strpos($build['multiplebuildshyperlink'], $expected) !== false); + $this->assertTrue(str_contains($build['multiplebuildshyperlink'], $expected)); } private function verifyTwoHutBuilds() @@ -86,7 +86,7 @@ private function verifyTwoHutBuilds() } foreach ($buildgroup['builds'] as $build) { $sitename = $build['site']; - if (strpos($sitename, 'hut') === false) { + if (!str_contains($sitename, 'hut')) { $this->fail("Expected sitename to contain 'hut', instead got $sitename"); } } diff --git a/app/cdash/tests/test_indexfilters.php b/app/cdash/tests/test_indexfilters.php index d1c37bbed..f7b716aac 100644 --- a/app/cdash/tests/test_indexfilters.php +++ b/app/cdash/tests/test_indexfilters.php @@ -61,7 +61,7 @@ public function filter($field, $compare, $value, $expected, $url = null) // ...and that it's the right build. $buildname = $buildgroup['builds'][0]['buildname']; - if (strpos($buildname, $expected) === false) { + if (!str_contains($buildname, $expected)) { $this->fail("Expected $expected to survive $field filter, instead got $buildname"); return false; } diff --git a/app/cdash/tests/test_javajsoncoverage.php b/app/cdash/tests/test_javajsoncoverage.php index 8666cccb1..4601354b9 100644 --- a/app/cdash/tests/test_javajsoncoverage.php +++ b/app/cdash/tests/test_javajsoncoverage.php @@ -47,7 +47,7 @@ public function testJavaJSONCoverage() $filename = dirname(__FILE__) . '/data/JavaJSONTar_example.tar'; $put_result = $this->uploadfile($puturl, $filename); - if (strpos($put_result, '{"status":0}') === false) { + if (!str_contains($put_result, '{"status":0}')) { $this->fail( "status:0 not found in PUT results:\n$put_result\n"); return 1; @@ -56,7 +56,7 @@ public function testJavaJSONCoverage() // Verify that the coverage data was successfully parsed. $content = $this->get( $this->url . "/viewCoverage.php?buildid=$buildid&status=6"); - if (strpos($content, '86.36') === false) { + if (!str_contains($content, '86.36')) { $this->fail('\"86.36\" not found when expected'); return 1; } diff --git a/app/cdash/tests/test_jscovercoverage.php b/app/cdash/tests/test_jscovercoverage.php index 4c54aa1cb..2a9603347 100644 --- a/app/cdash/tests/test_jscovercoverage.php +++ b/app/cdash/tests/test_jscovercoverage.php @@ -47,7 +47,7 @@ public function testJSCoverCoverage() $filename = dirname(__FILE__) . '/data/JSCoverTest.tar'; $put_result = $this->uploadfile($puturl, $filename); - if (strpos($put_result, '{"status":0}') === false) { + if (!str_contains($put_result, '{"status":0}')) { $this->fail( "status:0 not found in PUT results:\n$put_result\n"); return 1; @@ -56,7 +56,7 @@ public function testJSCoverCoverage() // Verify that the coverage data was successfully parsed. $content = $this->get( $this->url . "/viewCoverage.php?buildid=$buildid&status=6"); - if (strpos($content, '86.06') === false) { + if (!str_contains($content, '86.06')) { $this->fail('\"86.06\" not found when expected'); return 1; } diff --git a/app/cdash/tests/test_manageprojectroles.php b/app/cdash/tests/test_manageprojectroles.php index fb55dca36..d3a62e9e8 100644 --- a/app/cdash/tests/test_manageprojectroles.php +++ b/app/cdash/tests/test_manageprojectroles.php @@ -62,7 +62,7 @@ public function connectAndGetProjectId() $content = $this->connect($this->url . '/manageProjectRoles.php'); $lines = explode("\n", $content); foreach ($lines as $line) { - if (strpos($line, 'PublicDashboard') !== false) { + if (str_contains($line, 'PublicDashboard')) { preg_match('#