mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix: SA: Fix "...Access to an undefined property..." rule.
SA stands for Static Analysis.
This commit is contained in:
parent
6cfcf91757
commit
db2010082a
@ -195,11 +195,6 @@ parameters:
|
||||
count: 2
|
||||
path: src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php
|
||||
|
||||
-
|
||||
message: "#^Access to an undefined property Chill\\\\CustomFieldsBundle\\\\Form\\\\DataTransformer\\\\JsonCustomFieldToArrayTransformer\\:\\:\\$customField\\.$#"
|
||||
count: 3
|
||||
path: src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method Chill\\\\ThirdPartyBundle\\\\Form\\\\Type\\\\PickThirdPartyTypeCategoryType\\:\\:transform\\(\\)\\.$#"
|
||||
count: 1
|
||||
|
@ -1,28 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\CustomFieldsBundle\Form\DataTransformer;
|
||||
|
||||
use Chill\CustomFieldsBundle\Entity\CustomField;
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
class JsonCustomFieldToArrayTransformer implements DataTransformerInterface {
|
||||
/**
|
||||
* @var ObjectManager
|
||||
*/
|
||||
private $om;
|
||||
private ObjectManager $om;
|
||||
|
||||
private array $customField;
|
||||
|
||||
/**
|
||||
* @param ObjectManager $om
|
||||
*/
|
||||
public function __construct(ObjectManager $om)
|
||||
{
|
||||
$this->om = $om;
|
||||
|
||||
$customFields = $this->om
|
||||
->getRepository('ChillCustomFieldsBundle:CustomField')
|
||||
->getRepository(CustomField::class)
|
||||
->findAll();
|
||||
|
||||
// @TODO: in the array_map callback, CustomField::getLabel() does not exist. What do we do here?
|
||||
$customFieldsLablels = array_map(
|
||||
function($e) { return $e->getLabel(); },
|
||||
$customFields);
|
||||
@ -36,20 +35,12 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface {
|
||||
{
|
||||
echo $customFieldsJSON;
|
||||
|
||||
if($customFieldsJSON === null) { // lors de la creation
|
||||
$customFieldsArray = array();
|
||||
if($customFieldsJSON === null) {
|
||||
$customFieldsArray = [];
|
||||
} else {
|
||||
$customFieldsArray = json_decode($customFieldsJSON,true);
|
||||
$customFieldsArray = json_decode($customFieldsJSON, true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
echo "<br> - 4 - <br>";
|
||||
|
||||
var_dump($customFieldsArray);
|
||||
|
||||
echo "<br> - 5 - <br>";
|
||||
*/
|
||||
|
||||
$customFieldsArrayRet = array();
|
||||
|
||||
foreach ($customFieldsArray as $key => $value) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user