Issues (74)

src/Fastspring/Fastspring.php (2 issues)

1
<?php
2
3
namespace Bgultekin\CashierFastspring\Fastspring;
4
5
/**
6
 * This class helps to reach Fastspring class with laravel config and static methods.
7
 *
8
 * @author   Bilal Gultekin <[email protected]>
9
 *
10
 * @version  0.1
11
 *
12
 * @see      https://docs.fastspring.com/integrating-with-fastspring/fastspring-api
13
 */
14
class Fastspring
15
{
16
    /**
17
     * Instance of Fastspring class.
18
     *
19
     * @var array
20
     */
21
    public static $instance;
22
23
    /**
24
     * It is not useful to construct this Fastspring class everytime.
25
     * This helps to construct this class with the current config.
26
     */
27 18
    public static function __callStatic($method, $parameters)
28
    {
29
        // if there is not any constructed instance
30
        // construct and save it to self::$instance
31 18
        if (!self::$instance) {
0 ignored issues
show
Bug Best Practice introduced by
The expression self::instance of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
32 1
            $username = (getenv('FASTSPRING_USERNAME') ?: config('services.fastspring.username'));
33 1
            $password = (getenv('FASTSPRING_PASSWORD') ?: config('services.fastspring.password'));
34
35 1
            self::$instance = new ApiClient($username, $password);
0 ignored issues
show
Documentation Bug introduced by
It seems like new Bgultekin\CashierFas...t($username, $password) of type Bgultekin\CashierFastspring\Fastspring\ApiClient is incompatible with the declared type array of property $instance.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
36
        }
37
38 18
        return call_user_func_array([self::$instance, $method], $parameters);
39
    }
40
}
41