Skip to content

Commit

Permalink
Don't use data pointers in form render arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic Tubach committed Aug 10, 2023
1 parent e8a3fce commit 05c2fcc
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 17 deletions.
12 changes: 7 additions & 5 deletions src/JsonForms/Definition/Control/ArrayControlDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

namespace Drupal\json_forms\JsonForms\Definition\Control;

use Drupal\json_forms\Util\ConvertUtil;

final class ArrayControlDefinition extends ControlDefinition {

public function getItems(): ?\stdClass {
Expand All @@ -35,27 +37,27 @@ public function getPrefixItems(): ?array {
}

public function getMaxItems(): ?int {
return $this->propertySchema->maxItems ?? NULL;
return ConvertUtil::stdClassToNull($this->propertySchema->maxItems ?? NULL);

Check failure on line 40 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMaxItems() should return int|null but returns mixed.

Check failure on line 40 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMaxItems() should return int|null but returns mixed.

Check failure on line 40 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMaxItems() should return int|null but returns mixed.

Check failure on line 40 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMaxItems() should return int|null but returns mixed.

Check failure on line 40 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMaxItems() should return int|null but returns mixed.

Check failure on line 40 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMaxItems() should return int|null but returns mixed.
}

public function getMinItems(): ?int {
return $this->propertySchema->minItems ?? NULL;
return ConvertUtil::stdClassToNull($this->propertySchema->minItems ?? NULL);

Check failure on line 44 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMinItems() should return int|null but returns mixed.

Check failure on line 44 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMinItems() should return int|null but returns mixed.

Check failure on line 44 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMinItems() should return int|null but returns mixed.

Check failure on line 44 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMinItems() should return int|null but returns mixed.

Check failure on line 44 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMinItems() should return int|null but returns mixed.

Check failure on line 44 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMinItems() should return int|null but returns mixed.
}

public function getUniqueItems(): ?bool {
return $this->propertySchema->uniqueItems ?? NULL;
return ConvertUtil::stdClassToNull($this->propertySchema->uniqueItems ?? NULL);

Check failure on line 48 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getUniqueItems() should return bool|null but returns mixed.

Check failure on line 48 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getUniqueItems() should return bool|null but returns mixed.

Check failure on line 48 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getUniqueItems() should return bool|null but returns mixed.

Check failure on line 48 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getUniqueItems() should return bool|null but returns mixed.

Check failure on line 48 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getUniqueItems() should return bool|null but returns mixed.

Check failure on line 48 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getUniqueItems() should return bool|null but returns mixed.
}

public function getContains(): ?\stdClass {
return $this->propertySchema->contains ?? NULL;
}

public function getMaxContains(): ?int {
return $this->propertySchema->maxContains ?? NULL;
return ConvertUtil::stdClassToNull($this->propertySchema->maxContains ?? NULL);

Check failure on line 56 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMaxContains() should return int|null but returns mixed.

Check failure on line 56 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMaxContains() should return int|null but returns mixed.

Check failure on line 56 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMaxContains() should return int|null but returns mixed.

Check failure on line 56 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMaxContains() should return int|null but returns mixed.

Check failure on line 56 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMaxContains() should return int|null but returns mixed.

Check failure on line 56 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMaxContains() should return int|null but returns mixed.
}

public function getMinContains(): ?int {
return $this->propertySchema->minContains ?? NULL;
return ConvertUtil::stdClassToNull($this->propertySchema->minContains ?? NULL);

Check failure on line 60 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMinContains() should return int|null but returns mixed.

Check failure on line 60 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMinContains() should return int|null but returns mixed.

Check failure on line 60 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMinContains() should return int|null but returns mixed.

Check failure on line 60 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMinContains() should return int|null but returns mixed.

Check failure on line 60 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMinContains() should return int|null but returns mixed.

Check failure on line 60 in src/JsonForms/Definition/Control/ArrayControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\ArrayControlDefinition::getMinContains() should return int|null but returns mixed.
}

}
14 changes: 8 additions & 6 deletions src/JsonForms/Definition/Control/NumberControlDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,35 @@

namespace Drupal\json_forms\JsonForms\Definition\Control;

use Drupal\json_forms\Util\ConvertUtil;

class NumberControlDefinition extends ControlDefinition {

public function getMultipleOf(): ?int {
return $this->propertySchema->multipleOf ?? NULL;
return ConvertUtil::stdClassToNull($this->getpropertySchema->multipleOf ?? NULL);

Check failure on line 29 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getMultipleOf() should return int|null but returns mixed.

Check failure on line 29 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getMultipleOf() should return int|null but returns mixed.

Check failure on line 29 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getMultipleOf() should return int|null but returns mixed.

Check failure on line 29 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getMultipleOf() should return int|null but returns mixed.

Check failure on line 29 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getMultipleOf() should return int|null but returns mixed.

Check failure on line 29 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getMultipleOf() should return int|null but returns mixed.
}

public function getMaximum(): ?int {
return $this->propertySchema->maximum ?? NULL;
return ConvertUtil::stdClassToNull($this->propertySchema->maximum ?? NULL);

Check failure on line 33 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getMaximum() should return int|null but returns mixed.

Check failure on line 33 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getMaximum() should return int|null but returns mixed.

Check failure on line 33 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getMaximum() should return int|null but returns mixed.

Check failure on line 33 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getMaximum() should return int|null but returns mixed.

Check failure on line 33 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getMaximum() should return int|null but returns mixed.

Check failure on line 33 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getMaximum() should return int|null but returns mixed.
}

public function getExclusiveMaximum(): ?int {
return $this->propertySchema->exclusiveMaximum ?? NULL;
return ConvertUtil::stdClassToNull($this->propertySchema->exclusiveMaximum ?? NULL);

Check failure on line 37 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getExclusiveMaximum() should return int|null but returns mixed.

Check failure on line 37 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getExclusiveMaximum() should return int|null but returns mixed.

Check failure on line 37 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getExclusiveMaximum() should return int|null but returns mixed.

Check failure on line 37 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getExclusiveMaximum() should return int|null but returns mixed.

Check failure on line 37 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getExclusiveMaximum() should return int|null but returns mixed.

Check failure on line 37 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getExclusiveMaximum() should return int|null but returns mixed.
}

public function getMinimum(): ?int {
return $this->propertySchema->minimum ?? NULL;
return ConvertUtil::stdClassToNull($this->propertySchema->minimum ?? NULL);

Check failure on line 41 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getMinimum() should return int|null but returns mixed.

Check failure on line 41 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getMinimum() should return int|null but returns mixed.

Check failure on line 41 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getMinimum() should return int|null but returns mixed.

Check failure on line 41 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getMinimum() should return int|null but returns mixed.

Check failure on line 41 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getMinimum() should return int|null but returns mixed.

Check failure on line 41 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getMinimum() should return int|null but returns mixed.
}

public function getExclusiveMinimum(): ?int {
return $this->propertySchema->exclusiveMinimum ?? NULL;
return ConvertUtil::stdClassToNull($this->propertySchema->exclusiveMinimum ?? NULL);

Check failure on line 45 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getExclusiveMinimum() should return int|null but returns mixed.

Check failure on line 45 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getExclusiveMinimum() should return int|null but returns mixed.

Check failure on line 45 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getExclusiveMinimum() should return int|null but returns mixed.

Check failure on line 45 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getExclusiveMinimum() should return int|null but returns mixed.

Check failure on line 45 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getExclusiveMinimum() should return int|null but returns mixed.

Check failure on line 45 in src/JsonForms/Definition/Control/NumberControlDefinition.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.2 prefer-stable

Method Drupal\json_forms\JsonForms\Definition\Control\NumberControlDefinition::getExclusiveMinimum() should return int|null but returns mixed.
}

/**
* @return int|null Not a standardized property.
*/
public function getPrecision(): ?int {
return $this->propertySchema->precision ?? NULL;
return ConvertUtil::stdClassToNull($this->propertySchema->precision ?? NULL);
}

}
8 changes: 5 additions & 3 deletions src/JsonForms/Definition/Control/ObjectControlDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@

namespace Drupal\json_forms\JsonForms\Definition\Control;

use Drupal\json_forms\Util\ConvertUtil;

final class ObjectControlDefinition extends ControlDefinition {

public function getMaxProperties(): ?int {
return $this->propertySchema->maxProperties ?? NULL;
return ConvertUtil::stdClassToNull($this->propertySchema->maxProperties ?? NULL);
}

public function getMinProperties(): ?int {
return $this->propertySchema->minProperties ?? NULL;
return ConvertUtil::stdClassToNull($this->propertySchema->minProperties ?? NULL);
}

/**
Expand All @@ -42,7 +44,7 @@ public function getProperties(): \stdClass {
* @return array<string>|null
*/
public function getRequired(): ?array {
return $this->propertySchema->required ?? NULL;
return ConvertUtil::stdClassToNull($this->propertySchema->required ?? NULL);
}

public function getDependentRequired(): ?\stdClass {
Expand Down
8 changes: 5 additions & 3 deletions src/JsonForms/Definition/Control/StringControlDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@

namespace Drupal\json_forms\JsonForms\Definition\Control;

use Drupal\json_forms\Util\ConvertUtil;

class StringControlDefinition extends ControlDefinition {

public function getMaxLength(): ?int {
return $this->propertySchema->maxLength ?? NULL;
return ConvertUtil::stdClassToNull($this->propertySchema->maxLength ?? NULL);
}

public function getMinLength(): ?int {
return $this->propertySchema->minLength ?? NULL;
return ConvertUtil::stdClassToNull($this->propertySchema->minLength ?? NULL);
}

public function getPattern(): ?string {
return $this->propertySchema->pattern ?? NULL;
return ConvertUtil::stdClassToNull($this->propertySchema->pattern ?? NULL);
}

}
39 changes: 39 additions & 0 deletions src/Util/ConvertUtil.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/*
* Copyright (C) 2023 SYSTOPIA GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

declare(strict_types=1);

namespace Drupal\json_forms\Util;

final class ConvertUtil {

/**
* Returns NULL if the value is an \stdClass, otherwise the value itself.
*
* This method might be used for constraints in form render arrays such that
* no data pointer (defined in \stdClass object) will be used there.
*
* @param mixed $value
*
* @return mixed|null
*/
public static function stdClassToNull($value) {
return $value instanceof \stdClass ? NULL : $value;
}

}

0 comments on commit 05c2fcc

Please sign in to comment.