These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | class DMSDocumentAddExistingField extends CompositeField |
||
0 ignored issues
–
show
|
|||
4 | { |
||
5 | public $useFieldContext = true; |
||
6 | |||
7 | public function __construct($name, $title = null) |
||
8 | { |
||
9 | $this->name = $name; |
||
10 | $this->title = ($title === null) ? $name : $title; |
||
11 | |||
12 | parent::__construct( |
||
13 | new TreeDropdownField( |
||
14 | 'PageSelector', |
||
15 | 'Add from another page', |
||
16 | 'SiteTree', |
||
17 | 'ID', |
||
18 | 'TitleWithNumberOfDocuments' |
||
19 | ) |
||
20 | ); |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * Force a record to be used as "Parent" for uploaded Files (eg a Page with a has_one to File) |
||
25 | * @param DataObject $record |
||
26 | */ |
||
27 | public function setRecord($record) |
||
28 | { |
||
29 | $this->record = $record; |
||
0 ignored issues
–
show
The property
record does not exist on object<DMSDocumentAddExistingField> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
30 | return $this; |
||
31 | } |
||
32 | /** |
||
33 | * Get the record to use as "Parent" for uploaded Files (eg a Page with a has_one to File) If none is set, it |
||
34 | * will use Form->getRecord() or Form->Controller()->data() |
||
35 | * @return DataObject |
||
36 | */ |
||
37 | public function getRecord() |
||
38 | { |
||
39 | if (!$this->record && $this->form) { |
||
0 ignored issues
–
show
The property
record does not exist on object<DMSDocumentAddExistingField> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
40 | if ($this->form->getRecord() && is_a($this->form->getRecord(), 'DataObject')) { |
||
41 | $this->record = $this->form->getRecord(); |
||
0 ignored issues
–
show
The property
record does not exist on object<DMSDocumentAddExistingField> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
42 | } elseif ($this->form->Controller() && $this->form->Controller()->hasMethod('data') |
||
0 ignored issues
–
show
The method
Form::Controller() has been deprecated with message: 4.0
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.
Loading history...
|
|||
43 | && $this->form->Controller()->data() && is_a($this->form->Controller()->data(), 'DataObject')) { |
||
0 ignored issues
–
show
The method
Form::Controller() has been deprecated with message: 4.0
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.
Loading history...
|
|||
44 | $this->record = $this->form->Controller()->data(); |
||
0 ignored issues
–
show
The property
record does not exist on object<DMSDocumentAddExistingField> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
The method
Form::Controller() has been deprecated with message: 4.0
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.
Loading history...
|
|||
45 | } |
||
46 | } |
||
47 | return $this->record; |
||
0 ignored issues
–
show
The property
record does not exist on object<DMSDocumentAddExistingField> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
48 | } |
||
49 | |||
50 | public function FieldHolder($properties = array()) |
||
51 | { |
||
52 | return $this->Field($properties); |
||
53 | } |
||
54 | |||
55 | public function Field($properties = array()) |
||
56 | { |
||
57 | Requirements::javascript(DMS_DIR.'/javascript/DMSDocumentAddExistingField.js'); |
||
58 | Requirements::javascript(DMS_DIR."/javascript/DocumentHtmlEditorFieldToolbar.js"); |
||
59 | |||
60 | return $this->renderWith('DMSDocumentAddExistingField'); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * Sets or unsets the use of the "field" class in the template. The "field" class adds Javascript behaviour |
||
65 | * that causes unwelcome hiding side-effects when this Field is used within the link editor pop-up |
||
66 | * |
||
67 | * @return $this |
||
68 | */ |
||
69 | public function setUseFieldClass($use = false) |
||
70 | { |
||
71 | $this->useFieldContext = $use; |
||
72 | return $this; |
||
73 | } |
||
74 | } |
||
75 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.