Skip to content

Commit 341a5fd

Browse files
committed
Add misc type annotations to BuildFailure class
1 parent f10fe08 commit 341a5fd

File tree

4 files changed

+27
-111
lines changed

4 files changed

+27
-111
lines changed

app/Http/Controllers/BuildController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ public static function marshalBuildFailure($data, \CDash\Model\Project $project,
10741074
'outputtype' => $data['outputtype'],
10751075
'workingdirectory' => $data['workingdirectory'],
10761076
'exitcondition' => $data['exitcondition'],
1077-
], $buildfailure->GetBuildFailureArguments($data['id']));
1077+
], $buildfailure->GetBuildFailureArguments((int) $data['id']));
10781078

10791079
$marshaled['stderror'] = $data['stderror'];
10801080
$marshaled['stdoutput'] = $data['stdoutput'];

app/cdash/app/Model/BuildFailure.php

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,23 @@ class BuildFailure
2929
{
3030
public $BuildId;
3131
public $Type;
32-
public $WorkingDirectory;
33-
public $Arguments;
34-
public $StdOutput;
35-
public $StdError;
36-
public $ExitCondition;
37-
public $Language;
38-
public $TargetName;
39-
public $SourceFile;
40-
public $OutputFile;
41-
public $OutputType;
42-
public $Labels;
32+
public string $WorkingDirectory = '';
33+
/** @var array<string> */
34+
protected array $Arguments = [];
35+
public string $StdOutput = '';
36+
public string $StdError = '';
37+
public string $ExitCondition = '';
38+
public string $Language = '';
39+
public string $TargetName = '';
40+
public string $SourceFile = '';
41+
public string $OutputFile = '';
42+
public string $OutputType = '';
43+
public array $Labels = [];
4344

4445
private $PDO;
4546

4647
public function __construct()
4748
{
48-
$this->Arguments = [];
49-
$this->Labels = [];
5049
$this->PDO = Database::getInstance()->getPdo();
5150
}
5251

@@ -55,8 +54,7 @@ public function AddLabel($label): void
5554
$this->Labels[] = $label;
5655
}
5756

58-
// Add an argument to the buildfailure
59-
public function AddArgument($argument): void
57+
public function AddArgument(string $argument): void
6058
{
6159
$this->Arguments[] = $argument;
6260
}
@@ -68,31 +66,21 @@ public function Insert(): bool
6866
abort(500, 'BuildFailure::Insert(): BuildId not set.');
6967
}
7068

71-
$workingDirectory = $this->WorkingDirectory ?? '';
72-
$stdOutput = $this->StdOutput ?? '';
73-
$stdError = $this->StdError ?? '';
74-
$exitCondition = $this->ExitCondition ?? '';
75-
$language = $this->Language ?? '';
76-
$targetName = $this->TargetName ?? '';
77-
$outputFile = $this->OutputFile ?? '';
78-
$outputType = $this->OutputType ?? '';
79-
$sourceFile = $this->SourceFile ?? '';
80-
8169
$db = Database::getInstance();
8270

8371
/** @var RichBuildAlert $failure */
8472
$failure = Build::findOrFail((int) $this->BuildId)->richAlerts()->create([
85-
'workingdirectory' => $workingDirectory,
86-
'sourcefile' => $sourceFile,
73+
'workingdirectory' => $this->WorkingDirectory,
74+
'sourcefile' => $this->SourceFile,
8775
'newstatus' => 0,
8876
'type' => (int) $this->Type,
89-
'stdoutput' => $stdOutput,
90-
'stderror' => $stdError,
91-
'exitcondition' => $exitCondition,
92-
'language' => $language,
93-
'targetname' => $targetName,
94-
'outputfile' => $outputFile,
95-
'outputtype' => $outputType,
77+
'stdoutput' => $this->StdOutput,
78+
'stderror' => $this->StdError,
79+
'exitcondition' => $this->ExitCondition,
80+
'language' => $this->Language,
81+
'targetname' => $this->TargetName,
82+
'outputfile' => $this->OutputFile,
83+
'outputtype' => $this->OutputType,
9684
]);
9785

