Skip to content

Commit

Permalink
Update static testing, and fix newly found issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
kloor committed Aug 4, 2021
1 parent 494c0fb commit db412ff
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
21 changes: 17 additions & 4 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@
<rule ref="PSR12"/>

<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Generic.Classes.DuplicateClassName"/>
<rule ref="Generic.CodeAnalysis.AssignmentInCondition"/>
<rule ref="Generic.CodeAnalysis.EmptyPHPStatement"/>
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
<rule ref="Generic.CodeAnalysis.EmptyStatement">
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
</rule>
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<rule ref="Generic.Commenting.Fixme"/>
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<rule ref="Generic.Commenting.Todo"/>
<rule ref="Generic.Files.InlineHTML"/>
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<rule ref="Generic.Functions.CallTimePassByReference"/>
<rule ref="Generic.Metrics.CyclomaticComplexity"/>
<rule ref="Generic.Metrics.NestingLevel"/>
Expand All @@ -24,9 +29,18 @@
<rule ref="Generic.PHP.DiscourageGoto"/>
<rule ref="Generic.PHP.ForbiddenFunctions"/>
<rule ref="Generic.PHP.NoSilencedErrors"/>
<rule ref="Generic.PHP.SAPIUsage"/>
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<properties>
<property name="allowMultiline" value="true"/>
</properties>
</rule>

<rule ref="PEAR.Commenting.InlineComment"/>

<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<rule ref="Squiz.Classes.LowercaseClassKeywords"/>
<rule ref="Squiz.Classes.ClassFileName"/>
<rule ref="Squiz.Classes.SelfMemberReference"/>
<rule ref="Squiz.Commenting.DocCommentAlignment"/>
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
Expand Down Expand Up @@ -97,7 +111,6 @@
<rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/>
<rule ref="SlevomatCodingStandard.Commenting.UselessFunctionDocComment"/>
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing"/>
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowEmpty"/>
Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
ignoreInternalFunctionNullReturn="false"
resolveFromConfigFile="false"
sealAllMethods="true"
strictBinaryOperands="true"
>
<issueHandlers>
<PropertyNotSetInConstructor>
Expand Down
8 changes: 6 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ private function send(HttpRequest $request): string
}

if ($response->getStatusCode() !== self::HTTP_OK) {
$message = 'HTTP ' . $response->getStatusCode() . ' response';
$message = 'HTTP ' . (string) $response->getStatusCode() .
' response';

try {
$message .= self::parseJsonError(
Expand Down Expand Up @@ -408,7 +409,10 @@ private static function parseJsonError(object $json): string
{
if (isset($json->errors)) {
if (\is_array($json->errors)) {
return ': ' . \implode('; ', $json->errors);
/** @var string[] */
$errors = $json->errors;

return ': ' . \implode('; ', $errors);
}

if (\is_string($json->errors)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected static function decodeJson(string $data)
return \json_decode(
$data,
false,
Data::JSON_DEPTH,
self::JSON_DEPTH,
\JSON_THROW_ON_ERROR
);
} catch (\Throwable $exception) {
Expand Down
4 changes: 3 additions & 1 deletion src/Data/Space/Reserve/PayloadReserveSpaceData.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public function json(): string
continue;
}

$data[$key] = \implode(', ', $data[$key]);
/** @var string[] */
$strings = $data[$key];
$data[$key] = \implode(', ', $strings);
}

try {
Expand Down

0 comments on commit db412ff

Please sign in to comment.