Skip to content

Commit

Permalink
PHPstan, level 1
Browse files Browse the repository at this point in the history
  • Loading branch information
janhenckens committed Dec 28, 2023
1 parent 26066cb commit a9d9318
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ includes:
- vendor/craftcms/phpstan/phpstan.neon

parameters:
level: 5
level: 1
paths:
- src
1 change: 1 addition & 0 deletions src/Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ private function registerFormie()
function(RegisterExportableElementTypes $event) {
$model = new ExportableFormieSubmissionModel();
$event->elementTypes = array_merge($event->elementTypes, [
/** @phpstan-ignore-next-line */
\verbb\formie\elements\Submission::class => $model,
]);
});
Expand Down
3 changes: 1 addition & 2 deletions src/console/controllers/ExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public function actionDebug($id): bool
$data[] = array_merge($attributes, $fields);

foreach ($query->limit(1)->all() as $element) {
d($element->id);
$values = $element->toArray(array_keys($export->getAttributes()));
// Convert values to strings
$row = array_map(function($item) {
Expand All @@ -54,7 +53,7 @@ public function actionDebug($id): bool

// Fetch the custom field content, already prepped
$fieldValues = $export->parseFieldValues($element);
dd($fieldValues);
var_dump($row); exit;
$data[] = array_merge($row, $fieldValues);
}

Expand Down
5 changes: 3 additions & 2 deletions src/elements/ExportElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,10 @@ public function getSupportedFields(Element $element): array
$supportedFields = Exporter::getInstance()->fields->getAvailableFieldTypes();
$elementFields = $element->fieldLayout->getCustomFields();

return array_filter($elementFields, function($field) use ($supportedFields) {
return array_filter($elementFields, function($field) {
// TODO How to handle unsupported fields here?
return true;
// return in_array(get_class($field), $supportedFields);

});
}

Expand Down
4 changes: 2 additions & 2 deletions src/fields/MoneyFieldParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public function getOptionType(): string|bool

protected function getOptionLabel(): string|bool
{
// TODO: Implement getOptionLabel() method.
return false;
}

protected function getOptionDescription(): string|bool
{
// TODO: Implement getOptionDescription() method.
return false;
}
}
4 changes: 2 additions & 2 deletions src/fields/PlainTextParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public function getOptionType(): string|bool

protected function getOptionLabel(): string|bool
{
// TODO: Implement getOptionLabel() method.
return false;
}

protected function getOptionDescription(): string|bool
{
// TODO: Implement getOptionDescription() method.
return false;
}
}
1 change: 1 addition & 0 deletions src/models/ExportableFormieSubmissionModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class ExportableFormieSubmissionModel extends ExportableElementTypeModel
{
/** @phpstan-ignore-next-line */
public $elementType = Submission::class;

public string $elementLabel = "Formie Submissions";
Expand Down
1 change: 1 addition & 0 deletions src/models/ExportableFreeformSubmissionModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class ExportableFreeformSubmissionModel extends ExportableElementTypeModel
{
/** @phpstan-ignore-next-line */
public $elementType = Submission::class;

public string $elementLabel = "Freeform Submissions";
Expand Down
2 changes: 1 addition & 1 deletion src/services/ExportQueryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function getFields(ExportElement $export, Element $element): array
$object = Craft::createObject($parser);

if (!isset($field['handle'])) {
throw new FieldNotFoundException();
throw new FieldNotFoundException($craftField->uid, "Field not found");
}

$data[$field['handle']] = $object->getValue($element, $field);
Expand Down

0 comments on commit a9d9318

Please sign in to comment.