GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 0681d7...5c78ad )
by Edi
01:55
created

bundle/Form/FieldTypeHandler/TextBlock.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Netgen\Bundle\EzFormsBundle\Form\FieldTypeHandler;
6
7
use eZ\Publish\API\Repository\Values\Content\Content;
8
use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
9
use eZ\Publish\Core\FieldType\TextBlock\Value as TextBlockValue;
10
use eZ\Publish\SPI\FieldType\Value;
11
use Netgen\Bundle\EzFormsBundle\Form\FieldTypeHandler;
12
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
13
use Symfony\Component\Form\FormBuilderInterface;
14
15
class TextBlock extends FieldTypeHandler
16
{
17
    public function convertFieldValueToForm(Value $value, ?FieldDefinition $fieldDefinition = null): string
18
    {
19
        return $value->text;
0 ignored issues
show
Accessing text on the interface eZ\Publish\SPI\FieldType\Value suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
20
    }
21
22
    public function convertFieldValueFromForm($data): TextBlockValue
23
    {
24
        if (empty($data)) {
25
            $data = '';
26
        }
27
28
        return new TextBlockValue($data);
29
    }
30
31
    protected function buildFieldForm(
32
        FormBuilderInterface $formBuilder,
33
        FieldDefinition $fieldDefinition,
34
        string $languageCode,
35
        ?Content $content = null
36
    ): void {
37
        $options = $this->getDefaultFieldOptions($fieldDefinition, $languageCode, $content);
38
39
        $options['attr']['rows'] = $fieldDefinition->fieldSettings['textRows'];
40
41
        $formBuilder->add($fieldDefinition->identifier, TextareaType::class, $options);
42
    }
43
}
44