This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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 Abbreviation extends DataObject implements Shortcodable |
||
0 ignored issues
–
show
|
|||
4 | { |
||
5 | |||
6 | private static $db = array( |
||
0 ignored issues
–
show
|
|||
7 | 'Title' => 'Varchar(255)', |
||
8 | 'Description' => 'Varchar(255)', |
||
9 | 'URLSlug' => 'Varchar(255)', |
||
10 | 'Explanation' => 'HTMLText' |
||
11 | ); |
||
12 | |||
13 | private static $has_one = array( |
||
0 ignored issues
–
show
|
|||
14 | 'Page' => 'Page' |
||
15 | ); |
||
16 | |||
17 | private static $singular_name = 'Abbreviation'; |
||
0 ignored issues
–
show
|
|||
18 | |||
19 | private static $plural_name = 'Abbreviations'; |
||
0 ignored issues
–
show
|
|||
20 | |||
21 | private static $summary_fields = array('Title', 'Description'); |
||
0 ignored issues
–
show
|
|||
22 | |||
23 | private static $searchable_fields = array('Title', 'Description'); |
||
0 ignored issues
–
show
|
|||
24 | |||
25 | public function getCMSFields() |
||
26 | { |
||
27 | $fields = parent::getCMSFields(); |
||
28 | $fields->removeByName('URLSlug'); |
||
29 | return $fields; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Taken from https://github.com/NightJar/ssrigging-slug/blob/master/code/Slug.php |
||
34 | */ |
||
35 | public function Slug($regen=false) |
||
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a ![]() |
|||
36 | { |
||
37 | $existing = $this->URLSlug; |
||
0 ignored issues
–
show
The property
URLSlug does not exist on object<Abbreviation> . 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. ![]() |
|||
38 | return $existing && !$regen ? $existing : URLSegmentFilter::create()->filter($this->Title); |
||
0 ignored issues
–
show
The property
Title does not exist on object<Abbreviation> . 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. ![]() |
|||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Taken from https://github.com/NightJar/ssrigging-slug/blob/master/code/Slug.php |
||
43 | */ |
||
44 | public function onBeforeWrite() |
||
45 | { |
||
46 | parent::onBeforeWrite(); |
||
47 | if ($this->isChanged('URLSlug') || !$this->URLSlug || $this->isChanged($this->Title)) { |
||
0 ignored issues
–
show
The property
URLSlug does not exist on object<Abbreviation> . 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. ![]() The property
Title does not exist on object<Abbreviation> . 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. ![]() |
|||
48 | $this->URLSlug = $this->Slug(); |
||
0 ignored issues
–
show
The property
URLSlug does not exist on object<Abbreviation> . 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. ![]() |
|||
49 | $class = $this->class; |
||
50 | $filter = array('URLSlug' => $this->URLSlug); |
||
0 ignored issues
–
show
The property
URLSlug does not exist on object<Abbreviation> . 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. ![]() |
|||
51 | if ($parent = $this->parentRel) { |
||
0 ignored issues
–
show
The property
parentRel does not exist on object<Abbreviation> . 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. ![]() |
|||
52 | $filter[$parent] = $this->$parent; |
||
53 | } |
||
54 | $count = 1; |
||
55 | while ($exists = $class::get()->filter($filter)->exclude('ID', $this->ID)->exists()) { |
||
0 ignored issues
–
show
$exists is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
56 | $this->URLSlug = $this->URLSlug.$count++; |
||
0 ignored issues
–
show
The property
URLSlug does not exist on object<Abbreviation> . 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. ![]() The property
URLSlug does not exist on object<Abbreviation> . 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. ![]() |
|||
57 | $filter['URLSlug'] = $this->URLSlug; |
||
0 ignored issues
–
show
The property
URLSlug does not exist on object<Abbreviation> . 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. ![]() |
|||
58 | } |
||
59 | } |
||
60 | } |
||
61 | |||
62 | public function Link() |
||
63 | { |
||
64 | return Controller::join_links($this->Page()->Link(), $this->URLSlug); |
||
0 ignored issues
–
show
The property
URLSlug does not exist on object<Abbreviation> . 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. ![]() The method
Page does not exist on object<Abbreviation> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
![]() |
|||
65 | } |
||
66 | |||
67 | public function AbsoluteLink() |
||
68 | { |
||
69 | return Director::absoluteURL($this->Link()); |
||
70 | } |
||
71 | |||
72 | public function forTemplate() |
||
73 | { |
||
74 | $template = new SSViewer('Abbreviation'); |
||
75 | return $template->process($this); |
||
76 | } |
||
77 | |||
78 | |||
79 | /** |
||
80 | * Used for Breadcrumbs |
||
81 | * |
||
82 | * @return DBField |
||
83 | */ |
||
84 | public function getMenuTitle() |
||
85 | { |
||
86 | return $this->dbObject('Title'); |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * Returns the first letter of the module title, used for grouping. |
||
91 | * @return string |
||
92 | */ |
||
93 | public function getTitleFirstLetter() |
||
94 | { |
||
95 | return strtoupper($this->Title[0]); |
||
0 ignored issues
–
show
The property
Title does not exist on object<Abbreviation> . 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. ![]() |
|||
96 | } |
||
97 | |||
98 | /** |
||
99 | * Parse the shortcode and render as a string, probably with a template |
||
100 | * @param array $arguments the list of attributes of the shortcode |
||
101 | * @param string $content the shortcode content |
||
102 | * @param ShortcodeParser $parser the ShortcodeParser instance |
||
103 | * @param string $shortcode the raw shortcode being parsed |
||
104 | * @return String |
||
0 ignored issues
–
show
|
|||
105 | **/ |
||
106 | View Code Duplication | public static function parse_shortcode($arguments, $content, $parser, $shortcode) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
107 | { |
||
108 | if (empty($arguments['id'])) { |
||
109 | return; |
||
110 | } |
||
111 | |||
112 | if (array_key_exists('id', $arguments) && $arguments['id']) { |
||
113 | $abbreviation = Abbreviation::get()->byID($arguments['id']); |
||
114 | } |
||
115 | |||
116 | if (!$abbreviation) { |
||
0 ignored issues
–
show
The variable
$abbreviation does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
117 | return; |
||
118 | } |
||
119 | |||
120 | if (array_key_exists('title', $arguments) && $arguments['title']) { |
||
121 | $abbreviation->Title = $arguments['title']; |
||
122 | } |
||
123 | |||
124 | $template = new SSViewer('AbbreviationShortcode'); |
||
125 | return $template->process($abbreviation); |
||
126 | } |
||
127 | |||
128 | /** |
||
129 | * returns a list of fields for editing the shortcode's attributes |
||
130 | * @return Fieldlist |
||
0 ignored issues
–
show
|
|||
131 | **/ |
||
132 | public static function shortcode_attribute_fields() |
||
133 | { |
||
134 | //@todo use addnew field to add a new abbr. on the fly |
||
135 | } |
||
136 | } |
||
137 |
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.