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 |
||
0 ignored issues
–
show
|
|||
2 | /** |
||
3 | * HomeFinder Widgets Class |
||
4 | * |
||
5 | * @package RE-PRO |
||
6 | */ |
||
7 | |||
8 | // Exit if accessed directly. |
||
9 | if ( ! defined( 'ABSPATH' ) ) { exit; } |
||
10 | |||
11 | if ( ! class_exists( 'HomeFinderWidgets' ) ) { |
||
12 | /** |
||
13 | * HomeFinderWidgets class. |
||
14 | */ |
||
15 | class HomeFinderWidgets { |
||
0 ignored issues
–
show
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.
You can fix this by adding a namespace to your class: namespace YourVendor;
class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries. ![]() |
|||
16 | |||
17 | /** |
||
18 | * Widget data to be sent to JS. |
||
19 | * |
||
20 | * @var [Array] |
||
21 | */ |
||
22 | static private $hf_data; |
||
23 | |||
24 | /** |
||
25 | * __construct function. |
||
26 | * |
||
27 | * @access public |
||
28 | * @return void |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Adding a
@return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.
Adding a Please refer to the PHP core documentation on constructors. ![]() |
|||
29 | */ |
||
30 | public function __construct() { |
||
31 | add_action( 'wp_footer', array( $this, 'hf_enqueue' ) ); |
||
32 | |||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Enqueue JS on footer and handle multiple widgets. |
||
37 | */ |
||
38 | public function hf_enqueue() { |
||
39 | wp_enqueue_script( 'hf-widget-loader', 'http://www.homefinder.com/widgets/js/widgetLoader.js', array( 'jquery' ), null, true ); |
||
40 | wp_enqueue_script( 'hf-widgets-js', plugins_url( 'homefinder-widgets.js', __FILE__ ), array( 'jquery' ), null, true ); |
||
41 | wp_localize_script( 'hf-widgets-js', 'hf_data', static::$hf_data ); |
||
0 ignored issues
–
show
Since
$hf_data is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self , or increasing the visibility of $hf_data to at least protected.
Let’s assume you have a class which uses late-static binding: class YourClass
{
private static $someVariable;
public static function getSomeVariable()
{
return static::$someVariable;
}
}
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the class YourSubClass extends YourClass { }
YourSubClass::getSomeVariable(); // Will cause an access error.
In the case above, it makes sense to update class SomeClass
{
private static $someVariable;
public static function getSomeVariable()
{
return self::$someVariable; // self works fine with private.
}
}
![]() |
|||
42 | |||
43 | } |
||
44 | |||
45 | /** |
||
46 | * HomeFinder ID Names. |
||
47 | * |
||
48 | * @access public |
||
49 | * @param string $widget_id (default: ''). |
||
50 | * @return string $widget_id. |
||
51 | */ |
||
52 | public function homefinder_id( $widget_id = '' ) { |
||
53 | |||
54 | if ( '' !== $widget_id ) { |
||
55 | return sanitize_html_class( $widget_id ); |
||
56 | } |
||
57 | |||
58 | } |
||
59 | |||
60 | /** |
||
61 | * HomeFinder div Class Names. |
||
62 | * |
||
63 | * @access public |
||
64 | * @param string $widget_name (default: ''). |
||
65 | * @return string class name. |
||
66 | */ |
||
67 | public function homefinder_class( $widget_name = '' ) { |
||
68 | |||
69 | if ( '' !== $widget_name ) { |
||
70 | return 'homefinder homefinder-widget homefinder-' . sanitize_html_class( $widget_name ) . '-widget'; |
||
71 | } else { |
||
72 | return 'homefinder homefinder-widget'; |
||
73 | } |
||
74 | |||
75 | } |
||
76 | |||
77 | /* HomeFinder WIDGETS. */ |
||
78 | |||
79 | /** |
||
80 | * Get Homes For Sale Widget. |
||
81 | * |
||
82 | * @access public |
||
83 | * @return void |
||
84 | */ |
||
85 | View Code Duplication | public function get_homes_for_sale_widget() { |
|
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. ![]() |
|||
86 | |||
87 | $widget_data = array( |
||
88 | 'type' => 'homeSearch', |
||
89 | 'container' => 'homeSearchWidget', |
||
90 | ); |
||
91 | static::$hf_data[] = $widget_data; |
||
0 ignored issues
–
show
Since
$hf_data is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self , or increasing the visibility of $hf_data to at least protected.
Let’s assume you have a class which uses late-static binding: class YourClass
{
private static $someVariable;
public static function getSomeVariable()
{
return static::$someVariable;
}
}
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the class YourSubClass extends YourClass { }
YourSubClass::getSomeVariable(); // Will cause an access error.
In the case above, it makes sense to update class SomeClass
{
private static $someVariable;
public static function getSomeVariable()
{
return self::$someVariable; // self works fine with private.
}
}
![]() |
|||
92 | |||
93 | $index = count( static::$hf_data ) - 1; |
||
0 ignored issues
–
show
Since
$hf_data is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self , or increasing the visibility of $hf_data to at least protected.
Let’s assume you have a class which uses late-static binding: class YourClass
{
private static $someVariable;
public static function getSomeVariable()
{
return static::$someVariable;
}
}
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the class YourSubClass extends YourClass { }
YourSubClass::getSomeVariable(); // Will cause an access error.
In the case above, it makes sense to update class SomeClass
{
private static $someVariable;
public static function getSomeVariable()
{
return self::$someVariable; // self works fine with private.
}
}
![]() |
|||
94 | |||
95 | echo '<div id="homeSearchWidget-'. $index .'" class="'. $this->homefinder_class( 'homes-for-sale' ) .'"></div>'; |
||
96 | |||
97 | } |
||
98 | |||
99 | /** |
||
100 | * Get Open House Widget. |
||
101 | * |
||
102 | * @access public |
||
103 | * @return void |
||
104 | */ |
||
105 | View Code Duplication | public function get_open_house_widget() { |
|
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. ![]() |
|||
106 | |||
107 | $widget_data = array( |
||
108 | 'type' => 'openHouseSearch', |
||
109 | 'container' => 'openHouseSearchWidget', |
||
110 | ); |
||
111 | static::$hf_data[] = $widget_data; |
||
0 ignored issues
–
show
Since
$hf_data is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self , or increasing the visibility of $hf_data to at least protected.
Let’s assume you have a class which uses late-static binding: class YourClass
{
private static $someVariable;
public static function getSomeVariable()
{
return static::$someVariable;
}
}
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the class YourSubClass extends YourClass { }
YourSubClass::getSomeVariable(); // Will cause an access error.
In the case above, it makes sense to update class SomeClass
{
private static $someVariable;
public static function getSomeVariable()
{
return self::$someVariable; // self works fine with private.
}
}
![]() |
|||
112 | |||
113 | $index = count( static::$hf_data ) - 1; |
||
0 ignored issues
–
show
Since
$hf_data is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self , or increasing the visibility of $hf_data to at least protected.
Let’s assume you have a class which uses late-static binding: class YourClass
{
private static $someVariable;
public static function getSomeVariable()
{
return static::$someVariable;
}
}
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the class YourSubClass extends YourClass { }
YourSubClass::getSomeVariable(); // Will cause an access error.
In the case above, it makes sense to update class SomeClass
{
private static $someVariable;
public static function getSomeVariable()
{
return self::$someVariable; // self works fine with private.
}
}
![]() |
|||
114 | |||
115 | echo '<div id="openHouseSearchWidget-'. $index .'" class="'. $this->homefinder_class( 'open-house' ) .'"></div>'; |
||
116 | |||
117 | } |
||
118 | |||
119 | /** |
||
120 | * Get Foreclosure Homes Widget. |
||
121 | * |
||
122 | * @access public |
||
123 | * @return void |
||
124 | */ |
||
125 | View Code Duplication | public function get_foreclosure_homes_widget() { |
|
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. ![]() |
|||
126 | |||
127 | $widget_data = array( |
||
128 | 'type' => 'foreclosureSearch', |
||
129 | 'container' => 'foreclosureSearchWidget', |
||
130 | ); |
||
131 | static::$hf_data[] = $widget_data; |
||
0 ignored issues
–
show
Since
$hf_data is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self , or increasing the visibility of $hf_data to at least protected.
Let’s assume you have a class which uses late-static binding: class YourClass
{
private static $someVariable;
public static function getSomeVariable()
{
return static::$someVariable;
}
}
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the class YourSubClass extends YourClass { }
YourSubClass::getSomeVariable(); // Will cause an access error.
In the case above, it makes sense to update class SomeClass
{
private static $someVariable;
public static function getSomeVariable()
{
return self::$someVariable; // self works fine with private.
}
}
![]() |
|||
132 | |||
133 | $index = count( static::$hf_data ) - 1; |
||
0 ignored issues
–
show
Since
$hf_data is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self , or increasing the visibility of $hf_data to at least protected.
Let’s assume you have a class which uses late-static binding: class YourClass
{
private static $someVariable;
public static function getSomeVariable()
{
return static::$someVariable;
}
}
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the class YourSubClass extends YourClass { }
YourSubClass::getSomeVariable(); // Will cause an access error.
In the case above, it makes sense to update class SomeClass
{
private static $someVariable;
public static function getSomeVariable()
{
return self::$someVariable; // self works fine with private.
}
}
![]() |
|||
134 | |||
135 | echo '<div id="foreclosureSearchWidget-'. $index .'" class="'. $this->homefinder_class( 'foreclosure-homes' ) .'"></div>'; |
||
136 | |||
137 | } |
||
138 | |||
139 | /** |
||
140 | * Get HomeFinder Widget. |
||
141 | * |
||
142 | * @access public |
||
143 | * @param string $type Widget Type. |
||
144 | * @param [Mixed] $widget_data : Array of widget data to send to js. |
||
0 ignored issues
–
show
The doc-type
[Mixed] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. ![]() |
|||
145 | * @return void |
||
146 | */ |
||
147 | public function get_affiliates_widget( $type, $widget_data ) { |
||
148 | |||
149 | $widget_data['type'] = $type; |
||
150 | static::$hf_data[] = $widget_data; |
||
0 ignored issues
–
show
Since
$hf_data is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self , or increasing the visibility of $hf_data to at least protected.
Let’s assume you have a class which uses late-static binding: class YourClass
{
private static $someVariable;
public static function getSomeVariable()
{
return static::$someVariable;
}
}
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the class YourSubClass extends YourClass { }
YourSubClass::getSomeVariable(); // Will cause an access error.
In the case above, it makes sense to update class SomeClass
{
private static $someVariable;
public static function getSomeVariable()
{
return self::$someVariable; // self works fine with private.
}
}
![]() |
|||
151 | |||
152 | $index = count( static::$hf_data ) - 1; |
||
0 ignored issues
–
show
Since
$hf_data is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self , or increasing the visibility of $hf_data to at least protected.
Let’s assume you have a class which uses late-static binding: class YourClass
{
private static $someVariable;
public static function getSomeVariable()
{
return static::$someVariable;
}
}
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the class YourSubClass extends YourClass { }
YourSubClass::getSomeVariable(); // Will cause an access error.
In the case above, it makes sense to update class SomeClass
{
private static $someVariable;
public static function getSomeVariable()
{
return self::$someVariable; // self works fine with private.
}
}
![]() |
|||
153 | |||
154 | if ( 'search' === $type ) { |
||
155 | echo '<div id="searchPreview-' . $index . '" class="'. $this->homefinder_class( 'affiliate-search' ) .'"><div>'; |
||
156 | } else if ( 'directory' === $type ) { |
||
157 | echo '<div id="directoryPreview-' . $index . '" class="'. $this->homefinder_class( 'adveritser-directory' ) .'"></div>'; |
||
158 | } |
||
159 | |||
160 | } |
||
161 | } |
||
162 | } |
||
163 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.