Completed
Push — master ( 590f4c...1ff8f1 )
by Michael
05:40
created

Runner::runPHPCBF()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace SugaredRim\PHP\CodeSniffer;
4
5
class Runner extends \PHP_CodeSniffer\Runner
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $sugaredRimTrigger;
11
12
    /**
13
     * @inheritDoc
14
     */
15
    public function init():void
16
    {
17
        $this->config = new Config();
18
19
        // v3.* and still sucks :-(
20
        if ($this->sugaredRimTrigger === 'runPHPCBF') {
21
            if ($this->config->stdin === true) {
0 ignored issues
show
Documentation introduced by
The property stdin does not exist on object<SugaredRim\PHP\CodeSniffer\Config>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
22
                $this->config->verbosity = 0;
0 ignored issues
show
Documentation introduced by
The property verbosity does not exist on object<SugaredRim\PHP\CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
23
            }
24
        }
25
26
        parent::init();
27
    }
28
29
    /**
30
     * @inheritDoc
31
     */
32
    public function runPHPCS()
33
    {
34
        $this->sugaredRimTrigger = 'runPHPCS';
35
        return parent::runPHPCS();
36
    }
37
38
    /**
39
     * @inheritDoc
40
     */
41
    public function runPHPCBF()
42
    {
43
        $this->sugaredRimTrigger = 'runPHPCBF';
44
        return parent::runPHPCBF();
45
    }
46
}
47