Completed
Push — master ( d9dfd9...4ffba9 )
by
unknown
01:27
created

Aeria/Field/Fields/FieldsetField.php (7 issues)

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
namespace Aeria\Field\Fields;
4
5
use Aeria\Field\FieldNodeFactory;
6
7
class FieldsetField extends BaseField
8
{
9
    private function getAccordionStatus()
10
    {
11
        return new SwitchField(
12
            $this->key,
0 ignored issues
show
The property key does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
13
            ['id' => 'accordion-state', 'validators' => ''],
14
            $this->sections
0 ignored issues
show
The property sections does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
15
        );
16
    }
17
18
    public function get(array $metas, bool $skipFilter = false)
19
    {
20
        $fields = [];
21 View Code Duplication
        foreach ($this->config['fields'] as $field_index => $field_config) {
0 ignored issues
show
The property config does not seem to exist. Did you mean original_config?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
22
            $fields[$field_config['id']] = FieldNodeFactory::make(
23
                $this->key, $field_config, $this->sections
24
            )->get($metas);
25
        }
26
        if (!$skipFilter) {
27
            $fields = apply_filters('aeria_get_fieldset', $fields, $this->config);
0 ignored issues
show
The property config does not seem to exist. Did you mean original_config?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
28
        }
29
30
        return $fields;
31
    }
32
33
    public function getAdmin(array $metas, array $errors)
34
    {
35
        $config = $this->config;
0 ignored issues
show
The property config does not seem to exist. Did you mean original_config?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
36
        $config['accordionState'] = $this->getAccordionStatus()->get($metas);
37
        $fields = [];
38
        foreach ($this->config['fields'] as $field_index => $field_config) {
0 ignored issues
show
The property config does not seem to exist. Did you mean original_config?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
39
            $fields[] = FieldNodeFactory::make(
40
                $this->key, $field_config, $this->sections
41
            )->getAdmin($metas, $errors);
42
        }
43
        $config['fields'] = $fields;
44
45
        return $config;
46
    }
47
48
    public function set($context_ID, $context_type, array $savedFields, array $new_values, $validator_service, $query_service)
49
    {
50
        $this->getAccordionStatus()->set($context_ID, $context_type, $savedFields, $new_values, $validator_service, $query_service);
51
        foreach ($this->config['fields'] as $field_index => $field_config) {
0 ignored issues
show
The property config does not seem to exist. Did you mean original_config?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
52
            FieldNodeFactory::make(
53
                $this->key, $field_config, $this->sections
54
            )->set($context_ID, $context_type, $savedFields, $new_values, $validator_service, $query_service);
55
        }
56
    }
57
}
58