apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -13,14 +13,8 @@ namespace Chill\TaskBundle\Workflow\Definition;
use Chill\TaskBundle\Entity\AbstractTask;
use Chill\TaskBundle\Entity\SingleTask;
use LogicException;
use Symfony\Component\Workflow\Transition;
use function array_key_exists;
use function array_slice;
use function explode;
use function implode;
class DefaultTaskDefinition implements \Chill\TaskBundle\Workflow\TaskWorkflowDefinition
{
final public const DEFINITION_METADATA = [
@@ -61,15 +55,15 @@ class DefaultTaskDefinition implements \Chill\TaskBundle\Workflow\TaskWorkflowDe
string $key,
$metadataSubject = null
) {
$keys = explode('.', $key);
$keys = \explode('.', $key);
switch ($keys[0]) {
case 'transition':
if (!$metadataSubject instanceof Transition) {
throw new LogicException('You must give a transition as metadatasubject');
throw new \LogicException('You must give a transition as metadatasubject');
}
return $this->getTransitionMetadata(implode('.', array_slice($keys, 1)), $metadataSubject);
return $this->getTransitionMetadata(\implode('.', \array_slice($keys, 1)), $metadataSubject);
case 'definition':
return self::DEFINITION_METADATA[$keys[1]] ?? $key;
@@ -81,23 +75,23 @@ class DefaultTaskDefinition implements \Chill\TaskBundle\Workflow\TaskWorkflowDe
public function isClosed(AbstractTask $task)
{
return array_key_exists('closed', $task->getCurrentStates())
|| array_key_exists('canceled', $task->getCurrentStates());
return \array_key_exists('closed', $task->getCurrentStates())
|| \array_key_exists('canceled', $task->getCurrentStates());
}
public function supports(AbstractTask $task)
{
return $task instanceof SingleTask
&& $task->getType() === 'task_default';
&& 'task_default' === $task->getType();
}
protected function getTransitionMetadata($key, Transition $transition)
{
if (!array_key_exists($transition->getName(), self::TRANSITION_METADATA)) {
if (!\array_key_exists($transition->getName(), self::TRANSITION_METADATA)) {
return $key;
}
if (!array_key_exists($key, self::TRANSITION_METADATA[$transition->getName()])) {
if (!\array_key_exists($key, self::TRANSITION_METADATA[$transition->getName()])) {
return $key;
}

View File

@@ -12,14 +12,10 @@ declare(strict_types=1);
namespace Chill\TaskBundle\Workflow;
use Chill\TaskBundle\Entity\AbstractTask;
use LogicException;
use Symfony\Component\Workflow\Event\Event;
use Symfony\Component\Workflow\SupportStrategy\WorkflowSupportStrategyInterface;
use Symfony\Component\Workflow\WorkflowInterface;
use function count;
use function sprintf;
class TaskWorkflowManager implements WorkflowSupportStrategyInterface
{
/**
@@ -33,9 +29,9 @@ class TaskWorkflowManager implements WorkflowSupportStrategyInterface
}
/**
* @throws LogicException
*
* @return TaskWorkflowDefinition
*
* @throws \LogicException
*/
public function getTaskWorkflowDefinition(AbstractTask $task)
{
@@ -47,21 +43,20 @@ class TaskWorkflowManager implements WorkflowSupportStrategyInterface
}
}
$count = count($definitions);
$count = \count($definitions);
if (1 < $count) {
throw new LogicException('More than one TaskWorkflowDefinition supports '
. 'this task. This should not happens.');
throw new \LogicException('More than one TaskWorkflowDefinition supports this task. This should not happens.');
}
if (0 === $count) {
throw new LogicException(sprintf('No taskWorkflowDefinition supports this task type: %s (task id: %s).', $task->getType(), $task->getId()));
throw new \LogicException(\sprintf('No taskWorkflowDefinition supports this task type: %s (task id: %s).', $task->getType(), $task->getId()));
}
return $definitions[0];
}
public function getWorkflowMetadata(AbstractTask $task, string $key, $metadataSubject = null, ?string $name = null)
public function getWorkflowMetadata(AbstractTask $task, string $key, $metadataSubject = null, string $name = null)
{
return $this->getTaskWorkflowDefinition($task)
->getWorkflowMetadata($task, $key, $metadataSubject);