Issues (216)

src/Extensions/ElementalCMSMainExtension.php (2 issues)

1
<?php
2
3
namespace DNADesign\Elemental\Extensions;
4
5
use SilverStripe\Core\Extension;
6
use SilverStripe\Forms\DropdownField;
7
use SilverStripe\Forms\Form;
8
9
class ElementalCMSMainExtension extends Extension
10
{
11
    /**
12
     * Remove the empty default string on the class filter, which adds "All pages" again. This is already
13
     * added by ElementSiteTreeFilterSearch.
14
     *
15
     * @param Form $form
16
     */
17
    public function updateSearchForm(Form $form)
18
    {
19
        /** @var DropdownField $filterField */
20
        $filterField = $form->Fields()->fieldByName('Search__FilterClass');
0 ignored issues
show
Are you sure the assignment to $filterField is correct as $form->Fields()->fieldBy...('Search__FilterClass') targeting SilverStripe\Forms\FieldList::fieldByName() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
21
        if ($filterField) {
0 ignored issues
show
$filterField is of type SilverStripe\Forms\DropdownField, thus it always evaluated to true.
Loading history...
22
            $filterField->setEmptyString('')->setHasEmptyDefault(false);
23
        }
24
    }
25
}
26