9886
// Insert the arguments
@@ -146,7 +134,7 @@ public function Insert(): bool
146134
/**
147135
* Retrieve the arguments from a build failure given its id.
148136
**/
149-
public function GetBuildFailureArguments($buildFailureId): array
137+
public function GetBuildFailureArguments(int $buildFailureId): array
150138
{
151139
$response = [
152140
'argumentfirst' => null,

app/cdash/tests/test_buildproperties.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function testUploadBuildProperties(): void
106106
$warning->WorkingDirectory = '/tmp';
107107
$warning->StdOutput = 'warning #1';
108108
$warning->StdError = 'this is a warning';
109-
$warning->ExitCondition = 0;
109+
$warning->ExitCondition = '0';
110110
$warning->Language = 'C';
111111
$warning->TargetName = 'foo';
112112
$warning->OutputFile = 'foo.lib';

phpstan-baseline.neon

Lines changed: 2 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -9870,69 +9870,27 @@ parameters:
98709870
count: 1
98719871
path: app/cdash/app/Model/BuildFailure.php
98729872

9873-
-
9874-
rawMessage: 'Method CDash\Model\BuildFailure::AddArgument() has parameter $argument with no type specified.'
9875-
identifier: missingType.parameter
9876-
count: 1
9877-
path: app/cdash/app/Model/BuildFailure.php
9878-
98799873
-
98809874
rawMessage: 'Method CDash\Model\BuildFailure::AddLabel() has parameter $label with no type specified.'
98819875
identifier: missingType.parameter
98829876
count: 1
98839877
path: app/cdash/app/Model/BuildFailure.php
98849878

9885-
-
9886-
rawMessage: 'Method CDash\Model\BuildFailure::GetBuildFailureArguments() has parameter $buildFailureId with no type specified.'
9887-
identifier: missingType.parameter
9888-
count: 1
9889-
path: app/cdash/app/Model/BuildFailure.php
9890-
98919879
-
98929880
rawMessage: 'Method CDash\Model\BuildFailure::GetBuildFailureArguments() return type has no value type specified in iterable type array.'
98939881
identifier: missingType.iterableValue
98949882
count: 1
98959883
path: app/cdash/app/Model/BuildFailure.php
98969884

9897-
-
9898-
rawMessage: Property CDash\Model\BuildFailure::$Arguments has no type specified.
9899-
identifier: missingType.property
9900-
count: 1
9901-
path: app/cdash/app/Model/BuildFailure.php
9902-
99039885
-
99049886
rawMessage: Property CDash\Model\BuildFailure::$BuildId has no type specified.
99059887
identifier: missingType.property
99069888
count: 1
99079889
path: app/cdash/app/Model/BuildFailure.php
99089890

99099891
-
9910-
rawMessage: Property CDash\Model\BuildFailure::$ExitCondition has no type specified.
9911-
identifier: missingType.property
9912-
count: 1
9913-
path: app/cdash/app/Model/BuildFailure.php
9914-
9915-
-
9916-
rawMessage: Property CDash\Model\BuildFailure::$Labels has no type specified.
9917-
identifier: missingType.property
9918-
count: 1
9919-
path: app/cdash/app/Model/BuildFailure.php
9920-
9921-
-
9922-
rawMessage: Property CDash\Model\BuildFailure::$Language has no type specified.
9923-
identifier: missingType.property
9924-
count: 1
9925-
path: app/cdash/app/Model/BuildFailure.php
9926-
9927-
-
9928-
rawMessage: Property CDash\Model\BuildFailure::$OutputFile has no type specified.
9929-
identifier: missingType.property
9930-
count: 1
9931-
path: app/cdash/app/Model/BuildFailure.php
9932-
9933-
-
9934-
rawMessage: Property CDash\Model\BuildFailure::$OutputType has no type specified.
9935-
identifier: missingType.property
9892+
rawMessage: Property CDash\Model\BuildFailure::$Labels type has no value type specified in iterable type array.
9893+
identifier: missingType.iterableValue
99369894
count: 1
99379895
path: app/cdash/app/Model/BuildFailure.php
99389896

@@ -9942,42 +9900,12 @@ parameters:
99429900
count: 1
99439901
path: app/cdash/app/Model/BuildFailure.php
99449902

9945-
-
9946-
rawMessage: Property CDash\Model\BuildFailure::$SourceFile has no type specified.
9947-
identifier: missingType.property
9948-
count: 1
9949-
path: app/cdash/app/Model/BuildFailure.php
9950-
9951-
-
9952-
rawMessage: Property CDash\Model\BuildFailure::$StdError has no type specified.
9953-
identifier: missingType.property
9954-
count: 1
9955-
path: app/cdash/app/Model/BuildFailure.php
9956-
9957-
-
9958-
rawMessage: Property CDash\Model\BuildFailure::$StdOutput has no type specified.
9959-
identifier: missingType.property
9960-
count: 1
9961-
path: app/cdash/app/Model/BuildFailure.php
9962-
9963-
-
9964-
rawMessage: Property CDash\Model\BuildFailure::$TargetName has no type specified.
9965-
identifier: missingType.property
9966-
count: 1
9967-
path: app/cdash/app/Model/BuildFailure.php
9968-
99699903
-
99709904
rawMessage: Property CDash\Model\BuildFailure::$Type has no type specified.
99719905
identifier: missingType.property
99729906
count: 1
99739907
path: app/cdash/app/Model/BuildFailure.php
99749908

9975-
-
9976-
rawMessage: Property CDash\Model\BuildFailure::$WorkingDirectory has no type specified.
9977-
identifier: missingType.property
9978-
count: 1
9979-
path: app/cdash/app/Model/BuildFailure.php
9980-
99819909
-
99829910
rawMessage: 'Method CDash\Model\BuildGroup::GetBuildGroups() has parameter $begin with no type specified.'
99839911
identifier: missingType.parameter

0 commit comments

Comments
 (0)