Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update phpstan #40

Merged
merged 2 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Admin/AutomationAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function configureViews(ViewCollection $viewCollection): void
}

/**
* {@inheritdoc}
* @return mixed[]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should contribute this back to sulu/sulu so we don't have this issue in every bundle.

If we are correct we would need to go with something like:

@return array<string, array<string, array<string, array<int, string>>>>

but think that would be to complex 🙈

*/
public function getSecurityContexts()
{
Expand Down
12 changes: 8 additions & 4 deletions Controller/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use FOS\RestBundle\View\ViewHandlerInterface;
use JMS\Serializer\DeserializationContext;
use JMS\Serializer\SerializerInterface;
use Nette\Utils\DateTime;
use Sulu\Bundle\AutomationBundle\Admin\AutomationAdmin;
use Sulu\Bundle\AutomationBundle\Entity\Task;
use Sulu\Bundle\AutomationBundle\Exception\TaskNotFoundException;
Expand Down Expand Up @@ -44,6 +43,9 @@
*/
class TaskController extends AbstractRestController implements ClassResourceInterface, SecuredControllerInterface
{
/**
* @var string[]
*/
private static $scheduleComparators = [
'future' => ListBuilderInterface::WHERE_COMPARATOR_GREATER_THAN,
'past' => ListBuilderInterface::WHERE_COMPARATOR_LESS,
Expand Down Expand Up @@ -287,7 +289,7 @@ public function postAction(Request $request): Response
$context
);

/** @var DateTime $date */
/** @var \DateTime $date */
$date = date_create_from_format('Y-m-d:H:i:s', $data['date'] . ':' . $data['time']);

$task->setSchedule($date);
Expand Down Expand Up @@ -325,7 +327,9 @@ public function putAction(string $id, Request $request): Response
$context
);

$task->setSchedule(date_create_from_format('Y-m-d:H:i:s', $data['date'] . ':' . $data['time']));
/** @var \DateTime $dateTime */
$dateTime = date_create_from_format('Y-m-d:H:i:s', $data['date'] . ':' . $data['time']);
$task->setSchedule($dateTime);
$task = $this->taskManager->update($task);

$this->entityManager->flush();
Expand Down Expand Up @@ -379,7 +383,7 @@ private function getFieldDescriptors(string $type = null): array
}

