1 | <?php |
||||
2 | |||||
3 | namespace Dynamic\Salsify\ORM; |
||||
4 | |||||
5 | use Dynamic\Salsify\Model\MapperHash; |
||||
6 | use SilverStripe\Admin\LeftAndMain; |
||||
0 ignored issues
–
show
|
|||||
7 | use SilverStripe\CMS\Forms\SiteTreeURLSegmentField; |
||||
0 ignored issues
–
show
The type
SilverStripe\CMS\Forms\SiteTreeURLSegmentField was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
8 | use SilverStripe\CMS\Model\SiteTree; |
||||
0 ignored issues
–
show
The type
SilverStripe\CMS\Model\SiteTree was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
9 | use SilverStripe\Control\Controller; |
||||
10 | use SilverStripe\Forms\DatetimeField; |
||||
11 | use SilverStripe\Forms\FieldList; |
||||
12 | use SilverStripe\Forms\FormAction; |
||||
13 | use SilverStripe\Forms\TextField; |
||||
14 | use SilverStripe\ORM\DataExtension; |
||||
15 | use SilverStripe\ORM\HasManyList; |
||||
16 | |||||
17 | /** |
||||
18 | * Class FileExtension |
||||
19 | * |
||||
20 | * @property string SalsifyID |
||||
21 | * @property string SalsifyUpdatedAt |
||||
22 | * @property string SalsifyRelationsUpdatedAt |
||||
23 | * |
||||
24 | * @method HasManyList MapperHashes() |
||||
25 | * |
||||
26 | * @property-read \SilverStripe\ORM\DataObject|\Dynamic\Salsify\ORM\SalsifyIDExtension $owner |
||||
27 | */ |
||||
28 | class SalsifyIDExtension extends DataExtension |
||||
29 | { |
||||
30 | |||||
31 | /** |
||||
32 | * @var array |
||||
33 | */ |
||||
34 | private static $db = [ |
||||
0 ignored issues
–
show
|
|||||
35 | 'SalsifyID' => 'Varchar(255)', |
||||
36 | 'SalsifyUpdatedAt' => 'Varchar(255)', |
||||
37 | 'SalsifyRelationsUpdatedAt' => 'Varchar(255)', |
||||
38 | ]; |
||||
39 | |||||
40 | /** |
||||
41 | * @var array |
||||
42 | */ |
||||
43 | private static $has_many = [ |
||||
44 | 'MapperHashes' => MapperHash::class, |
||||
45 | ]; |
||||
46 | |||||
47 | /** |
||||
48 | * @var array |
||||
49 | */ |
||||
50 | private static $indexes = [ |
||||
0 ignored issues
–
show
|
|||||
51 | 'SalsifyID' => true, |
||||
52 | ]; |
||||
53 | |||||
54 | /** |
||||
55 | * @param \SilverStripe\Forms\FieldList $fields |
||||
56 | */ |
||||
57 | protected function updateFields(FieldList $fields) |
||||
58 | { |
||||
59 | $salsifyID = $fields->fieldByName('SalsifyID'); |
||||
0 ignored issues
–
show
Are you sure the assignment to
$salsifyID is correct as $fields->fieldByName('SalsifyID') 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 The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||
60 | if (!$salsifyID) { |
||||
0 ignored issues
–
show
|
|||||
61 | $fields->push($salsifyID = TextField::create('SalsifyID')); |
||||
62 | } |
||||
63 | |||||
64 | $salsifyUpdatedAt = $fields->fieldByName('SalsifyUpdatedAt'); |
||||
0 ignored issues
–
show
Are you sure the assignment to
$salsifyUpdatedAt is correct as $fields->fieldByName('SalsifyUpdatedAt') 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 The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||
65 | if (!$salsifyUpdatedAt) { |
||||
0 ignored issues
–
show
|
|||||
66 | $fields->push($salsifyUpdatedAt = DatetimeField::create('SalsifyUpdatedAt')); |
||||
67 | } |
||||
68 | |||||
69 | $salsifyRelationsUpdatedAt = $fields->fieldByName('SalsifyRelationsUpdatedAt'); |
||||
0 ignored issues
–
show
Are you sure the assignment to
$salsifyRelationsUpdatedAt is correct as $fields->fieldByName('SalsifyRelationsUpdatedAt') 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 The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||
70 | if (!$salsifyRelationsUpdatedAt) { |
||||
0 ignored issues
–
show
|
|||||
71 | $fields->push($salsifyRelationsUpdatedAt = DatetimeField::create('SalsifyRelationsUpdatedAt')); |
||||
72 | } |
||||
73 | |||||
74 | if ($this->owner->SalsifyID) { |
||||
75 | $salsifyID->setTemplate(SiteTreeURLSegmentField::class)->addExtraClass('urlsegment'); |
||||
76 | } |
||||
77 | $salsifyUpdatedAt->setReadonly(true); |
||||
78 | $salsifyRelationsUpdatedAt->setReadonly(true); |
||||
79 | } |
||||
80 | |||||
81 | /** |
||||
82 | * @param \SilverStripe\Forms\FieldList $fields |
||||
83 | */ |
||||
84 | public function updateCMSFields(FieldList $fields) |
||||
85 | { |
||||
86 | if ($this->owner instanceof SiteTree) { |
||||
87 | return parent::updateCMSFields($fields); |
||||
0 ignored issues
–
show
Are you sure the usage of
parent::updateCMSFields($fields) targeting SilverStripe\ORM\DataExtension::updateCMSFields() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||
88 | } |
||||
89 | |||||
90 | $this->updateFields($fields); |
||||
91 | return parent::updateCMSFields($fields); |
||||
0 ignored issues
–
show
Are you sure the usage of
parent::updateCMSFields($fields) targeting SilverStripe\ORM\DataExtension::updateCMSFields() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||
92 | } |
||||
93 | |||||
94 | /** |
||||
95 | * @param \SilverStripe\Forms\FieldList $fields |
||||
96 | */ |
||||
97 | public function updateSettingsFields(FieldList $fields) |
||||
98 | { |
||||
99 | $this->updateFields($fields); |
||||
100 | } |
||||
101 | |||||
102 | /** |
||||
103 | * @param \SilverStripe\Forms\FieldList $actions |
||||
104 | */ |
||||
105 | public function updateCMSActions(FieldList $actions) |
||||
106 | { |
||||
107 | parent::updateCMSActions($actions); |
||||
108 | |||||
109 | if (!$this->owner->SalsifyID) { |
||||
110 | return; |
||||
111 | } |
||||
112 | |||||
113 | $controller = Controller::curr(); |
||||
114 | if ($controller instanceof LeftAndMain && $controller->canFetchSalsify()) { |
||||
115 | /** @var FormAction $action */ |
||||
116 | $action = FormAction::create('salsifyFetch', 'Re-fetch Salsify') |
||||
117 | ->addExtraClass('btn-primary font-icon-sync') |
||||
118 | ->setUseButtonTag(true); |
||||
119 | |||||
120 | $actions->push($action); |
||||
121 | } |
||||
122 | } |
||||
123 | |||||
124 | /** |
||||
125 | * |
||||
126 | */ |
||||
127 | public function onBeforeWrite() |
||||
128 | { |
||||
129 | parent::onBeforeWrite(); |
||||
130 | |||||
131 | $this->owner->SalsifyID = trim($this->owner->SalsifyID); |
||||
0 ignored issues
–
show
It seems like
$this->owner->SalsifyID can also be of type null ; however, parameter $string of trim() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
132 | } |
||||
133 | } |
||||
134 |
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