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 | /** |
||
4 | *@author nicolaas[at]sunnysideup.co.nz |
||
5 | * |
||
6 | * |
||
7 | **/ |
||
8 | |||
9 | class VimeoDataObject extends DataObject |
||
0 ignored issues
–
show
|
|||
10 | { |
||
11 | private static $db = array( |
||
0 ignored issues
–
show
|
|||
12 | "Title" => "Varchar(100)", |
||
13 | "VimeoCode" => "Int", |
||
14 | "HTMLSnippet" => "HTMLText", |
||
15 | "Data" => "Text" |
||
16 | ); |
||
17 | |||
18 | private static $casting = array( |
||
0 ignored issues
–
show
|
|||
19 | "FullName" => "Text", |
||
20 | "Icon" => "HTMLText", |
||
21 | "IconLink" => "Varchar", |
||
22 | "FullImage" => "HTMLText", |
||
23 | "FullImageLink" => "Varchar" |
||
24 | ); |
||
25 | |||
26 | private static $searchable_fields = array( |
||
0 ignored issues
–
show
|
|||
27 | "Title" => "PartialMatchFilter", |
||
28 | "VimeoCode" |
||
29 | ); |
||
30 | |||
31 | private static $summary_fields = array( |
||
0 ignored issues
–
show
|
|||
32 | "Icon" => "Icon", |
||
33 | "Title" => "Title", |
||
34 | ); |
||
35 | |||
36 | private static $singular_name = "Vimeo Video"; |
||
0 ignored issues
–
show
|
|||
37 | |||
38 | private static $plural_name = "Vimeo Videos"; |
||
0 ignored issues
–
show
|
|||
39 | |||
40 | private static $default_sort = "Title ASC"; |
||
0 ignored issues
–
show
|
|||
41 | |||
42 | private static $vimeo_base_url = "http://vimeo.com/api/oembed.xml?url=http%3A//vimeo.com/";//The exact width of the video. Defaults to original size. |
||
0 ignored issues
–
show
|
|||
43 | |||
44 | private static $width = null;//The exact width of the video. Defaults to original size. |
||
0 ignored issues
–
show
|
|||
45 | |||
46 | private static $maxwidth = null;////Same as width, but video will not exceed original size. |
||
0 ignored issues
–
show
|
|||
47 | |||
48 | private static $height = null;//The exact height of the video. Defaults to original size. |
||
0 ignored issues
–
show
|
|||
49 | |||
50 | private static $maxheight = null;//Same as height, but video will not exceed original size. |
||
0 ignored issues
–
show
|
|||
51 | |||
52 | private static $byline = null;//Show the byline on the video. Defaults to true. |
||
0 ignored issues
–
show
|
|||
53 | |||
54 | private static $title = null;//Show the title on the video. Defaults to true. |
||
0 ignored issues
–
show
|
|||
55 | |||
56 | private static $portrait = null;//// Show the user's portrait on the video. Defaults to true. |
||
0 ignored issues
–
show
|
|||
57 | |||
58 | private static $color = null;// Specify the color of the video controls. |
||
0 ignored issues
–
show
|
|||
59 | |||
60 | private static $callback = null;//When returning JSON, wrap in this function. |
||
0 ignored issues
–
show
|
|||
61 | |||
62 | private static $autoplay = null;//Automatically start playback of the video. Defaults to false. |
||
0 ignored issues
–
show
|
|||
63 | |||
64 | private static $xhtml = null;// Make the embed code XHTML compliant. Defaults to true. |
||
0 ignored issues
–
show
|
|||
65 | |||
66 | private static $api = null;// Enable the Javascript API for Moogaloop. Defaults to false. |
||
0 ignored issues
–
show
|
|||
67 | |||
68 | private static $wmode = null;//add the "wmode" parameter. Can be either transparent or opaque. |
||
0 ignored issues
–
show
|
|||
69 | |||
70 | private static $iframe;// Use our new embed code. Defaults to true. NEW! |
||
0 ignored issues
–
show
|
|||
71 | |||
72 | protected $dataAsArray = array(); |
||
73 | |||
74 | protected $variables = array( |
||
75 | "type", |
||
76 | "version", |
||
77 | "provider_name", |
||
78 | "provider_url", |
||
79 | "title", |
||
80 | "author_name", |
||
81 | "author_url", |
||
82 | "is_plus", |
||
83 | "html", |
||
84 | "width", |
||
85 | "height", |
||
86 | "duration", |
||
87 | "description", |
||
88 | "thumbnail_url", |
||
89 | "thumbnail_width", |
||
90 | "thumbnail_height", |
||
91 | "video_id" |
||
92 | ); |
||
93 | |||
94 | /** |
||
95 | * do not retrieve data from vimeo server ... |
||
96 | * for internal use only |
||
97 | * @var Boolean |
||
98 | */ |
||
99 | private $doNotRetrieveData = false; |
||
100 | |||
101 | public function getCMSFields() |
||
102 | { |
||
103 | $fields = parent::getCMSFields(); |
||
104 | $fields->removeByName("HTMLSnippet"); |
||
105 | $fields->removeByName("Data"); |
||
106 | $fields->addFieldToTab("Root.Main", new LiteralField("HTMLSnippet", $this->HTML($noCaching = false))); |
||
107 | $this->getDataAsArray(); |
||
108 | if (is_array($this->dataAsArray) && count($this->dataAsArray)) { |
||
109 | foreach ($this->dataAsArray as $name => $value) { |
||
110 | $fields->addFieldToTab("Root.Details", new ReadOnlyField($name, $name, $value)); |
||
111 | } |
||
112 | } |
||
113 | return $fields; |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * casted variable |
||
118 | * @return string |
||
119 | */ |
||
120 | public function getFullName() |
||
121 | { |
||
122 | return $this->Title." (".$this->VimeoCode.")"; |
||
0 ignored issues
–
show
The property
Title does not exist on object<VimeoDataObject> . 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
VimeoCode does not exist on object<VimeoDataObject> . 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. ![]() |
|||
123 | } |
||
124 | |||
125 | /** |
||
126 | * alias for getVariable |
||
127 | * @param String $name |
||
128 | * @return Varchar |
||
0 ignored issues
–
show
|
|||
129 | */ |
||
130 | public function MetaDataVariable($name) |
||
131 | { |
||
132 | return $this->getMetaDataVariable($name); |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * |
||
137 | * @param String - name of variable |
||
138 | * |
||
139 | * @return Varchar Object |
||
0 ignored issues
–
show
|
|||
140 | */ |
||
141 | View Code Duplication | public function getMetaDataVariable($name) |
|
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. ![]() |
|||
142 | { |
||
143 | $this->getDataAsArray(); |
||
144 | if (!empty($this->dataAsArray[$name])) { |
||
145 | return DBField::create_field("Varchar", $this->dataAsArray[$name]); |
||
146 | } |
||
147 | return null; |
||
148 | } |
||
149 | |||
150 | /** |
||
151 | * return icon as <img tag> |
||
152 | * @return String |
||
0 ignored issues
–
show
|
|||
153 | */ |
||
154 | public function getIcon() |
||
155 | { |
||
156 | View Code Duplication | if (!count($this->dataAsArray)) { |
|
0 ignored issues
–
show
This code seems to be duplicated across 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. ![]() |
|||
157 | //remove non-ascii characters as they were causing havoc... |
||
158 | $this->Data = preg_replace('/[^(\x20-\x7F)]*/', '', $this->Data); |
||
0 ignored issues
–
show
The property
Data does not exist on object<VimeoDataObject> . 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
Data does not exist on object<VimeoDataObject> . 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. ![]() |
|||
159 | $this->dataAsArray = $this->safelyUnserialize($this->Data); |
||
0 ignored issues
–
show
The property
Data does not exist on object<VimeoDataObject> . 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. ![]() |
|||
160 | } |
||
161 | if (!empty($this->dataAsArray["thumbnail_url"])) { |
||
162 | $v = "<img src=\"".$this->dataAsArray["thumbnail_url"]."\" width=\"".$this->dataAsArray["thumbnail_width"]."\" height=\"".$this->dataAsArray["thumbnail_height"]."\" alt=\"".Convert::raw2att($this->Title)."\"/>"; |
||
0 ignored issues
–
show
The property
Title does not exist on object<VimeoDataObject> . 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. ![]() |
|||
163 | } else { |
||
164 | $v = "[".$this->Title."]"; |
||
0 ignored issues
–
show
The property
Title does not exist on object<VimeoDataObject> . 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. ![]() |
|||
165 | } |
||
166 | return DBField::create_field("HTMLText", $v); |
||
167 | } |
||
168 | |||
169 | /** |
||
170 | * returns icon as myimage.png |
||
171 | * @return String |
||
0 ignored issues
–
show
|
|||
172 | */ |
||
173 | View Code Duplication | public function getIconLink() |
|
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. ![]() |
|||
174 | { |
||
175 | $this->getDataAsArray(); |
||
176 | if (!empty($this->dataAsArray["thumbnail_url"])) { |
||
177 | return DBField::create_field("Varchar", $this->dataAsArray["thumbnail_url"]); |
||
178 | } |
||
179 | return null; |
||
180 | } |
||
181 | |||
182 | /** |
||
183 | * return icon as <img tag> |
||
184 | * @return String |
||
0 ignored issues
–
show
|
|||
185 | */ |
||
186 | public function getFullImage() |
||
187 | { |
||
188 | View Code Duplication | if (!count($this->dataAsArray)) { |
|
0 ignored issues
–
show
This code seems to be duplicated across 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. ![]() |
|||
189 | //remove non-ascii characters as they were causing havoc... |
||
190 | $this->Data = preg_replace('/[^(\x20-\x7F)]*/', '', $this->Data); |
||
0 ignored issues
–
show
The property
Data does not exist on object<VimeoDataObject> . 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
Data does not exist on object<VimeoDataObject> . 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. ![]() |
|||
191 | $this->dataAsArray = $this->safelyUnserialize($this->Data); |
||
0 ignored issues
–
show
The property
Data does not exist on object<VimeoDataObject> . 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. ![]() |
|||
192 | } |
||
193 | if (!empty($this->dataAsArray["thumbnail_url"])) { |
||
194 | $imageLink = str_replace("_295x166", "", $this->dataAsArray["thumbnail_url"]); |
||
195 | $v = "<img src=\"".$imageLink."\" alt=\"".Convert::raw2att($this->Title)."\"/>"; |
||
0 ignored issues
–
show
The property
Title does not exist on object<VimeoDataObject> . 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. ![]() |
|||
196 | } else { |
||
197 | $v = "[".$this->Title."]"; |
||
0 ignored issues
–
show
The property
Title does not exist on object<VimeoDataObject> . 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. ![]() |
|||
198 | } |
||
199 | return DBField::create_field("HTMLText", $v); |
||
200 | } |
||
201 | |||
202 | /** |
||
203 | * returns icon as myimage.png |
||
204 | * @return String |
||
0 ignored issues
–
show
|
|||
205 | */ |
||
206 | public function getFullImageLink() |
||
207 | { |
||
208 | $this->getDataAsArray(); |
||
209 | if (!empty($this->dataAsArray["thumbnail_url"])) { |
||
210 | $imageLink = str_replace("_295x166", "", $this->dataAsArray["thumbnail_url"]); |
||
211 | return DBField::create_field("Varchar", $imageLink); |
||
212 | } |
||
213 | return null; |
||
214 | } |
||
215 | |||
216 | /** |
||
217 | * returns the HTML Embed code |
||
218 | * @return String |
||
219 | */ |
||
220 | public function HTML($noCaching = false) |
||
0 ignored issues
–
show
HTML uses the super-global variable $_GET which is generally not recommended.
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: // Bad
class Router
{
public function generate($path)
{
return $_SERVER['HOST'].$path;
}
}
// Better
class Router
{
private $host;
public function __construct($host)
{
$this->host = $host;
}
public function generate($path)
{
return $this->host.$path;
}
}
class Controller
{
public function myAction(Request $request)
{
// Instead of
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
// Better (assuming you use the Symfony2 request)
$page = $request->query->get('page', 1);
}
}
![]() |
|||
221 | { |
||
222 | if ($noCaching || strlen($this->HTMLSnippet) < 17 || !$this->Data || isset($_GET["flush"])) { |
||
0 ignored issues
–
show
The property
HTMLSnippet does not exist on object<VimeoDataObject> . 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
Data does not exist on object<VimeoDataObject> . 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. ![]() |
|||
223 | // |
||
224 | $this->updateData(); |
||
225 | } |
||
226 | return $this->HTMLSnippet; |
||
0 ignored issues
–
show
The property
HTMLSnippet does not exist on object<VimeoDataObject> . 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. ![]() |
|||
227 | } |
||
228 | |||
229 | /** |
||
230 | * turns the saved serialized data into an array to return |
||
231 | * if there is no data then it will try to retrieve and save it |
||
232 | * then return it. |
||
233 | * @return Array |
||
234 | */ |
||
235 | protected function getDataAsArray() |
||
236 | { |
||
237 | if ($this->dataAsArray) { |
||
0 ignored issues
–
show
The expression
$this->dataAsArray of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() |
|||
238 | return $this->dataAsArray; |
||
239 | } |
||
240 | if (!$this->Data) { |
||
0 ignored issues
–
show
The property
Data does not exist on object<VimeoDataObject> . 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. ![]() |
|||
241 | $this->updateData(); |
||
242 | } |
||
243 | $this->dataAsArray = $this->safelyUnserialize($this->Data); |
||
0 ignored issues
–
show
The property
Data does not exist on object<VimeoDataObject> . 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. ![]() |
|||
244 | return $this->dataAsArray; |
||
245 | } |
||
246 | |||
247 | /** |
||
248 | * retrieves data from Vimeo Site |
||
249 | * |
||
250 | * @return Array |
||
251 | */ |
||
252 | protected function updateData($writeToDatabase = true) |
||
253 | { |
||
254 | if ($this->doNotRetrieveData) { |
||
0 ignored issues
–
show
This
if statement is empty and can be removed.
This check looks for the bodies of These if (rand(1, 6) > 3) {
//print "Check failed";
} else {
print "Check succeeded";
}
could be turned into if (rand(1, 6) <= 3) {
print "Check succeeded";
}
This is much more concise to read. ![]() |
|||
255 | //do nothing |
||
256 | } elseif ($this->VimeoCode) { |
||
0 ignored issues
–
show
The property
VimeoCode does not exist on object<VimeoDataObject> . 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. ![]() |
|||
257 | $get = array(); |
||
258 | if ($width = $this->Config()->get("width")) { |
||
259 | $get["width"] = $width; |
||
260 | } |
||
261 | if ($max_width = $this->Config()->get("maxwidth")) { |
||
262 | $get["maxwidth"] = $max_width; |
||
263 | } |
||
264 | if ($height = $this->Config()->get("height")) { |
||
265 | $get["height"] = $height; |
||
266 | } |
||
267 | if ($maxheight = $this->Config()->get("maxheight")) { |
||
268 | $get["maxheight"] = $maxheight; |
||
269 | } |
||
270 | if ($byline = $this->Config()->get("byline")) { |
||
271 | $get["byline"] = $byline; |
||
272 | } |
||
273 | if ($title = $this->Config()->get("title")) { |
||
274 | $get["title"] = $title; |
||
275 | } |
||
276 | if ($portrait = $this->Config()->get("portrait")) { |
||
277 | $get["portrait"] = $portrait; |
||
278 | } |
||
279 | if ($color = $this->Config()->get("color")) { |
||
280 | $get["color"] = $color; |
||
281 | } |
||
282 | if ($callback = $this->Config()->get("callback")) { |
||
283 | $get["callback"] = $callback; |
||
284 | } |
||
285 | if ($autoplay = $this->Config()->get("autoplay ")) { |
||
286 | $get["autoplay"] = $autoplay; |
||
287 | } |
||
288 | if ($xhtml = $this->Config()->get("xhtml")) { |
||
289 | $get["xhtml"] = $xhtml; |
||
290 | } |
||
291 | if ($api = $this->Config()->get("api")) { |
||
292 | $get["api"] = $api; |
||
293 | } |
||
294 | if ($wmode = $this->Config()->get("wmode")) { |
||
295 | $get["wmode"] = $wmode; |
||
296 | } |
||
297 | if ($iframe = $this->Config()->get("iframe")) { |
||
298 | $get["iframe"] = $iframe; |
||
299 | } |
||
300 | $url = ''; |
||
301 | $url .= $this->Config()->get("vimeo_base_url").$this->VimeoCode; |
||
0 ignored issues
–
show
The property
VimeoCode does not exist on object<VimeoDataObject> . 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. ![]() |
|||
302 | if (is_array($get) && count($get)) { |
||
303 | foreach ($get as $key => $value) { |
||
304 | $get[$key] = $key."=".urlencode($value); |
||
305 | } |
||
306 | $url .= "?".implode("&", $get); |
||
307 | } |
||
308 | $ch = curl_init(); |
||
309 | curl_setopt($ch, CURLOPT_URL, $url); |
||
310 | curl_setopt($ch, CURLOPT_HEADER, 0); |
||
311 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
||
312 | $data = curl_exec($ch); |
||
313 | $array = $this->my_xml2array($data); |
||
314 | foreach ($this->variables as $variable) { |
||
315 | $data_array = $this->get_value_by_path($array, 'oembed/'.$variable); |
||
316 | if (isset($data_array["name"]) && isset($data_array["value"])) { |
||
317 | $this->dataAsArray[$data_array["name"]] = $data_array["value"]; |
||
318 | } else { |
||
319 | $this->dataAsArray[$variable] = null; |
||
320 | } |
||
321 | } |
||
322 | $this->Data = $this->safelySerialize($this->dataAsArray); |
||
0 ignored issues
–
show
The property
Data does not exist on object<VimeoDataObject> . 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. ![]() |
|||
323 | $this->HTMLSnippet = $this->dataAsArray["html"]; |
||
0 ignored issues
–
show
The property
HTMLSnippet does not exist on object<VimeoDataObject> . 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. ![]() |
|||
324 | if ($writeToDatabase) { |
||
325 | $this->write(); |
||
326 | } |
||
327 | } |
||
328 | return $this->Data; |
||
0 ignored issues
–
show
The property
Data does not exist on object<VimeoDataObject> . 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. ![]() |
|||
329 | } |
||
330 | |||
331 | |||
332 | public function onBeforeWrite() |
||
333 | { |
||
334 | parent::onBeforeWrite(); |
||
335 | $this->VimeoCode = intval($this->VimeoCode); |
||
0 ignored issues
–
show
The property
VimeoCode does not exist on object<VimeoDataObject> . 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
VimeoCode does not exist on object<VimeoDataObject> . 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. ![]() |
|||
336 | $this->updateData(false); |
||
337 | } |
||
338 | |||
339 | |||
340 | //SOURCE: http://php.net/manual/en/function.xml-parse.php |
||
341 | private function my_xml2array($contents) |
||
342 | { |
||
343 | $parser = xml_parser_create(''); |
||
344 | if (!$parser) { |
||
345 | return false; |
||
346 | } |
||
347 | xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); |
||
348 | xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); |
||
349 | xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
||
350 | xml_parse_into_struct($parser, trim($contents), $xml_values); |
||
351 | xml_parser_free($parser); |
||
352 | if (!$xml_values) { |
||
0 ignored issues
–
show
The expression
$xml_values of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() |
|||
353 | return array(); |
||
354 | } |
||
355 | $xml_array = array(); |
||
356 | $last_tag_ar =& $xml_array; |
||
357 | $parents = array(); |
||
358 | $last_counter_in_tag = array(1=>0); |
||
359 | foreach ($xml_values as $data) { |
||
360 | switch ($data['type']) { |
||
361 | case 'open': |
||
362 | $last_counter_in_tag[$data['level']+1] = 0; |
||
363 | $new_tag = array('name' => $data['tag']); |
||
364 | if (isset($data['attributes'])) { |
||
365 | $new_tag['attributes'] = $data['attributes']; |
||
366 | } |
||
367 | View Code Duplication | if (isset($data['value']) && trim($data['value'])) { |
|
0 ignored issues
–
show
This code seems to be duplicated across 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. ![]() |
|||
368 | $new_tag['value'] = trim($data['value']); |
||
369 | } |
||
370 | $last_tag_ar[$last_counter_in_tag[$data['level']]] = $new_tag; |
||
371 | $parents[$data['level']] =& $last_tag_ar; |
||
372 | $last_tag_ar =& $last_tag_ar[$last_counter_in_tag[$data['level']]++]; |
||
373 | break; |
||
374 | case 'complete': |
||
375 | $new_tag = array('name' => $data['tag']); |
||
376 | if (isset($data['attributes'])) { |
||
377 | $new_tag['attributes'] = $data['attributes']; |
||
378 | } |
||
379 | View Code Duplication | if (isset($data['value']) && trim($data['value'])) { |
|
0 ignored issues
–
show
This code seems to be duplicated across 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. ![]() |
|||
380 | $new_tag['value'] = trim($data['value']); |
||
381 | } |
||
382 | $last_count = count($last_tag_ar)-1; |
||
0 ignored issues
–
show
$last_count 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 ![]() |
|||
383 | $last_tag_ar[$last_counter_in_tag[$data['level']]++] = $new_tag; |
||
384 | break; |
||
385 | case 'close': |
||
386 | $last_tag_ar =& $parents[$data['level']]; |
||
387 | break; |
||
388 | default: |
||
389 | break; |
||
390 | }; |
||
391 | } |
||
392 | return $xml_array; |
||
393 | } |
||
394 | |||
395 | // |
||
396 | // use this to get node of tree by path with '/' terminator |
||
397 | // |
||
398 | //SOURCE: http://php.net/manual/en/function.xml-parse.php |
||
399 | private function get_value_by_path($__xml_tree, $__tag_path) |
||
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 ![]() |
|||
400 | { |
||
401 | $tmp_arr =& $__xml_tree; |
||
402 | $tag_path = explode('/', $__tag_path); |
||
403 | foreach ($tag_path as $tag_name) { |
||
404 | $res = false; |
||
405 | foreach ($tmp_arr as $key => $node) { |
||
406 | if (is_int($key) && $node['name'] == $tag_name) { |
||
407 | $tmp_arr = $node; |
||
408 | $res = true; |
||
409 | break; |
||
410 | } |
||
411 | } |
||
412 | if (!$res) { |
||
413 | return false; |
||
414 | } |
||
415 | } |
||
416 | return $tmp_arr; |
||
417 | } |
||
418 | |||
419 | /** |
||
420 | * |
||
421 | * @param String $serializedData |
||
422 | * |
||
423 | * @return Array |
||
424 | */ |
||
425 | public function safelyUnserialize($serializedData) |
||
426 | { |
||
427 | return unserialize(base64_decode($serializedData)); |
||
428 | //this code needs checking. |
||
429 | try { |
||
0 ignored issues
–
show
try { $fixed = unser... }, $serializedData); } does not seem to be reachable.
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed. Unreachable code is most often the result of function fx() {
try {
doSomething();
return true;
}
catch (\Exception $e) {
return false;
}
return false;
}
In the above example, the last ![]() |
|||
430 | $fixed = unserialize(base64_decode($serializedData)); |
||
431 | if (is_array($fixed)) { |
||
432 | return $fixed; |
||
433 | } else { |
||
434 | return unserialize($serializedData); |
||
435 | } |
||
436 | } catch (Exception $e) { |
||
437 | $fixed = preg_replace_callback( |
||
438 | '!s:(\d+):"(.*?)";!', |
||
439 | function ($match) { |
||
440 | return ($match[1] == strlen($match[2])) ? $match[0] : 's:' . strlen($match[2]) . ':"' . $match[2] . '";'; |
||
441 | }, |
||
442 | $serializedData |
||
443 | ); |
||
444 | } |
||
445 | return $fixed; |
||
446 | } |
||
447 | |||
448 | /** |
||
449 | * |
||
450 | * @param Array $dataAsArray |
||
451 | * |
||
452 | * @return String |
||
453 | * |
||
454 | */ |
||
455 | public function safelySerialize($dataAsArray) |
||
456 | { |
||
457 | return base64_encode(serialize($dataAsArray)); |
||
458 | } |
||
459 | } |
||
460 |
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.