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.
Test Failed
Push — master ( d54200...f2da15 )
by Charlotte
03:55
created

src/Commands/QueryCommand.php (2 issues)

1
<?php
2
/**
3
 * Plasma Driver MySQL component
4
 * Copyright 2018 PlasmaPHP, All Rights Reserved
5
 *
6
 * Website: https://github.com/PlasmaPHP
7
 * License: https://github.com/PlasmaPHP/driver-mysql/blob/master/LICENSE
8
*/
9
10
namespace Plasma\Drivers\MySQL\Commands;
11
12
/**
13
 * Query command.
14
 * @internal
15
 */
16
class QueryCommand extends PromiseCommand {
17
    /**
18
     * The identifier for this command.
19
     * @var int
20
     * @source
21
     */
22
    const COMMAND_ID = 0x03;
23
    
24
    /**
25
     * @var \Plasma\DriverInterface
26
     */
27
    protected $driver;
28
    
29
    /**
30
     * @var string
31
     */
32
    protected $query;
33
    
34
    /**
35
     * @var \Plasma\ColumnDefinitionInterface[]
36
     */
37
    protected $fields = array();
38
    
39
    /**
40
     * @var int|null
41
     */
42
    protected $fieldsCount;
43
    
44
    /**
45
     * @var \Plasma\StreamQueryResult|\Plasma\QueryResult|null
46
     */
47
    protected $resolveValue;
48
    
49
    /**
50
     * Constructor.
51
     * @param \Plasma\DriverInterface  $driver
52
     * @param string                   $query
53
     */
54 2
    function __construct(\Plasma\DriverInterface $driver, string $query) {
55 2
        parent::__construct();
56
        
57 2
        $this->driver = $driver;
58 2
        $this->query = $query;
59 2
    }
60
    
61
    /**
62
     * Get the encoded message for writing to the database connection.
63
     * @return string
64
     */
65 2
    function getEncodedMessage(): string {
66 2
        return \chr(static::COMMAND_ID).$this->query;
67
    }
68
    
69
    /**
70
     * Sends the next received value into the command.
71
     * @param mixed  $value
72
     * @return void
73
     */
74 2
    function onNext($value): void {
75 2
        var_dump($value); ob_flush();
0 ignored issues
show
Security Debugging Code introduced by
var_dump($value) looks like debug code. Are you sure you do not want to remove it?
Loading history...
76
        
77 2
        if($value instanceof \Plasma\Drivers\MySQL\ProtocolOnNextCaller) {
78 1
            $this->handleQueryOnNextCaller($value);
79 2
        } elseif($value instanceof \Plasma\Drivers\MySQL\Messages\OkResponseMessage || $value instanceof \Plasma\Drivers\MySQL\Messages\EOFMessage) {
80 2
            if($this->resolveValue !== null) {
81
                $value->getParser()->markCommandAsFinished($this);
82 2
            } elseif($this->fieldsCount == 0 && $value instanceof \Plasma\Drivers\MySQL\Messages\OkResponseMessage) { // Matching 0 and null
1 ignored issue
show
Bug Best Practice introduced by
It seems like you are loosely comparing $this->fieldsCount of type integer|null to 0; this is ambiguous as not only 0 == 0 is true, but null == 0 is true, too. Consider using a strict comparison ===.
Loading history...
83 2
                $this->resolveValue = new \Plasma\QueryResult($value->affectedRows, $value->warningsCount, $value->lastInsertedID);
84 2
                $value->getParser()->markCommandAsFinished($this);
85
            } else {
86
                $this->createResolve();
87
            }
88
        }
89 2
    }
90
    
91
    /**
92
     * Creates the resolve value and resolves the promise.
93
     * @return void
94
     */
95
    function createResolve(): void {
96
        $this->resolveValue = new \Plasma\StreamQueryResult($this->driver, $this, 0, 0, $this->fields, null);
97
        $this->deferred->resolve($this->resolveValue);
98
    }
99
    
100
    /**
101
     * Whether the sequence ID should be resetted.
102
     * @return bool
103
     */
104 2
    function resetSequence(): bool {
105 2
        return true;
106
    }
107
}
108