1 | <?php |
||||||
2 | |||||||
3 | namespace SilverStripe\VersionedAdmin\Extensions; |
||||||
4 | |||||||
5 | use DNADesign\Elemental\Models\BaseElement; |
||||||
0 ignored issues
–
show
|
|||||||
6 | use SilverStripe\Forms\GridField\GridFieldDataColumns; |
||||||
7 | use SilverStripe\ORM\DataExtension; |
||||||
8 | use SilverStripe\ORM\FieldType\DBDatetime; |
||||||
9 | use SilverStripe\Security\Member; |
||||||
10 | use SilverStripe\VersionedAdmin\ArchiveAdmin; |
||||||
11 | use SilverStripe\VersionedAdmin\Interfaces\ArchiveViewProvider; |
||||||
12 | |||||||
13 | /** |
||||||
14 | * Adds a archive view for Elemental blocks |
||||||
15 | */ |
||||||
16 | class BlockArchiveExtension extends DataExtension implements ArchiveViewProvider |
||||||
17 | { |
||||||
18 | /** |
||||||
19 | * @inheritDoc |
||||||
20 | */ |
||||||
21 | public function getArchiveFieldClass() |
||||||
22 | { |
||||||
23 | return BaseElement::class; |
||||||
0 ignored issues
–
show
The expression
return DNADesign\Element...dels\BaseElement::class returns the type string which is incompatible with the return type mandated by SilverStripe\VersionedAd...:getArchiveFieldClass() of array .
In the issue above, the returned value is violating the contract defined by the mentioned interface. Let's take a look at an example: interface HasName {
/** @return string */
public function getName();
}
class Name {
public $name;
}
class User implements HasName {
/** @return string|Name */
public function getName() {
return new Name('foo'); // This is a violation of the ``HasName`` interface
// which only allows a string value to be returned.
}
}
![]() |
|||||||
24 | } |
||||||
25 | |||||||
26 | /** |
||||||
27 | * @inheritDoc |
||||||
28 | */ |
||||||
29 | public function getArchiveField() |
||||||
30 | { |
||||||
31 | $listField = ArchiveAdmin::createArchiveGridField('Blocks', BaseElement::class); |
||||||
32 | |||||||
33 | $listColumns = $listField->getConfig()->getComponentByType(GridFieldDataColumns::class); |
||||||
34 | $listColumns->setDisplayFields([ |
||||||
0 ignored issues
–
show
The method
setDisplayFields() does not exist on SilverStripe\Forms\GridField\GridFieldComponent . It seems like you code against a sub-type of SilverStripe\Forms\GridField\GridFieldComponent such as SilverStripe\Forms\GridField\GridFieldPrintButton or SilverStripe\Forms\GridField\GridFieldPrintButton or SilverStripe\Forms\GridField\GridFieldDataColumns or SilverStripe\Forms\GridField\GridFieldPrintButton or SilverStripe\Forms\Tests...ndlerTest\TestComponent or SilverStripe\Forms\GridField\GridFieldDetailForm .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
35 | 'Title' => BaseElement::singleton()->fieldLabel('Title'), |
||||||
36 | 'Type' => _t('SilverStripe\\VersionedAdmin\\ArchiveAdmin.COLUMN_TYPE', 'Type'), |
||||||
37 | 'Versions.first.LastEdited' => _t( |
||||||
38 | 'SilverStripe\\VersionedAdmin\\ArchiveAdmin.COLUMN_DATEARCHIVED', |
||||||
39 | 'Date Archived' |
||||||
40 | ), |
||||||
41 | 'Breadcrumbs' => _t('SilverStripe\\VersionedAdmin\\ArchiveAdmin.COLUMN_ORIGIN', 'Origin'), |
||||||
42 | 'Versions.first.Author.Name' => _t( |
||||||
43 | 'SilverStripe\\VersionedAdmin\\ArchiveAdmin.COLUMN_ARCHIVEDBY', |
||||||
44 | 'Archived By' |
||||||
45 | ) |
||||||
46 | ]); |
||||||
47 | $listColumns->setFieldFormatting([ |
||||||
0 ignored issues
–
show
The method
setFieldFormatting() does not exist on SilverStripe\Forms\GridField\GridFieldComponent . It seems like you code against a sub-type of SilverStripe\Forms\GridField\GridFieldComponent such as SilverStripe\Forms\GridField\GridFieldPrintButton or SilverStripe\Forms\GridField\GridFieldPrintButton or SilverStripe\Forms\GridField\GridFieldDataColumns or SilverStripe\Forms\GridField\GridFieldPrintButton or SilverStripe\Forms\Tests...ndlerTest\TestComponent or SilverStripe\Forms\GridField\GridFieldDetailForm .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
48 | 'Breadcrumbs' => function ($val, $item) { |
||||||
49 | $parent = $item->Page; |
||||||
50 | |||||||
51 | return $parent ? $parent->Breadcrumbs() : null; |
||||||
52 | }, |
||||||
53 | 'Versions.first.LastEdited' => function ($val, $item) { |
||||||
0 ignored issues
–
show
The parameter
$item is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||||
54 | return DBDatetime::create_field('Datetime', $val)->Ago(); |
||||||
55 | }, |
||||||
56 | ]); |
||||||
57 | |||||||
58 | return $listField; |
||||||
59 | } |
||||||
60 | |||||||
61 | /** |
||||||
62 | * @inheritDoc |
||||||
63 | */ |
||||||
64 | public function isArchiveFieldEnabled() |
||||||
65 | { |
||||||
66 | return true; |
||||||
67 | } |
||||||
68 | } |
||||||
69 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths