Skip to content

Commit

Permalink
Merge pull request ecamp#3129 from ecamp/renovate/php-linter
Browse files Browse the repository at this point in the history
chore(deps): update php-linter
  • Loading branch information
BacLuc authored Nov 5, 2022
2 parents 3478660 + dd7fa83 commit 639f4a8
Show file tree
Hide file tree
Showing 58 changed files with 254 additions and 329 deletions.
4 changes: 2 additions & 2 deletions api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
"webonyx/graphql-php": "14.11.8"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "3.12.0",
"friendsofphp/php-cs-fixer": "3.13.0",
"hautelook/alice-bundle": "2.11.0",
"justinrainbow/json-schema": "5.2.12",
"php-coveralls/php-coveralls": "2.5.3",
"phpstan/phpstan": "1.8.11",
"phpstan/phpstan": "1.9.1",
"phpunit/phpunit": "9.5.26",
"rector/rector": "0.14.6",
"symfony/browser-kit": "6.1.3",
Expand Down
44 changes: 22 additions & 22 deletions api/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions api/src/DataPersister/ResetPasswordDataPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use App\Service\MailService;
use App\Util\IdGenerator;
use Doctrine\ORM\EntityManagerInterface;
use Exception;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactoryInterface;
use Symfony\Component\PasswordHasher\PasswordHasherInterface;
Expand Down Expand Up @@ -41,7 +40,7 @@ public function persist($data, array $context = []): void {
}

public function remove($data, array $context = []) {
throw new Exception('ResetPasswordDataPersister->remove() is not implemented');
throw new \Exception('ResetPasswordDataPersister->remove() is not implemented');
}

