Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply all "safe" PHP migration style rules #1624

Merged
merged 13 commits into from
Aug 18, 2023
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
$config = new PhpCsFixer\Config();
return $config->setRules([
'@PSR2' => true,
'@PHP81Migration' => true,
'method_argument_space' => ['on_multiline' => 'ignore'],
'no_unused_imports' => true,
])
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/MigrateConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function handle()
if (strpos($line, '=') === false) {
continue;
}
list($key, $value) = explode('=', $line);
[$key, $value] = explode('=', $line);
$config[$key] = $value;
}
fclose($handle);
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ public function removeBuilds(): View|RedirectResponse
$dayTo,
$yearFrom,
$monthFrom,
$dayFrom
$dayFrom,
]);

$builds = array();
$builds = [];
foreach ($build as $build_array) {
$builds[] = (int) $build_array->id;
}
Expand Down Expand Up @@ -238,7 +238,7 @@ public function upgrade()

// Add new multi-column index to build table.
// This improves the rendering speed of overview.php.
$multi_index = array('projectid', 'parentid', 'starttime');
$multi_index = ['projectid', 'parentid', 'starttime'];
AddTableIndex('build', $multi_index);

// Support for dynamic BuildGroups.
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected function sendFailedLoginResponse(Request $request): Response
->response = response()
->view('auth.login', [
'errors' => $e->validator->getMessageBag(),
'title' => 'Login'
'title' => 'Login',
],
401
);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function create(array $data) : User|null
'lastname' => $data['lname'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
'institution' => $data['institution']
'institution' => $data['institution'],
]);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/AuthTokenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function fetchAll(): JsonResponse
}

return response()->json([
'tokens' => $token_map
'tokens' => $token_map,
]);
}

Expand Down
16 changes: 8 additions & 8 deletions app/Http/Controllers/BuildController.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,16 +687,16 @@ public function viewUpdatePageContent(): JsonResponse
$update_groups = [
[
'description' => "{$this->project->Name} Updated Files ($num_updated_files)",
'directories' => $updated_files
'directories' => $updated_files,
],
[
'description' => "Modified Files ($num_modified_files)",
'directories' => $modified_files
'directories' => $modified_files,
],
[
'description' => "Conflicting Files ($num_conflicting_files)",
'directories' => $conflicting_files
]
'directories' => $conflicting_files,
],
];
$response['updategroups'] = $update_groups;

Expand Down Expand Up @@ -850,7 +850,7 @@ public function apiViewBuildError(): JsonResponse

// Site
$extra_build_fields = [
'site' => $this->build->GetSite()->name
'site' => $this->build->GetSite()->name,
];

// Update
Expand Down Expand Up @@ -910,12 +910,12 @@ public function apiViewBuildError(): JsonResponse
', [intval($resolvedBuildFailure['id'])], $marshaledResolvedBuildFailure);
}

$marshaledResolvedBuildFailure = array_merge($marshaledResolvedBuildFailure, array(
$marshaledResolvedBuildFailure = array_merge($marshaledResolvedBuildFailure, [
'stderr' => $resolvedBuildFailure['stderror'],
'stderrorrows' => min(10, substr_count($resolvedBuildFailure['stderror'], "\n") + 1),
'stdoutput' => $resolvedBuildFailure['stdoutput'],
'stdoutputrows' => min(10, substr_count($resolvedBuildFailure['stdoutput'], "\n") + 1),
));
]);

