Skip to content

Commit

Permalink
PHPstan level 4
Browse files Browse the repository at this point in the history
  • Loading branch information
janhenckens committed Dec 28, 2023
1 parent a9d9318 commit faf79cb
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 7 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: 1
level: 4
paths:
- src
2 changes: 1 addition & 1 deletion src/console/controllers/ExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 4 additions & 0 deletions src/controllers/ElementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down
9 changes: 6 additions & 3 deletions src/fields/RelationFieldParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/services/formats/Csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
1 change: 1 addition & 0 deletions src/services/formats/Xlsx.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
2 changes: 0 additions & 2 deletions src/variables/ExporterVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public function listenForJob(ExportElement $export)
{
$class = ExportBatchJob::class;
$reflect = new ReflectionClass($class);
$reflect->getShortName();


$query = new Query();
$query->from("{{%queue}}")
Expand Down

0 comments on commit faf79cb

Please sign in to comment.