1 | <?php |
||
2 | namespace Pronamic\WordPress\Pay\Gateways\Ingenico\DirectLink; |
||
3 | |||
4 | use Pronamic\WordPress\Pay\Core\Gateway; |
||
0 ignored issues
–
show
|
|||
5 | use Pronamic\WordPress\Pay\Core\GatewayConfigFactory; |
||
6 | use Pronamic\WordPress\Pay\Gateways\Ingenico\DirectLink; |
||
7 | |||
8 | /** |
||
9 | * Title: Ingenico DirectLink config factory |
||
10 | * Description: |
||
11 | * Copyright: 2005-2019 Pronamic |
||
12 | * Company: Pronamic |
||
13 | * |
||
14 | * @author Remco Tolsma |
||
15 | * @version 2.0.0 |
||
16 | */ |
||
17 | class ConfigFactory extends GatewayConfigFactory { |
||
18 | public function get_config( $post_id ) { |
||
19 | $config = new Config(); |
||
20 | |||
21 | $config->mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true ); |
||
0 ignored issues
–
show
It seems like
get_post_meta($post_id, ...ic_gateway_mode', true) can also be of type false . However, the property $mode 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 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...
|
|||
22 | $config->psp_id = get_post_meta( $post_id, '_pronamic_gateway_ogone_psp_id', true ); |
||
0 ignored issues
–
show
It seems like
get_post_meta($post_id, ...ay_ogone_psp_id', true) can also be of type false . However, the property $psp_id 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 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...
|
|||
23 | $config->hash_algorithm = get_post_meta( $post_id, '_pronamic_gateway_ogone_hash_algorithm', true ); |
||
0 ignored issues
–
show
|
|||
24 | $config->sha_out_pass_phrase = get_post_meta( $post_id, '_pronamic_gateway_ogone_sha_out_pass_phrase', true ); |
||
0 ignored issues
–
show
|
|||
25 | $config->user_id = get_post_meta( $post_id, '_pronamic_gateway_ogone_user_id', true ); |
||
26 | $config->password = get_post_meta( $post_id, '_pronamic_gateway_ogone_password', true ); |
||
27 | $config->sha_in_pass_phrase = get_post_meta( $post_id, '_pronamic_gateway_ogone_directlink_sha_in_pass_phrase', true ); |
||
28 | $config->enabled_3d_secure = get_post_meta( $post_id, '_pronamic_gateway_ogone_3d_secure_enabled', true ); |
||
0 ignored issues
–
show
|
|||
29 | $config->order_id = get_post_meta( $post_id, '_pronamic_gateway_ogone_order_id', true ); |
||
0 ignored issues
–
show
|
|||
30 | |||
31 | // API URL |
||
32 | $is_utf8 = strcasecmp( get_bloginfo( 'charset' ), 'UTF-8' ) === 0; |
||
33 | |||
34 | switch ( $config->mode ) { |
||
35 | case Gateway::MODE_TEST: |
||
36 | if ( $is_utf8 ) { |
||
37 | $config->api_url = DirectLink::API_TEST_UTF8_URL; |
||
38 | } else { |
||
39 | $config->api_url = DirectLink::API_TEST_URL; |
||
40 | } |
||
41 | |||
42 | break; |
||
43 | default: |
||
44 | if ( $is_utf8 ) { |
||
45 | $config->api_url = DirectLink::API_PRODUCTION_UTF8_URL; |
||
46 | } else { |
||
47 | $config->api_url = DirectLink::API_PRODUCTION_URL; |
||
48 | } |
||
49 | } |
||
50 | |||
51 | return $config; |
||
52 | } |
||
53 | } |
||
54 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: