and let’s assume the following content of Bar.php:
// Bar.phpnamespaceOtherDir;useSomeDir\Foo;// This now conflicts the class OtherDir\Foo
If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the
same runtime, you will see a PHP error such as the following:
PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as OtherDir/Foo.php does not necessarily have to be loaded and the
error is only triggered if it is loaded before OtherDir/Bar.php, this problem
might go unnoticed for a while. In order to prevent this error from surfacing,
you must import the namespace with a different alias:
// Bar.phpnamespaceOtherDir;useSomeDir\FooasSomeDirFoo;// There is no conflict anymore.
Loading history...
5
6
/**
7
* Class Marker_Model
8
* @package Clubdeuce\WPLib\Components\GoogleMaps
9
*
10
* @method \Clubdeuce\WPGoogleMaps\Marker marker()
11
*/
12
class Marker_Model extends Model_Base {
13
14
/**
15
* @var \Clubdeuce\WPGoogleMaps\Marker
16
*/
17
protected $_marker;
18
19
/**
20
* @return bool
21
*/
22
1
function has_marker() {
23
24
1
return $this->_has( '_marker' );
25
26
}
27
28
/**
29
* @return Location
30
*/
31
2
function location() {
32
33
2
return new Location( array( 'location' => $this->marker()->location() ) );
34
35
}
36
37
/**
38
* @return Marker_Label
39
*/
40
1
function label() {
41
42
1
return new Marker_Label( array( 'label' => $this->marker()->label() ) );
43
44
}
45
46
/**
47
* @return Info_Window
48
*/
49
1
function info_window() {
50
51
1
return new Info_Window( array( 'info_window' => $this->marker()->info_window() ) );
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.
Both the $myVar assignment in line 1 and the $higher assignment in line 2
are dead. The first because $myVar is never used and the second because
$higher is always overwritten for every possible time line.
Are you sure the assignment to $value is correct as parent::__call($method_name, $args) (which targets Clubdeuce\WPLib\Componen...ps\Model_Base::__call()) 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.
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: