Skip to content

Commit

Permalink
fix phpstan issues
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat committed Jan 13, 2025
1 parent d6c1cc1 commit ed009f8
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 41 deletions.
4 changes: 1 addition & 3 deletions src/Builder/FrontendFormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ public function buildForm(
'form_template' => null
];

if (is_array($formRuntimeData)) {
$formRuntimeData = array_merge($defaults, $formRuntimeData);
}
$formRuntimeData = array_merge($defaults, $formRuntimeData);

/** @var Request $request */
$request = $this->requestStack->getCurrentRequest();
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Admin/OutputWorkflowController.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function saveOutputWorkflowAction(Request $request, int $outputWorkflowId
if ($form->isValid()) {
$this->outputWorkflowManager->saveRawEntity($outputWorkflow);
} else {
/** @var FormError $e */

foreach ($form->getErrors(true, true) as $e) {
$errorMessageTemplate = $e->getMessageTemplate();
foreach ($e->getMessageParameters() as $key => $value) {
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Type/FormBuilderFieldsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform): array
if ($field['type'] === 'container') {
$formField = $this->formDefinitionFactory->createFormFieldContainerDefinition();
$this->populateFormField($formField, $field);
if ($formField instanceof SubFieldsAwareInterface && isset($field['fields']) && is_array($field['fields'])) {
if (isset($field['fields']) && is_array($field['fields'])) {
$subFields = [];
foreach ($field['fields'] as $subField) {
$subFormField = $this->formDefinitionFactory->createFormFieldDefinition();
Expand Down
2 changes: 1 addition & 1 deletion src/Event/FormAssembleEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function getFormOptionsResolver(): FormOptionsResolver
return $this->formOptionsResolver;
}

public function getForm(): FormInterface
public function getForm(): ?FormInterface
{
return $this->form;
}
Expand Down
8 changes: 0 additions & 8 deletions src/EventSubscriber/SignalStorage/FormDataSignalStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ public function storeSignal(OutputWorkflowSignalEvent $signal): void
$storageToken = $this->funnelData->getStorageToken();
$formStorageData = $this->funnelData->getFormStorageData();

if (!$formStorageData instanceof FormStorageData) {
throw new \Exception('Cannot store signal without valid FormStorageData');
}

if ($signal->getName() !== AttachmentStream::SIGNAL_CLEAN_UP) {
throw new \Exception(sprintf('FormDataSignalStorage only supports signal events of type "%s"', AttachmentStream::SIGNAL_CLEAN_UP));
}
Expand All @@ -62,10 +58,6 @@ public function getSignals(): array
{
$formStorageData = $this->funnelData->getFormStorageData();

if (!$formStorageData instanceof FormStorageData) {
return [];
}

$restoredAttachmentSignalEvents = [];
/** @var FileStack $fileStack */
foreach ($formStorageData->getAttachmentSignals() as $fileStack) {
Expand Down
2 changes: 1 addition & 1 deletion src/Migrations/Version20230830183642.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private function migrateMailLayout(array $configuration): ?array
return $configuration;
}

protected function parseSquareBracketsTag(array $tag): ?string
protected function parseSquareBracketsTag(array $tag): string
{
$type = $tag[1];
$config = $this->parseSquareBracketsAttributes($tag[2]);
Expand Down
2 changes: 1 addition & 1 deletion src/Model/FormDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function getName(): string

public function setGroup(?string $groupName = null): void
{
$this->group = !empty($groupName) && is_string($groupName) ? $groupName : null;
$this->group = !empty($groupName) ? $groupName : null;
}

public function getGroup(): ?string
Expand Down
18 changes: 5 additions & 13 deletions src/OutputWorkflow/Channel/Object/AbstractObjectResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,6 @@ protected function processObject(DataObject\Concrete $object): void

$formData = $this->formValuesOutputApplier->applyForChannel($this->getForm(), [], 'object', $this->getLocale());

if (!is_array($formData)) {
return;
}

$this->processObjectData($object, $formData);
}

Expand Down Expand Up @@ -447,15 +443,11 @@ protected function dispatchGuardEvent(mixed $subject): DataObject\Fieldcollectio
protected function getObjectFieldDefinition(mixed $object, string $fieldName): ?DataObject\ClassDefinition\Data
{
if ($object instanceof DataObject\Concrete) {
$classDefinition = $object->getClass();
if ($classDefinition instanceof DataObject\ClassDefinition) {
return $classDefinition->getFieldDefinition($fieldName);
}
} elseif ($object instanceof DataObject\Fieldcollection\Data\AbstractData) {
$classDefinition = $object->getDefinition();
if ($classDefinition instanceof DataObject\Fieldcollection\Definition) {
return $classDefinition->getFieldDefinition($fieldName);
}
return $object->getClass()->getFieldDefinition($fieldName);
}

if ($object instanceof DataObject\Fieldcollection\Data\AbstractData) {
return $object->getDefinition()->getFieldDefinition($fieldName);
}

return null;
Expand Down
8 changes: 0 additions & 8 deletions src/OutputWorkflow/FunnelWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ public function processFunnel(OutputWorkflowInterface $outputWorkflow, Request $
{
$funnelData = $this->funnelDataResolver->getFunnelData($request);

if (!$funnelData instanceof FunnelData) {
throw new \Exception($request, 'Invalid Funnel Data');
}

if (!$outputWorkflow->isFunnelWorkflow()) {
throw new \Exception(sprintf('Funnel with id %d is not a valid funnel', $outputWorkflow->getId()));
}
Expand All @@ -121,10 +117,6 @@ public function processFunnel(OutputWorkflowInterface $outputWorkflow, Request $

$formStorageData = $funnelData->getFormStorageData();

if (!$formStorageData instanceof FormStorageData) {
throw new \Exception(sprintf('No storage data for token "%s" found', $storageToken));
}

// restore submission event to allow seamless output workflow channel processing
$submissionEvent = $this->buildSubmissionEvent($request, $outputWorkflow, $formStorageData);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ protected function applyActions(bool $validationState, array $actions, array $fo

$appliedData = $this->conditionalLogicRegistry->getAction($action['type'])->setValues($action)->apply($validationState, $formData, $ruleId);

if (!$appliedData instanceof ReturnStackInterface) {
continue;
}

//If field is available: only add affected field data to return container!
if (!$field instanceof FieldDefinitionInterface) {
$returnContainer[] = $appliedData;
Expand Down

0 comments on commit ed009f8

Please sign in to comment.