[TOOLS] Fix errors pointed out by PHPStan level 4

This commit is contained in:
2022-10-19 22:38:49 +01:00
parent 4d7742e0e1
commit edeee49af9
37 changed files with 168 additions and 198 deletions

View File

@@ -14,6 +14,7 @@ use App\Entity\LocalUser;
use App\Entity\Note;
use App\Util\Exception\BugFoundException;
use App\Util\Exception\ClientException;
use App\Util\Exception\InvalidRequestException;
use App\Util\Exception\ServerException;
use App\Util\Formatting;
use Component\Conversation\Conversation;
@@ -68,11 +69,13 @@ class APIv1 extends Controller
// $encoder = new XmlEncoder();
// $xml = $encoder->encode($result, 'xml');
[$tag_names, $keys] = F\zip(...F\map(array_keys($result), fn (string $k) => explode('_', $k)));
$xml = new SimpleXMLElement('<' . $tag_names[0] . '/>');
dd($tag_names, $keys, $result, $xml, (string) $xml);
$xml->addChild();
dd($xml);
return new Response(content: $xml, status: $statis);
$xml = new SimpleXMLElement('<' . $tag_names[0] . '/>');
// dd($tag_names, $keys, $result, $xml, (string) $xml);
// $xml->addChild();
// dd($xml);
return new Response(content: $xml, status: $status);
} else {
throw new InvalidRequestException;
}
}
@@ -308,7 +311,7 @@ class APIv1 extends Controller
} elseif (!\is_null($day)) {
$day = new DateTimeImmutable($day);
$pins = DB::findBy(Pin::class, ['actor_id' => $user->getId(), 'gte' => ['modified' => $day], 'lt' => ['modified' => $day->modify('+1 day')]]);
} elseif (!\is_null($url)) {
} elseif (!\is_null($url)) { // @phpstan-ignore-line this is here for clarity
$pins = DB::findBy(Pin::class, ['actor_id' => $user->getId(), 'url_hash' => hash('sha256', $url)]);
} else {
throw new BugFoundException('Wonky logic in pinboard/posts/get');