diff --git a/phpstan.neon b/phpstan.neon index 32fb8a6..128dc09 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,6 +2,6 @@ includes: - vendor/craftcms/phpstan/phpstan.neon parameters: - level: 1 + level: 4 paths: - src \ No newline at end of file diff --git a/src/console/controllers/ExportController.php b/src/console/controllers/ExportController.php index 1defaa8..7f122ea 100644 --- a/src/console/controllers/ExportController.php +++ b/src/console/controllers/ExportController.php @@ -53,7 +53,7 @@ public function actionDebug($id): bool // Fetch the custom field content, already prepped $fieldValues = $export->parseFieldValues($element); - var_dump($row); exit; + // var_dump($row); exit; $data[] = array_merge($row, $fieldValues); } diff --git a/src/controllers/ElementController.php b/src/controllers/ElementController.php index fcf7ae8..a7fd4a0 100644 --- a/src/controllers/ElementController.php +++ b/src/controllers/ElementController.php @@ -41,6 +41,7 @@ public function actionRunExport() $export->validate(); if ($export->getErrors()) { + /** @phpstan-ignore-next-line */ Craft::$app->getUrlManager()->setRouteParams([ "export" => $export, "errors" => $export->getErrors(), @@ -170,6 +171,7 @@ public function actionStep1() $export->validate(); if ($export->getErrors()) { + /** @phpstan-ignore-next-line */ Craft::$app->getUrlManager()->setRouteParams([ "export" => $export, "errors" => $export->getErrors(), @@ -200,6 +202,7 @@ public function actionStep2() $export->validate(); if ($export->getErrors()) { + /** @phpstan-ignore-next-line */ Craft::$app->getUrlManager()->setRouteParams([ "export" => $export, "errors" => $export->getErrors(), @@ -226,6 +229,7 @@ public function actionStep3() $export->validate(); if ($export->getErrors()) { + /** @phpstan-ignore-next-line */ Craft::$app->getUrlManager()->setRouteParams([ "export" => $export, "errors" => $export->getErrors(), diff --git a/src/fields/RelationFieldParser.php b/src/fields/RelationFieldParser.php index 989b6f7..8da0fca 100644 --- a/src/fields/RelationFieldParser.php +++ b/src/fields/RelationFieldParser.php @@ -9,14 +9,17 @@ class RelationFieldParser extends BaseFieldParser { public function getValue(Element $element, array $field) { + /** @var Element|null $element */ + $relation = $element->getFieldValue($field['handle'])->one(); $property = $field['property']; if ($relation) { - return $relation->$property; + if (isset($relation->$property)) { + return $relation->$property; + } + return $relation->id; } - - return $relation->id; } public function getOptions(): array diff --git a/src/services/formats/Csv.php b/src/services/formats/Csv.php index 5bfb383..ce48857 100644 --- a/src/services/formats/Csv.php +++ b/src/services/formats/Csv.php @@ -30,6 +30,7 @@ public function create(ExportElement $export, array $data, $fileName): string try { ob_end_clean(); + /** @phpstan-ignore-next-line */ } catch (\Throwable $e) { Craft::error($e->getMessage()); } diff --git a/src/services/formats/Xlsx.php b/src/services/formats/Xlsx.php index 511207c..7256542 100644 --- a/src/services/formats/Xlsx.php +++ b/src/services/formats/Xlsx.php @@ -30,6 +30,7 @@ public function create(ExportElement $export, array $data, $fileName): string try { ob_end_clean(); + /** @phpstan-ignore-next-line */ } catch (\Throwable $e) { Craft::error($e->getMessage()); } diff --git a/src/variables/ExporterVariable.php b/src/variables/ExporterVariable.php index 4dde9d1..d22cee2 100644 --- a/src/variables/ExporterVariable.php +++ b/src/variables/ExporterVariable.php @@ -23,8 +23,6 @@ public function listenForJob(ExportElement $export) { $class = ExportBatchJob::class; $reflect = new ReflectionClass($class); - $reflect->getShortName(); - $query = new Query(); $query->from("{{%queue}}")