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.

IncludeTask::configureVariables()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 11
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * See class comment
4
 *
5
 * PHP Version 5
6
 *
7
 * @category   Netresearch
8
 * @package    Netresearch\Kite
9
 * @subpackage Task
10
 * @author     Christian Opitz <[email protected]>
11
 * @license    http://www.netresearch.de Netresearch Copyright
12
 * @link       http://www.netresearch.de
13
 */
14
15
namespace Netresearch\Kite\Task;
16
17
/**
18
 * Include a file
19
 *
20
 * @category   Netresearch
21
 * @package    Netresearch\Kite
22
 * @subpackage Task
23
 * @author     Christian Opitz <[email protected]>
24
 * @license    http://www.netresearch.de Netresearch Copyright
25
 * @link       http://www.netresearch.de
26
 */
27
class IncludeTask extends \Netresearch\Kite\Task
28
{
29
    /**
30
     * Configure the options
31
     *
32
     * @return array
33
     */
34 View Code Duplication
    protected function configureVariables()
0 ignored issues
show
Duplication introduced by
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.

Loading history...
35
    {
36
        return array(
0 ignored issues
show
Best Practice introduced by
The expression return array('file' => a...::configureVariables(); seems to be an array, but some of its elements' types (string) are incompatible with the return type of the parent method Netresearch\Kite\Task::configureVariables of type array<string,array>.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
37
            'file' => array(
38
                'type' => 'string',
39
                'required' => 'true',
40
                'label' => 'The file to include'
41
            ),
42
            '--'
43
        ) + parent::configureVariables();
44
    }
45
46
    /**
47
     * Clear the caches
48
     *
49
     * @return void
50
     */
51
    public function execute()
52
    {
53
        ob_start(
54
            function ($output) {
55
                $this->console->output($output, false);
56
                return '';
57
            }, 2, 0
58
        );
59
        include $this->get('file');
60
        ob_end_flush();
61
    }
62
}
63
?>
64