mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-12 11:24:31 +02:00
Fixed PHPstan issues for level 5.
This commit is contained in:
parent
a9293b7ceb
commit
da72f5b3ec
24 changed files with 87 additions and 49 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue