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.
Completed
Push — master ( 204442...383a2e )
by Christian
03:07
created

src/Task/ExitTask.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
use Netresearch\Kite\Task;
17
use Netresearch\Kite\Exception\ExitException;
18
19
/**
20
 * Exit
21
 *
22
 * @category   Netresearch
23
 * @package    Netresearch\Kite
24
 * @subpackage Task
25
 * @author     Christian Opitz <[email protected]>
26
 * @license    http://www.netresearch.de Netresearch Copyright
27
 * @link       http://www.netresearch.de
28
 */
29
class ExitTask extends Task
30
{
31
    /**
32
     * Configure the options
33
     *
34
     * @return array
35
     */
36
    protected function configureVariables()
37
    {
38
        return array(
0 ignored issues
show
The expression return array('code' => 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...
39
            'code' => array(
40
                'type' => 'int',
41
                'default' => 0,
42
                'label' => 'Code to exit with'
43
            ),
44
            '--'
45
        ) + parent::configureVariables();
46
    }
47
48
    /**
49
     * Run the task
50
     *
51
     * @return void
52
     */
53
    public function run()
54
    {
55
        throw new ExitException($this->get('message'), $this->get('code'));
56
    }
57
}
58
?>
59