Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ebca064
Enable `array_push` style rule
williamjallen Dec 18, 2025
89036ba
Apply `array_push` style rule
williamjallen Dec 18, 2025
f63441d
Enable `combine_nested_dirname` rule
williamjallen Dec 18, 2025
170a0cb
Enable `dir_constant` rule
williamjallen Dec 18, 2025
4660b62
Apply `dir_constant` rule
williamjallen Dec 18, 2025
97f3807
Enable `ereg_to_preg` rule
williamjallen Dec 18, 2025
a2aa90a
Enable `fopen_flag_order` rule
williamjallen Dec 18, 2025
e7e7fba
Enable `function_to_constant` rule
williamjallen Dec 18, 2025
7181860
Enable `get_class_to_class_keyword` rule
williamjallen Dec 18, 2025
30dbb3a
Enable `implode_call` rule
williamjallen Dec 18, 2025
14586e7
Enable `is_null` rule
williamjallen Dec 18, 2025
5c4bcb0
Apply `is_null` rule
williamjallen Dec 18, 2025
ccfb2d8
Enable `logical_operators` rule
williamjallen Dec 18, 2025
be8f9ca
Apply `logical_operators` rule
williamjallen Dec 18, 2025
f6ad02b
Enable `long_to_shorthand_operator` rule
williamjallen Dec 18, 2025
5482625
Apply `long_to_shorthand_operator` rule
williamjallen Dec 18, 2025
951ff7b
Enable `modernize_strpos` rule
williamjallen Dec 18, 2025
28ba269
Apply `modernize_strpos` rule
williamjallen Dec 18, 2025
64947f4
Enable `modernize_types_casting` rule
williamjallen Dec 18, 2025
b27e4ba
Apply `modernize_types_casting` rule
williamjallen Dec 18, 2025
d43c44f
Enable `no_homoglyph_names` rule
williamjallen Dec 18, 2025
3cfa49a
Enable `no_useless_sprintf` rule
williamjallen Dec 18, 2025
f23a16a
Enable `non_printable_character` rule
williamjallen Dec 18, 2025
a7d758a
Enable `ordered_traits` rule
williamjallen Dec 18, 2025
226627b
Apply `ordered_traits` rule
williamjallen Dec 18, 2025
eb90f80
Regenerate PHPStan baseline
williamjallen Dec 18, 2025
cc319c8
Enable `self_accessor` rule
williamjallen Dec 18, 2025
8c89a1e
Apply `self_accessor` rule
williamjallen Dec 18, 2025
e652477
Enable `set_type_to_cast` rule
williamjallen Dec 18, 2025
785fc04
Enable `string_line_ending` rule
williamjallen Dec 18, 2025
5bad647
Update deprecated ruleset names
williamjallen Dec 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
->exclude('resources')
->exclude('public')
->exclude('app/cdash/tests/kwtest/simpletest')
->notPath('app/cdash/tests/config.test.local.php')
->in(__DIR__);

