Failed Conditions
Push — master ( 81451d...61709b )
by Alexander
03:23
created

Updater   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 21
ccs 0
cts 9
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A newVersionAvailable() 0 11 3
1
<?php
2
/**
3
 * This file is part of the SVN-Buddy library.
4
 * For the full copyright and license information, please view
5
 * the LICENSE file that was distributed with this source code.
6
 *
7
 * @copyright Alexander Obuhovich <[email protected]>
8
 * @link      https://github.com/console-helpers/svn-buddy
9
 */
10
11
namespace ConsoleHelpers\SVNBuddy\Updater;
12
13
14
use Humbug\SelfUpdate\Updater as BaseUpdater;
15
16
class Updater extends BaseUpdater
17
{
18
19
	/**
20
	 * Detects if new versions are available.
21
	 *
22
	 * @return boolean
23
	 */
24
	protected function newVersionAvailable()
25
	{
26
		$this->newVersion = $this->strategy->getCurrentRemoteVersion($this);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->strategy->getCurrentRemoteVersion($this) can also be of type boolean. However, the property $newVersion is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

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

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
27
		$this->oldVersion = $this->strategy->getCurrentLocalVersion($this);
28
29
		if ( !empty($this->newVersion) && ($this->newVersion !== $this->oldVersion) ) {
0 ignored issues
show
Unused Code introduced by
This if statement, and the following return statement can be replaced with return !empty($this->new... !== $this->oldVersion;.
Loading history...
30
			return true;
31
		}
32
33
		return false;
34
	}
35
36
}
37