/**
* {@inheritdoc}
* @return string
Copy link
Member

@alexander-schranz alexander-schranz Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for this we should contribute this back to sulu release/2.0 branch (SecuredControllerInterface)

*/
public function getSecurityContext()
{
Expand Down
7 changes: 5 additions & 2 deletions Controller/TaskHandlerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Task\Handler\TaskHandlerFactoryInterface;
use Task\TaskBundle\Handler\TaskHandlerFactory;

/**
* Provides simple-api for task-handler.
Expand All @@ -28,9 +28,12 @@ class TaskHandlerController
{
use RequestParametersTrait;

/**
* @var TaskHandlerFactory
*/
protected $taskHandlerFactory;

public function __construct(TaskHandlerFactoryInterface $taskHandlerFactory)
public function __construct(TaskHandlerFactory $taskHandlerFactory)
{
$this->taskHandlerFactory = $taskHandlerFactory;
}
Expand Down
10 changes: 2 additions & 8 deletions DependencyInjection/SuluAutomationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ class SuluAutomationExtension extends Extension implements PrependExtensionInter
{
use PersistenceExtensionTrait;

/**
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container)
public function prepend(ContainerBuilder $container): void
{
if ($container->hasExtension('jms_serializer')) {
$container->prependExtensionConfig(
Expand Down Expand Up @@ -82,10 +79,7 @@ public function prepend(ContainerBuilder $container)
}
}

/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
Expand Down
6 changes: 3 additions & 3 deletions Entity/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Task implements TaskInterface
private $entityId;

/**
* @var string
* @var string|null
*/
private $taskId;

Expand Down Expand Up @@ -163,15 +163,15 @@ public function setEntityId(string $entityId): self
return $this;
}

public function getTaskId(): string
public function getTaskId(): ?string
alexander-schranz marked this conversation as resolved.
Show resolved Hide resolved
{
return $this->taskId;
}

/**
* @return self
*/
public function setTaskId(string $taskId): TaskInterface
public function setTaskId(?string $taskId): TaskInterface
{
$this->taskId = $taskId;

Expand Down
2 changes: 1 addition & 1 deletion Handler/DocumentPublishHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(DocumentManagerInterface $documentManager, Translato
}

/**
* {@inheritdoc}
* @param string $locale
*/
protected function handleDocument(WorkflowStageBehavior $document, $locale): void
{
Expand Down
2 changes: 1 addition & 1 deletion Handler/DocumentUnpublishHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(DocumentManagerInterface $documentManager, Translato
}

/**
* {@inheritdoc}
* @param string $locale
*/
protected function handleDocument(WorkflowStageBehavior $document, $locale): void
{
Expand Down
3 changes: 3 additions & 0 deletions Metadata/FormMetadataLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public function __construct(
$this->taskHandlerFactory = $taskHandlerFactory;
}

/**
* @param mixed[] $metadataOptions
*/
public function getMetadata(string $key, string $locale, array $metadataOptions): ?MetadataInterface
{
if ('task_details' !== $key) {
Expand Down
5 changes: 1 addition & 4 deletions PageTree/AutomationPageTreeUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ public function __construct(
$this->requestStack = $requestStack;
}

/**
* {@inheritdoc}
*/
public function update(BasePageDocument $document)
public function update(BasePageDocument $document): void
{
$request = $this->requestStack->getCurrentRequest();
if (!$request) {
Expand Down
2 changes: 1 addition & 1 deletion PageTree/PageTreeRouteUpdateHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function configureOptionsResolver(OptionsResolver $optionsResolver): Opti
/**
* {@inheritdoc}
*/
public function supports($entityClass): bool
public function supports(string $entityClass): bool
{
return is_subclass_of($entityClass, BasePageDocument::class);
}
Expand Down
4 changes: 2 additions & 2 deletions Serializer/TaskSerializerSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(
}

/**
* {@inheritdoc}
* @return mixed[]
*/
public static function getSubscribedEvents()
{
Expand Down Expand Up @@ -80,7 +80,7 @@ public function onTaskSerialize(ObjectEvent $event): void
);
}

$executions = $this->taskExecutionRepository->findByTaskUuid($object->getTaskId());
$executions = $this->taskExecutionRepository->findByTaskUuid((string) $object->getTaskId());
if (0 < count($executions)) {
/** @var SerializationVisitorInterface $serializationVisitor */
$serializationVisitor = $event->getVisitor();
Expand Down
5 changes: 1 addition & 4 deletions SuluAutomationBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ class SuluAutomationBundle extends Bundle
{
use PersistenceBundleTrait;

/**
* {@inheritdoc}
*/
public function build(ContainerBuilder $container)
public function build(ContainerBuilder $container): void
{
$this->buildPersistence(
[
Expand Down
2 changes: 1 addition & 1 deletion TaskHandler/TaskHandlerConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TaskHandlerConfiguration
/**
* Create a new configuration.
*
* @return static
* @return TaskHandlerConfiguration
*/
public static function create(string $title)
{
Expand Down
4 changes: 2 additions & 2 deletions Tasks/Model/TaskInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ public function getEntityId(): string;
/**
* Returns taskId.
*/
public function getTaskId(): string;
public function getTaskId(): ?string;

/**
* Set taskId.
*
* @return TaskInterface
*/
public function setTaskId(string $taskId): self;
public function setTaskId(?string $taskId): self;

/**
* Returns host.
Expand Down
4 changes: 2 additions & 2 deletions Tasks/Scheduler/TaskScheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function reschedule(TaskInterface $task): void
{
$workload = $this->createWorkload($task);

$phpTask = $this->taskRepository->findByUuid($task->getTaskId());
$phpTask = $this->taskRepository->findByUuid((string) $task->getTaskId());
$executions = $this->taskExecutionRepository->findByTask($phpTask);

if ($task->getSchedule() == $phpTask->getFirstExecution()
Expand Down Expand Up @@ -105,7 +105,7 @@ public function reschedule(TaskInterface $task): void
*/
public function remove(TaskInterface $task): void
{
$phpTask = $this->taskRepository->findByUuid($task->getTaskId());
$phpTask = $this->taskRepository->findByUuid((string) $task->getTaskId());
$this->taskRepository->remove($phpTask);
}

Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
"php-ffmpeg/php-ffmpeg": "^0.14.0",
"jackalope/jackalope-doctrine-dbal": "^1.3.0",
"zendframework/zendsearch": "@dev",
"phpstan/phpstan": "^0.11.12",
"phpstan/phpstan-doctrine": "^0.11.5",
"phpstan/phpstan-phpunit": "^0.11.2",
"phpstan/phpstan-symfony": "^0.11.6",
"thecodingmachine/phpstan-strict-rules": "^0.11.2",
"jangregor/phpstan-prophecy": "^0.4.1"
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-doctrine": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-symfony": "^0.12",
"thecodingmachine/phpstan-strict-rules": "^0.12",
"jangregor/phpstan-prophecy": "^0.8"
},
"autoload": {
"psr-4": {
Expand Down
5 changes: 3 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
includes:
- vendor/jangregor/phpstan-prophecy/src/extension.neon
- vendor/jangregor/phpstan-prophecy/extension.neon
- vendor/phpstan/phpstan-doctrine/extension.neon
- vendor/phpstan/phpstan-doctrine/rules.neon
- vendor/phpstan/phpstan-symfony/extension.neon
Expand All @@ -16,9 +16,10 @@ parameters:
- %currentWorkingDirectory%/Tests/*
- %currentWorkingDirectory%/vendor/*
symfony:
container_xml_path: %rootDir%/../../../Tests/Application/var/cache/admin/dev/adminAdminDevDebugProjectContainer.xml
container_xml_path: %rootDir%/../../../Tests/Application/var/cache/admin/test/Sulu_Bundle_AutomationBundle_Tests_Application_KernelTestDebugContainer.xml
console_application_loader: Tests/phpstan/console-application.php
doctrine:
objectManagerLoader: Tests/phpstan/object-manager.php
checkGenericClassInNonGenericObjectType: false
ignoreErrors:
- '#Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch()#'