$config = new Config();
return $config->setRules([
'@PSR12' => true,
'@PSR12:risky' => true,
'@PHP82Migration' => true,
'@PHP82Migration:risky' => true,
'@PHP8x2Migration' => true,
'@PHP8x2Migration:risky' => true,
'@Symfony' => true,
'yoda_style' => false,
'blank_line_before_statement' => false,
Expand All @@ -32,4 +31,25 @@
'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...
// The following rules are a subset of @Symfony:risky and should eventually be replaced by the full ruleset.
'array_push' => true,
'combine_nested_dirname' => true,
'dir_constant' => true,
'ereg_to_preg' => true,
'fopen_flag_order' => true,
'function_to_constant' => true,
'get_class_to_class_keyword' => true,
'implode_call' => true,
'is_null' => true,
'logical_operators' => true,
'long_to_shorthand_operator' => true,
'modernize_strpos' => ['modernize_stripos' => true],
'modernize_types_casting' => true,
'no_homoglyph_names' => true,
'no_useless_sprintf' => true,
'non_printable_character' => true,
'ordered_traits' => true,
'self_accessor' => true,
'set_type_to_cast' => true,
'string_line_ending' => true,
])->setFinder($finder);
2 changes: 1 addition & 1 deletion app/Console/Commands/RemoveUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct()
public function handle(): void
{
$email = $this->option('email');
if (is_null($email)) {
if (null === $email) {
$this->error('You must specify the --email option');
return;
}
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/SaveUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct()
public function handle(): void
{
$email = $this->option('email');
if (is_null($email)) {
if (null === $email) {
$this->error('You must specify the --email option');
return;
}
Expand All @@ -57,7 +57,7 @@ public function handle(): void
$options = ['firstname', 'lastname', 'institution', 'password'];
foreach ($options as $option_name) {
$option_value = $this->option($option_name);
if (!is_null($option_value)) {
if (null !== $option_value) {
if ($option_name === 'password') {
$option_value = password_hash($option_value, PASSWORD_DEFAULT);
}
Expand Down
16 changes: 8 additions & 8 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public function removeBuilds(): View|RedirectResponse
{
@set_time_limit(0);

$projectid = intval($_GET['projectid'] ?? 0);
$projectid = (int) ($_GET['projectid'] ?? 0);

$alert = '';

// get date info here
@$dayTo = intval($_POST['dayFrom']);
@$dayTo = (int) $_POST['dayFrom'];
if (empty($dayTo)) {
$time = strtotime('2000-01-01 00:00:00');

Expand All @@ -43,12 +43,12 @@ public function removeBuilds(): View|RedirectResponse
$yearTo = date('Y');
$monthTo = date('m');
} else {
$dayFrom = intval($_POST['dayFrom']);
$monthFrom = intval($_POST['monthFrom']);
$yearFrom = intval($_POST['yearFrom']);
$dayTo = intval($_POST['dayTo']);
$monthTo = intval($_POST['monthTo']);
$yearTo = intval($_POST['yearTo']);
$dayFrom = (int) $_POST['dayFrom'];
$monthFrom = (int) $_POST['monthFrom'];
$yearFrom = (int) $_POST['yearFrom'];
$dayTo = (int) $_POST['dayTo'];
$monthTo = (int) $_POST['monthTo'];
$yearTo = (int) $_POST['yearTo'];
}

// List the available projects
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 @@ -89,7 +89,7 @@ protected function validator(array $data)
*/
public function create(array $data): ?User
{
if (is_null($data['institution'])) {
if (null === $data['institution']) {
$data['institution'] = '';
}
return User::create([
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 @@ -47,7 +47,7 @@ public function createToken(Request $request): JsonResponse
}

if ($request->input('scope') !== AuthToken::SCOPE_FULL_ACCESS) {
$projectid = intval($request->input('projectid'));
$projectid = (int) $request->input('projectid');
if (!is_numeric($projectid)) {
return response()->json(['error' => 'Invalid projectid'], Response::HTTP_BAD_REQUEST);
}
Expand Down
22 changes: 11 additions & 11 deletions app/Http/Controllers/BuildController.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function apiBuildSummary(): JsonResponse
{
$pageTimer = new PageTimer();

$this->setBuildById(intval($_GET['buildid'] ?? -1));
$this->setBuildById((int) ($_GET['buildid'] ?? -1));

$date = TestingDay::get($this->project, $this->build->StartTime);

Expand Down Expand Up @@ -504,7 +504,7 @@ public function buildOverview(): View|RedirectResponse
$currentstarttime = get_dates($date, $this->project->NightlyTime)[1];

// Return the available groups
$selected_group = intval($_POST['groupSelection'] ?? 0);
$selected_group = (int) ($_POST['groupSelection'] ?? 0);

// Check the builds
$beginning_timestamp = $currentstarttime;
Expand Down Expand Up @@ -580,7 +580,7 @@ public function viewUpdatePageContent(): JsonResponse
{
$pageTimer = new PageTimer();

$this->setBuildById(intval($_GET['buildid'] ?? -1));
$this->setBuildById((int) ($_GET['buildid'] ?? -1));

$date = TestingDay::get($this->project, $this->build->StartTime);
$response = begin_JSON_response();
Expand Down Expand Up @@ -821,13 +821,13 @@ public function build_file(int $build_id, int $file_id): StreamedResponse

public function ajaxBuildNote(): View
{
$this->setBuildById(intval($_GET['buildid'] ?? -1));
$this->setBuildById((int) ($_GET['buildid'] ?? -1));
Gate::authorize('edit-project', $this->project);

$notes = DB::select('SELECT * FROM comments WHERE buildid=? ORDER BY timestamp ASC', [$this->build->Id]);
foreach ($notes as $note) {
/** @var User $user */
$user = User::where('id', intval($note->userid))->first();
$user = User::where('id', (int) $note->userid)->first();
$note->user = $user;
}

Expand All @@ -851,7 +851,7 @@ public function apiViewBuildError(): JsonResponse
$response = begin_JSON_response();
$response['title'] = $this->project->Name;

$type = intval($_GET['type'] ?? 0);
$type = (int) ($_GET['type'] ?? 0);

$date = TestingDay::get($this->project, $this->build->StartTime);
get_dashboard_JSON($this->project->Name, $date, $response);
Expand Down Expand Up @@ -928,7 +928,7 @@ public function apiViewBuildError(): JsonResponse
label.id=label2buildfailure.labelid
AND label2buildfailure.buildfailureid=?
ORDER BY text ASC
', [intval($resolvedBuildFailure['id'])], $marshaledResolvedBuildFailure);
', [(int) $resolvedBuildFailure['id']], $marshaledResolvedBuildFailure);
}

$marshaledResolvedBuildFailure = array_merge($marshaledResolvedBuildFailure, [
Expand Down Expand Up @@ -1077,7 +1077,7 @@ public function apiViewConfigure(): JsonResponse

public function apiBuildUpdateGraph(): JsonResponse
{
$this->setBuildById(intval($_GET['buildid'] ?? -1));
$this->setBuildById((int) ($_GET['buildid'] ?? -1));

// Find previous submissions from this build.
$query_result = DB::select('
Expand Down Expand Up @@ -1118,7 +1118,7 @@ public function apiBuildUpdateGraph(): JsonResponse

public function apiGetPreviousBuilds(): JsonResponse
{
$this->setBuildById(intval($_GET['buildid'] ?? -1));
$this->setBuildById((int) ($_GET['buildid'] ?? -1));

// Take subproject into account, such that if there is one, then the
// previous builds must be associated with the same subproject.
Expand Down Expand Up @@ -1190,7 +1190,7 @@ public function apiGetPreviousBuilds(): JsonResponse
*/
public function apiBuildExpected(): JsonResponse
{
$this->setBuildById(intval($_GET['buildid'] ?? -1));
$this->setBuildById((int) ($_GET['buildid'] ?? -1));
$rule = new BuildGroupRule($this->build);
return response()->json([
'expected' => $rule->GetExpected(),
Expand Down Expand Up @@ -1372,7 +1372,7 @@ private function restApiGet(): JsonResponse
$gmtdate = strtotime($last_good_submit . ' UTC');
} else {
// Find the oldest submission for this build.
if (is_null($first_submit)) {
if (null === $first_submit) {
pdo_execute($oldest_build_stmt, $query_params);
$first_submit = $oldest_build_stmt->fetchColumn();
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/BuildNoteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class BuildNoteController extends AbstractBuildController
{
public function apiViewNotes(): JsonResponse
{
$this->setBuildById(intval($_GET['buildid'] ?? 0));
$this->setBuildById((int) ($_GET['buildid'] ?? 0));

$pageTimer = new PageTimer();

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/BuildPropertiesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function apiBuildProperties(): JsonResponse
// Default to the current date.
$date = date(FMT_DATE);
}
if (is_null($beginning_timestamp)) {
if (null === $beginning_timestamp) {
[$unused, $beginning_timestamp] = get_dates($date, $this->project->NightlyTime);
$datetime = new DateTime();
$datetime->setTimestamp($beginning_timestamp);
Expand Down Expand Up @@ -256,7 +256,7 @@ private function get_defects_for_builds()
$stmt = $pdo->prepare($sql);
$stmt->execute($_GET['buildid']);

if (!$this->gather_defects($stmt, $prettyname, $defects_response) && !is_null($sql2)) {
if (!$this->gather_defects($stmt, $prettyname, $defects_response) && null !== $sql2) {
$stmt = $pdo->prepare($sql2);
$stmt->execute($_GET['buildid']);
$this->gather_defects($stmt, $prettyname, $defects_response);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/CDash.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected function getRequestContents()
// Possible values of $redirect are null, 0, 1 and a ResponseRedirect.
// Clearly we want to ignore when null or int, otherwise $redirect should
// be returned
return is_numeric($redirect) || is_null($redirect) ? $content : $redirect;
return is_numeric($redirect) || null === $redirect ? $content : $redirect;
}

/**
Expand Down
Loading