GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (1449)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Message/AbstractRequest.php (162 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Omnipay\FirstAtlanticCommerce\Message;
4
5
use Omnipay\Common\Message\AbstractRequest as BaseAbstractRequest;
6
use Omnipay\FirstAtlanticCommerce\CreditCard;
7
use Omnipay\FirstAtlanticCommerce\ParameterTrait;
8
use SimpleXMLElement;
9
10
abstract class AbstractRequest extends BaseAbstractRequest
11
{
12
    use ParameterTrait;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
13
14
    /**
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
15
     * FACPG2 live endpoint URL
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
16
     *
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
17
     * @var string
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
18
     */
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
19
    protected $liveEndpoint = 'https://marlin.firstatlanticcommerce.com/PGServiceXML/';
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
20
21
    /**
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
22
     * FACPG2 test endpoint URL
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
23
     *
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
24
     * @var string
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
25
     */
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
26
    protected $testEndpoint = 'https://ecm.firstatlanticcommerce.com/PGServiceXML/';
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
27
28
    /**
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
29
     * FACPG2 XML namespace
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
30
     *
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
31
     * @var string
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
32
     */
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
33
    protected $namespace = 'http://schemas.firstatlanticcommerce.com/gateway/data';
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
34
35
    /**
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
36
     * FACPG2 XML root
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
37
     *
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
38
     * @var string
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
39
     */
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
40
    protected $requestName;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
41
42
    /**
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
43
     * Returns the amount formatted to match FAC's expectations.
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
44
     *
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
45
     * @return string The amount padded with zeros on the left to 12 digits and no decimal place.
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
46
     */
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
47
    protected function formatAmount()
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
The function name formatAmount is in camel caps, but expected format_amount instead as per the coding standard.
Loading history...
48
    {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
49
        $amount = $this->getAmount();
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
50
51
        $amount = str_replace('.', '', $amount);
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Expected 1 spaces after opening bracket; 0 found
Loading history...
Expected 1 spaces before closing bracket; 0 found
Loading history...
52
        $amount = str_pad($amount, 12, '0', STR_PAD_LEFT);
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Expected 1 spaces after opening bracket; 0 found
Loading history...
Expected 1 spaces before closing bracket; 0 found
Loading history...
53
54
        return $amount;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
55
    }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
56
57
    /**
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
58
     * Returns the live or test endpoint depending on TestMode.
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
59
     *
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
60
     * @return string Endpoint URL
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
61
     */
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
62
    protected function getEndpoint()
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
The function name getEndpoint is in camel caps, but expected get_endpoint instead as per the coding standard.
Loading history...
63
    {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
64
        return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
65
    }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
66
67
    /**
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
68
     * Return the response object
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
69
     *
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
70
     * @param \SimpleXMLElement $xml Response xml object
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
71
     *
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
72
     * @return ResponseInterface
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
73
     */
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
74
    abstract protected function newResponse($xml);
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
The function name newResponse is in camel caps, but expected new_response instead as per the coding standard.
Loading history...
75
76
    /**
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
77
     * Send the request payload
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
78
     *
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
79
     * @param array $data Request payload
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
80
     *
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
81
     * @return ResponseInterface
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
82
     */
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
83
    public function sendData($data)
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
The function name sendData is in camel caps, but expected send_data instead as per the coding standard.
Loading history...
84
    {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
85
        $httpResponse = $this->httpClient->post(
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
86
            $this->getEndpoint(),
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
87
            ['Content-Type' => 'text/xml; charset=utf-8'],
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
88
            $this->xmlSerialize($data)
0 ignored issues
show
It seems like $this->xmlSerialize($data) targeting Omnipay\FirstAtlanticCom...Request::xmlSerialize() can also be of type false; however, Guzzle\Http\ClientInterface::post() does only seem to accept array|object<Guzzle\Comm...tityBodyInterface>|null, did you maybe forget to handle an error condition?
Loading history...
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Expected 1 spaces after opening bracket; 0 found
Loading history...
Expected 1 spaces before closing bracket; 0 found
Loading history...
89
        )->send();
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
90
91
        return $this->response = $this->newResponse( $httpResponse->xml() );
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->newResponse($httpResponse->xml()) of type object<Omnipay\FirstAtla...sage\ResponseInterface> is incompatible with the declared type object<Omnipay\Common\Message\ResponseInterface> of property $response.

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...
Bug Best Practice introduced by
The return type of return $this->response =...($httpResponse->xml()); (Omnipay\FirstAtlanticCom...ssage\ResponseInterface) is incompatible with the return type declared by the interface Omnipay\Common\Message\RequestInterface::sendData of type Omnipay\Common\Message\ResponseInterface.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

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

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
Tabs must be used to indent lines; spaces are not allowed
Loading history...
92
    }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
93
94
    /**
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
95
     * Serializes an array into XML
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
96
     *
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
97
     * @param array $data Array to serialize into XML.
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
98
     * @param \SimpleXMLElement $xml SimpleXMLElement object.
0 ignored issues
show
Should the type for parameter $xml not be SimpleXMLElement|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
Tabs must be used to indent lines; spaces are not allowed
Loading history...
99
     *
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
100
     * @return string XML
0 ignored issues
show
Should the return type not be string|false?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
Tabs must be used to indent lines; spaces are not allowed
Loading history...
101
     */
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
102
    protected function xmlSerialize($data, $xml = null)
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
The function name xmlSerialize is in camel caps, but expected xml_serialize instead as per the coding standard.
Loading history...
103
    {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
104
        if ( !$xml instanceof SimpleXMLElement )
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Opening brace should be on the same line as the declaration
Loading history...
Expected 1 space after "!"; 0 found
Loading history...
105
        {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
106
            $xml = new SimpleXMLElement('<'. $this->requestName .' xmlns="'. $this->namespace .'" />');
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Expected 1 spaces after opening bracket; 0 found
Loading history...
Expected 1 spaces before closing bracket; 0 found
Loading history...
107
        }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
108
109
        foreach ($data as $key => $value)
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
No space after opening parenthesis is prohibited
Loading history...
Opening brace should be on the same line as the declaration
Loading history...
No space before closing parenthesis is prohibited
Loading history...
110
        {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
111
            if ( !isset($value) )
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Opening brace should be on the same line as the declaration
Loading history...
Expected 1 space after "!"; 0 found
Loading history...
Expected 1 spaces after opening bracket; 0 found
Loading history...
Expected 1 spaces before closing bracket; 0 found
Loading history...
112
            {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
113
                continue;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
114
            }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
115
116
            if ( is_array($value) )
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Opening brace should be on the same line as the declaration
Loading history...
Expected 1 spaces after opening bracket; 0 found
Loading history...
Expected 1 spaces before closing bracket; 0 found
Loading history...
117
            {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
118
                $node = $xml->addChild($key);
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Expected 1 spaces after opening bracket; 0 found
Loading history...
Expected 1 spaces before closing bracket; 0 found
Loading history...
119
                $this->xmlSerialize($value, $node);
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Expected 1 spaces after opening bracket; 0 found
Loading history...
Expected 1 spaces before closing bracket; 0 found
Loading history...
120
            }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
121
            else
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
122
            {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
123
                $xml->addChild($key, $value);
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Expected 1 spaces after opening bracket; 0 found
Loading history...
Expected 1 spaces before closing bracket; 0 found
Loading history...
124
            }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
125
        }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
126
127
        return $xml->asXML();
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
128
    }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
129
130
    /**
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
131
     * Sets the card.
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
132
     *
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
133
     * @param CreditCard $value
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
134
     *
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
135
     * @return AbstractRequest Provides a fluent interface
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
136
     */
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
137
    public function setCard($value)
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
The function name setCard is in camel caps, but expected set_card instead as per the coding standard.
Loading history...
138
    {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
139
        if ($value && !$value instanceof CreditCard)
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
No space after opening parenthesis is prohibited
Loading history...
Opening brace should be on the same line as the declaration
Loading history...
Expected 1 space after "!"; 0 found
Loading history...
No space before closing parenthesis is prohibited
Loading history...
140
        {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
141
            $value = new CreditCard($value);
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Expected 1 spaces after opening bracket; 0 found
Loading history...
Expected 1 spaces before closing bracket; 0 found
Loading history...
142
        }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
143
144
        return $this->setParameter('card', $value);
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Expected 1 spaces after opening bracket; 0 found
Loading history...
Expected 1 spaces before closing bracket; 0 found
Loading history...
145
    }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
146
}
147