Skip to content

Commit f2d8005

Browse files
committed
Tweak code for scrutinizer issues
1 parent 191bfb4 commit f2d8005

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

src/Omnipay/Common/Helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected static function convertToLowercase($str)
4343
{
4444
$explodedStr = explode('_', $str);
4545
$lowercasedStr = [];
46-
46+
4747
if (count($explodedStr) > 1) {
4848
foreach ($explodedStr as $value) {
4949
$lowercasedStr[] = strtolower($value);

src/Omnipay/Common/Http/ResponseParser.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ private static function toString($response)
3232
*/
3333
public static function json($response)
3434
{
35-
$body = static::toString($response);
35+
$body = self::toString($response);
3636

3737
$data = json_decode($body, true);
3838
if (JSON_ERROR_NONE !== json_last_error()) {
@@ -60,7 +60,7 @@ public static function json($response)
6060
*/
6161
public static function xml($response)
6262
{
63-
$body = static::toString($response);
63+
$body = self::toString($response);
6464

6565
$errorMessage = null;
6666
$internalErrors = libxml_use_internal_errors(true);
@@ -77,9 +77,10 @@ public static function xml($response)
7777
libxml_use_internal_errors($internalErrors);
7878
libxml_disable_entity_loader($disableEntities);
7979

80-
if ($errorMessage) {
80+
if ($errorMessage !== null) {
8181
throw new RuntimeException('Unable to parse response body into XML: ' . $errorMessage);
8282
}
83+
8384
return $xml;
8485
}
8586
}

src/Omnipay/Common/Item.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Item implements ItemInterface
2626
*
2727
* @param array|null $parameters An array of parameters to set on the new object
2828
*/
29-
public function __construct($parameters = null)
29+
public function __construct(array $parameters = null)
3030
{
3131
$this->initialize($parameters);
3232
}
@@ -37,7 +37,7 @@ public function __construct($parameters = null)
3737
* @param array|null $parameters An array of parameters to set on this object
3838
* @return $this Item
3939
*/
40-
public function initialize($parameters = null)
40+
public function initialize(array $parameters = null)
4141
{
4242
$this->parameters = new ParameterBag;
4343

@@ -46,6 +46,9 @@ public function initialize($parameters = null)
4646
return $this;
4747
}
4848

49+
/**
50+
* @return array
51+
*/
4952
public function getParameters()
5053
{
5154
return $this->parameters->all();

src/Omnipay/Common/Message/AbstractResponse.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Omnipay\Common\Exception\RuntimeException;
99
use Symfony\Component\HttpFoundation\RedirectResponse as HttpRedirectResponse;
1010
use Symfony\Component\HttpFoundation\Response as HttpResponse;
11+
use Symfony\Component\HttpFoundation\Response;
1112

1213
/**
1314
* Abstract Response
@@ -174,14 +175,15 @@ public function redirect()
174175
}
175176

176177
/**
177-
* @return HttpRedirectResponse
178+
* @return HttpRedirectResponse|HttpResponse
178179
*/
179180
public function getRedirectResponse()
180181
{
181182
if (!$this instanceof RedirectResponseInterface || !$this->isRedirect()) {
182183
throw new RuntimeException('This response does not support redirection.');
183184
}
184185

186+
/** @var $this RedirectResponseInterface */
185187
if ('GET' === $this->getRedirectMethod()) {
186188
return HttpRedirectResponse::create($this->getRedirectUrl());
187189
} elseif ('POST' === $this->getRedirectMethod()) {

src/Omnipay/Omnipay.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ class Omnipay
7272
public static function getFactory()
7373
{
7474
if (is_null(static::$factory)) {
75-
static::$factory = new GatewayFactory;
75+
self::$factory = new GatewayFactory;
7676
}
7777

78-
return static::$factory;
78+
return self::$factory;
7979
}
8080

8181
/**
@@ -85,7 +85,7 @@ public static function getFactory()
8585
*/
8686
public static function setFactory(GatewayFactory $factory = null)
8787
{
88-
static::$factory = $factory;
88+
self::$factory = $factory;
8989
}
9090

9191
/**
@@ -111,7 +111,7 @@ public static function setFactory(GatewayFactory $factory = null)
111111
*/
112112
public static function __callStatic($method, $parameters)
113113
{
114-
$factory = static::getFactory();
114+
$factory = self::getFactory();
115115

116116
return call_user_func_array(array($factory, $method), $parameters);
117117
}

0 commit comments

Comments
 (0)