$this->addErrorResponse($marshaledResolvedBuildFailure, $response);
}
Expand Down Expand Up @@ -1177,7 +1177,7 @@ public function apiBuildExpected(): JsonResponse
$this->setBuildById(intval($_GET['buildid'] ?? -1));
$rule = new BuildGroupRule($this->build);
return response()->json([
'expected' => $rule->GetExpected()
'expected' => $rule->GetExpected(),
]);
}
}
16 changes: 8 additions & 8 deletions app/Http/Controllers/BuildPropertiesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public function apiBuildProperties(): JsonResponse
if (isset($_GET['begin']) && isset($_GET['end'])) {
$beginning_date = $_GET['begin'];
$end_date = $_GET['end'];
list($unused, $beginning_timestamp) = get_dates($beginning_date, $this->project->NightlyTime);
list($unused, $end_timestamp) = get_dates($end_date, $this->project->NightlyTime);
[$unused, $beginning_timestamp] = get_dates($beginning_date, $this->project->NightlyTime);
[$unused, $end_timestamp] = get_dates($end_date, $this->project->NightlyTime);
$datetime = new DateTime();
$datetime->setTimestamp($end_timestamp);
$datetime->add(new DateInterval('P1D'));
Expand All @@ -62,7 +62,7 @@ public function apiBuildProperties(): JsonResponse
$date = date(FMT_DATE);
}
if (is_null($beginning_timestamp)) {
list($unused, $beginning_timestamp) = get_dates($date, $this->project->NightlyTime);
[$unused, $beginning_timestamp] = get_dates($date, $this->project->NightlyTime);
$datetime = new DateTime();
$datetime->setTimestamp($beginning_timestamp);
$datetime->add(new DateInterval('P1D'));
Expand All @@ -81,18 +81,18 @@ public function apiBuildProperties(): JsonResponse
[
'name' => 'builderrors',
'prettyname' => 'Errors',
'selected' => false
'selected' => false,
],
[
'name' => 'buildwarnings',
'prettyname' => 'Warnings',
'selected' => false
'selected' => false,
],
[
'name' => 'testfailed',
'prettyname' => 'Test Failures',
'selected' => false
]
'selected' => false,
],
];

// Mark specified types of defects as selected.
Expand Down Expand Up @@ -289,7 +289,7 @@ private function gather_defects(PDOStatement $stmt, string $prettyname, array &$
$defects_response[] = [
'descr' => $descr,
'type' => $prettyname,
'builds' => []
'builds' => [],
];
$idx = count($defects_response) - 1;
}
Expand Down
24 changes: 12 additions & 12 deletions app/Http/Controllers/CoverageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function manageCoverage(): View|RedirectResponse
if (!isset($userid) || !is_numeric($userid)) {
return view('cdash', [
'xsl' => true,
'xsl_content' => 'Not a valid userid!'
'xsl_content' => 'Not a valid userid!',
]);
}

Expand Down Expand Up @@ -84,7 +84,7 @@ public function manageCoverage(): View|RedirectResponse
if (!Gate::allows('edit-project', $Project)) {
return view('cdash', [
'xsl' => true,
'xsl_content' => "You don't have the permissions to access this page"
'xsl_content' => "You don't have the permissions to access this page",
]);
}

Expand Down Expand Up @@ -178,7 +178,7 @@ public function manageCoverage(): View|RedirectResponse
$line = substr($contents, $pos, $pos2 - $pos);

$file = '';
$authors = array();
$authors = [];

// first is the svnuser
$posfile = strpos($line, ':');
Expand Down Expand Up @@ -374,7 +374,7 @@ public function manageCoverage(): View|RedirectResponse
'xsl' => true,
'xsl_content' => generate_XSLT($xml, base_path() . '/app/cdash/public/manageCoverage', true),
'project' => $Project,
'title' => 'Manage Coverage'
'title' => 'Manage Coverage',
]);
}

