GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

TemplatePlugin::siteAdminHooks()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
require_once('common/plugin/Plugin.class.php');
4
5
class TemplatePlugin extends Plugin {
6
	
7
	function TemplatePlugin($id) {
8
		$this->Plugin($id);
9
        $this->_addHook('hook_name');
10
        $this->_addHook('site_admin_option_hook', 'siteAdminHooks', false);
11
	}
12
	
13
    function getPluginInfo() {
14
        if (!is_a($this->pluginInfo, 'TemplatePluginInfo')) {
15
            require_once('TemplatePluginInfo.class.php');
16
            $this->pluginInfo = new TemplatePluginInfo($this);
17
        }
18
        return $this->pluginInfo;
19
    }
20
21
	function CallHook($hook, $params) {
22
		if ($hook == 'hook_name') {
23
			//do Something
24
		}
25
	}
26
    
27
    function siteAdminHooks($params) {
28
        echo '<li><a href="'.$this->getPluginPath().'/">Template</a></li>';
29
    }
30
    
31
    function process() {
32
        echo '<h1>Template</h1>';
33
        echo $this->getPluginInfo()->getpropVal('answer');
0 ignored issues
show
Bug introduced by
The method getpropVal does only exist in ArchiveDeletedItemsPlugi... and TemplatePluginInfo, but not in AdminDelegationPluginInf...fo and hudsonPluginInfo.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
34
    }
35
}
36
37
?>
38