[TOOLS][PHPStan] Raise PHPStan level to 3 and fix new errors

This commit is contained in:
Hugo Sales 2021-09-09 01:08:45 +01:00
parent 9d7f43cd28
commit b74d944ae3
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
6 changed files with 17 additions and 4 deletions

View File

@ -1,5 +1,5 @@
parameters:
level: 2
level: 3
bootstrapFiles:
- config/bootstrap.php
earlyTerminatingMethodCalls:
@ -10,6 +10,10 @@ parameters:
message: '/Access to an undefined property App\\Util\\Bitmap::\$\w+/'
paths:
- *
# -
# message: '/has no return typehint specified/'
# paths:
# - tests/*
services:
-

View File

@ -182,7 +182,7 @@ class AttachmentEmbed extends Entity
/**
* Generate the Embed thumbnail HTML attributes
*
* @return string[] ['class' => "string", 'has_attachment' => "bool", 'height' => "int|null", 'width' => "int|null"]
* @return mixed[] ['class' => string, 'has_attachment' => bool, 'height' => int|null, 'width' => int|null]
*/
public function getImageHTMLAttributes(): array
{

View File

@ -36,6 +36,7 @@ use App\Util\Formatting;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Form as SymfForm;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface as SymfFormInterface;
use Symfony\Component\HttpFoundation\Request;
/**
@ -86,7 +87,7 @@ abstract class Form
?object $target = null,
array $extra_data = [],
string $type = 'Symfony\Component\Form\Extension\Core\Type\FormType',
array $form_options = []): SymfForm
array $form_options = []): SymfFormInterface
{
$name = $form[array_key_last($form)][0];
$fb = self::$form_factory->createNamedBuilder($name, $type, data: null, options: array_merge($form_options, ['translation_domain' => false]));

View File

@ -30,6 +30,7 @@
namespace App\Core;
use App\Entity\LocalUser;
use HtmlSanitizer\SanitizerInterface;
use Symfony\Component\Security\Core\Security as SymfonySecurity;
@ -40,6 +41,8 @@ use Symfony\Component\Security\Core\Security as SymfonySecurity;
* @codeCoverageIgnore
* @mixin SymfonySecurity
* @mixin SanitizerInterface
*
* @method static LocalUser getUser()
*/
abstract class Security
{

View File

@ -104,6 +104,10 @@ abstract class Common
public static function user(): ?LocalUser
{
// This returns the user stored in the session. We only use
// LocalUser, but this is more generic and returns
// UserInterface, so we need a type cast
/** @var LocalUser */
return Security::getUser();
}

View File

@ -84,7 +84,8 @@ class ExtensionTest extends GNUsocialTestCase
public function testIsCurrentRouteActive()
{
$req = $this->createMock(Request::class);
$req = $this->createMock(Request::class);
// @phpstan-ignore-next-line
$req->attributes = new class {
public function get(string $arg)
{