public function beforeCreate(ResetPassword $data): ResetPassword {
Expand Down
5 changes: 2 additions & 3 deletions api/src/DataPersister/Util/AbstractDataPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use ApiPlatform\Core\DataPersister\ContextAwareDataPersisterInterface;
use App\Entity\BaseEntity;
use InvalidArgumentException;

abstract class AbstractDataPersister implements ContextAwareDataPersisterInterface {
/**
Expand All @@ -19,12 +18,12 @@ public function __construct(
) {
foreach ($this->customActionListeners as $listener) {
if (!$listener instanceof CustomActionListener) {
throw new InvalidArgumentException('customActionListeners must be of type '.CustomActionListener::class);
throw new \InvalidArgumentException('customActionListeners must be of type '.CustomActionListener::class);
}
}
foreach ($this->propertyChangeListeners as $listener) {
if (!$listener instanceof PropertyChangeListener) {
throw new InvalidArgumentException('propertyChangeListeners must be of type '.PropertyChangeListener::class);
throw new \InvalidArgumentException('propertyChangeListeners must be of type '.PropertyChangeListener::class);
}
}
}
Expand Down
19 changes: 8 additions & 11 deletions api/src/DataPersister/Util/CustomActionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

namespace App\DataPersister\Util;

use Closure;
use ReflectionFunction;

class CustomActionListener {
private function __construct(
private string $actionName,
private Closure $beforeAction,
private Closure $afterAction
private \Closure $beforeAction,
private \Closure $afterAction
) {
}

Expand All @@ -18,8 +15,8 @@ private function __construct(
*/
public static function of(
string $actionName,
?Closure $beforeAction = null,
?Closure $afterAction = null
?\Closure $beforeAction = null,
?\Closure $afterAction = null
): CustomActionListener {
if (null == $beforeAction) {
$beforeAction = fn ($data) => $data;
Expand All @@ -42,19 +39,19 @@ public function getActionName(): string {
return $this->actionName;
}

public function getBeforeAction(): Closure {
public function getBeforeAction(): \Closure {
return $this->beforeAction;
}

public function getAfterAction(): Closure {
public function getAfterAction(): \Closure {
return $this->afterAction;
}

/**
* @throws \ReflectionException
*/
private static function hasOneParameter(?Closure $beforeAction): bool {
$beforeActionReflectionFunction = new ReflectionFunction($beforeAction);
private static function hasOneParameter(?\Closure $beforeAction): bool {
$beforeActionReflectionFunction = new \ReflectionFunction($beforeAction);

return 1 != $beforeActionReflectionFunction->getNumberOfParameters();
}
Expand Down
25 changes: 12 additions & 13 deletions api/src/DataPersister/Util/DataPersisterObservable.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
namespace App\DataPersister\Util;

use ApiPlatform\Core\DataPersister\ContextAwareDataPersisterInterface;
use Closure;
use Symfony\Component\HttpFoundation\RequestStack;

class DataPersisterObservable {
private Closure $onBeforeCreate;
private Closure $onAfterCreate;
private Closure $onBeforeUpdate;
private Closure $onAfterUpdate;
private Closure $onBeforeRemove;
private Closure $onAfterRemove;
private \Closure $onBeforeCreate;
private \Closure $onAfterCreate;
private \Closure $onBeforeUpdate;
private \Closure $onAfterUpdate;
private \Closure $onBeforeRemove;
private \Closure $onAfterRemove;

/**
* @var CustomActionListener[]
Expand Down Expand Up @@ -43,37 +42,37 @@ public function supports($data, array $context): bool {
return $this->dataPersister->supports($data, $context);
}

public function onBeforeCreate(Closure $onBeforeCreate): self {
public function onBeforeCreate(\Closure $onBeforeCreate): self {
$this->onBeforeCreate = $onBeforeCreate;

return $this;
}

public function onAfterCreate(Closure $onAfterCreate): self {
public function onAfterCreate(\Closure $onAfterCreate): self {
$this->onAfterCreate = $onAfterCreate;

return $this;
}

public function onBeforeUpdate(Closure $onBeforeUpdate): self {
public function onBeforeUpdate(\Closure $onBeforeUpdate): self {
$this->onBeforeUpdate = $onBeforeUpdate;

return $this;
}

public function onAfterUpdate(Closure $onAfterUpdate): self {
public function onAfterUpdate(\Closure $onAfterUpdate): self {
$this->onAfterUpdate = $onAfterUpdate;

return $this;
}

public function onBeforeRemove(Closure $onBeforeRemove): self {
public function onBeforeRemove(\Closure $onBeforeRemove): self {
$this->onBeforeRemove = $onBeforeRemove;

return $this;
}

public function onAfterRemove(Closure $onAfterRemove): self {
public function onAfterRemove(\Closure $onAfterRemove): self {
$this->onAfterRemove = $onAfterRemove;

return $this;
Expand Down
25 changes: 11 additions & 14 deletions api/src/DataPersister/Util/PropertyChangeListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,21 @@

namespace App\DataPersister\Util;

use Closure;
use ReflectionFunction;

class PropertyChangeListener {
private function __construct(
private Closure $extractProperty,
private Closure $beforeAction,
private Closure $afterAction
private \Closure $extractProperty,
private \Closure $beforeAction,
private \Closure $afterAction
) {
}

/**
* @throws \ReflectionException
*/
public static function of(
Closure $extractProperty,
?Closure $beforeAction = null,
?Closure $afterAction = null
\Closure $extractProperty,
?\Closure $beforeAction = null,
?\Closure $afterAction = null
): PropertyChangeListener {
if (null == $beforeAction) {
$beforeAction = function ($data) {
Expand All @@ -42,23 +39,23 @@ public static function of(
return new PropertyChangeListener($extractProperty, $beforeAction, $afterAction);
}

public function getExtractProperty(): Closure {
public function getExtractProperty(): \Closure {
return $this->extractProperty;
}

public function getBeforeAction(): Closure {
public function getBeforeAction(): \Closure {
return $this->beforeAction;
}

public function getAfterAction(): Closure {
public function getAfterAction(): \Closure {
return $this->afterAction;
}

/**
* @throws \ReflectionException
*/
private static function hasOneParameter(?Closure $beforeAction): bool {
$beforeActionReflectionFunction = new ReflectionFunction($beforeAction);
private static function hasOneParameter(?\Closure $beforeAction): bool {
$beforeActionReflectionFunction = new \ReflectionFunction($beforeAction);

return 1 != $beforeActionReflectionFunction->getNumberOfParameters();
}
Expand Down
5 changes: 2 additions & 3 deletions api/src/Entity/BaseEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use ApiPlatform\Core\Annotation\ApiProperty;
use App\Util\IdGenerator;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Serializer\Annotation\Groups;
Expand All @@ -25,12 +24,12 @@ abstract class BaseEntity {
#[ApiProperty(writable: false)]
#[Gedmo\Timestampable(on: 'create')]
#[ORM\Column(type: 'datetime')]
protected DateTime $createTime;
protected \DateTime $createTime;

#[ApiProperty(writable: false)]
#[Gedmo\Timestampable(on: 'update')]
#[ORM\Column(type: 'datetime')]
protected DateTime $updateTime;
protected \DateTime $updateTime;

public function __construct() {
$this->id = IdGenerator::generateRandomHexString(12);
Expand Down
Loading

0 comments on commit 639f4a8

Please sign in to comment.