Fixed PHPstan issues for level 5.

This commit is contained in:
Jan Böhmer 2020-02-01 19:42:28 +01:00
parent a9293b7ceb
commit da72f5b3ec
24 changed files with 87 additions and 49 deletions

View file

@ -91,7 +91,7 @@ class AttachmentReverseSearch
$this->cacheManager->remove($this->attachmentURLGenerator->absolutePathToAssetPath($file->getPathname()));
$fs = new Filesystem();
$fs->remove($file);
$fs->remove($file->getPathname());
return true;
}

View file

@ -25,6 +25,7 @@ declare(strict_types=1);
namespace App\Services;
use App\Entity\Base\StructuralDBElement;
use Symfony\Bundle\MakerBundle\Str;
use function count;
use Doctrine\ORM\EntityManagerInterface;
use InvalidArgumentException;
@ -133,7 +134,7 @@ class EntityImporter
$tmp = $this->validator->validate($entity);
//When no validation error occured, persist entity to database (cascade must be set in entity)
if (0 === count($errors)) {
if (empty($tmp)) {
$this->em->persist($entity);
} else { //Log validation errors to global log.
$errors[$entity->getFullPath()] = $tmp;
@ -210,7 +211,7 @@ class EntityImporter
* This functions corrects the parent setting based on the children value of the parent.
*
* @param iterable $entities the list of entities that should be fixed
* @param null $parent the parent, to which the entity should be set
* @param null|StructuralDBElement $parent the parent, to which the entity should be set
*/
protected function correctParentEntites(iterable $entities, $parent = null): void
{

View file

@ -96,19 +96,19 @@ class PasswordResetManager
/**
* Sets the new password of the user with the given name, if the token is valid.
*
* @param string $user The name of the user, which password should be reset
* @param string $username The name of the user, which password should be reset
* @param string $token The token that should be used to reset the password
* @param string $new_password The new password that should be applied to user
*
* @return bool Returns true, if the new password was applied. False, if either the username is unknown or the
* token is invalid or expired.
*/
public function setNewPassword(string $user, string $token, string $new_password): bool
public function setNewPassword(string $username, string $token, string $new_password): bool
{
//Try to find the user
$repo = $this->em->getRepository(User::class);
/** @var User $user */
$user = $repo->findOneBy(['name' => $user]);
/** @var User|null $user */
$user = $repo->findOneBy(['name' => $username]);
//If no user matching the name, show an error message
if (null === $user) {

View file

@ -25,6 +25,7 @@ declare(strict_types=1);
namespace App\Services;
use App\Configuration\PermissionsConfiguration;
use App\Entity\UserSystem\Group;
use App\Entity\UserSystem\User;
use App\Security\Interfaces\HasPermissionsInterface;
use Symfony\Component\Config\ConfigCache;
@ -109,6 +110,7 @@ class PermissionResolver
return $allowed;
}
/** @var HasPermissionsInterface $parent */
$parent = $user->getGroup();
while (null !== $parent) { //The top group, has parent == null
//Check if our current element gives a info about disallow/allow

View file

@ -191,7 +191,7 @@ class PricedetailHelper
$val_base = $value;
if (null !== $originCurrency) {
//Without an exchange rate we can not calculate the exchange rate
if (0 === (float) $originCurrency->getExchangeRate()) {
if (0.0 === (float) $originCurrency->getExchangeRate()) {
return null;
}