Expand Down Expand Up @@ -506,7 +506,7 @@ public function viewCoverage(): View|RedirectResponse
if ($this->project->DisplayLabels) {
// Get the set of labels involved:
//
$labels = array();
$labels = [];

$covlabels = $db->executePrepared('
SELECT DISTINCT id, text
Expand Down Expand Up @@ -596,8 +596,8 @@ public function viewCoverage(): View|RedirectResponse
AND c.fileid=cf.id
', [intval($this->build->Id)]);

$directories = array();
$covfile_array = array();
$directories = [];
$covfile_array = [];
foreach ($coveragefile as $coveragefile_array) {
$covfile['covered'] = 1;

Expand Down Expand Up @@ -675,7 +675,7 @@ public function viewCoverage(): View|RedirectResponse
$covfile_array[] = $covfile;
}

$ncoveragefiles = array();
$ncoveragefiles = [];
$ncoveragefiles[0] = count($directories);
$ncoveragefiles[1] = 0;
$ncoveragefiles[2] = 0;
Expand Down Expand Up @@ -730,7 +730,7 @@ public function viewCoverage(): View|RedirectResponse
'xsl' => true,
'xsl_content' => generate_XSLT($xml, 'viewCoverage', true),
'project' => $this->project,
'title' => 'Coverage'
'title' => 'Coverage',
]);
}

Expand Down Expand Up @@ -1080,12 +1080,12 @@ public function ajaxGetViewCoverage(): JsonResponse

// Contruct the directory view
if ($status === -1) {
$directory_array = array();
$directory_array = [];
foreach ($covfile_array as $covfile) {
$fullpath = $covfile['fullpath'];
$fullpath = dirname($fullpath);
if (!isset($directory_array[$fullpath])) {
$directory_array[$fullpath] = array();
$directory_array[$fullpath] = [];
$directory_array[$fullpath]['priority'] = 0;
$directory_array[$fullpath]['directory'] = 1;
$directory_array[$fullpath]['covered'] = 1;
Expand Down Expand Up @@ -1756,7 +1756,7 @@ public function apiCompareCoverage(): JsonResponse

$date = isset($_GET['date']) ? htmlspecialchars($_GET['date']) : null;

list($previousdate, $currentstarttime, $nextdate) = get_dates($date, $this->project->NightlyTime);
[$previousdate, $currentstarttime, $nextdate] = get_dates($date, $this->project->NightlyTime);

$response = begin_JSON_response();
$response['title'] = $this->project->Name . ' - Compare Coverage';
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/FilterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function getFilterDataArray(): JsonResponse
'limit',
'othercombine',
'showfilters',
'showlimit'
'showlimit',
];
foreach ($filterdata as $key => $value) {
if (!in_array($key, $fields_to_preserve)) {
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/ManageProjectRolesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function viewPage(): View|RedirectResponse
if (!$current_user->IsAdmin() && $role <= 1) {
return view('cdash', [
'xsl' => true,
'xsl_content' => "You don't have the permissions to access this page!"
'xsl_content' => "You don't have the permissions to access this page!",
]);
}

Expand Down Expand Up @@ -385,7 +385,7 @@ public function viewPage(): View|RedirectResponse
intval($project_array['id']),
intval($project_array['id']),
intval($project_array['id']),
$date
$date,
]);

add_last_sql_error('ManageProjectRole');
Expand All @@ -409,7 +409,7 @@ public function viewPage(): View|RedirectResponse
'xsl' => true,
'xsl_content' => generate_XSLT($xml, base_path() . '/app/cdash/public/manageProjectRoles', true),
'project' => $project,
'title' => 'Project Roles'
'title' => 'Project Roles',
]);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/MapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function viewMap(): View|RedirectResponse

$db = Database::getInstance();

list($previousdate, $currenttime, $nextdate) = get_dates($date, $this->project->NightlyTime);
[$previousdate, $currenttime, $nextdate] = get_dates($date, $this->project->NightlyTime);

$nightlytime = strtotime($this->project->NightlyTime);

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function apiCreateProject(): JsonResponse

$repositories = $this->project->GetRepositories();
foreach ($repositories as $repository) {
$repository_response = array();
$repository_response = [];
$repository_response['url'] = $repository['url'];
$repository_response['username'] = $repository['username'];
$repository_response['password'] = $repository['password'];
Expand Down
Loading