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.

DocumentLiteralWrapped::bindingStyle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Copyright (C) 2013-2015
4
 * Piotr Olaszewski <[email protected]>
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7
 * of this software and associated documentation files (the "Software"), to deal
8
 * in the Software without restriction, including without limitation the rights
9
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
 * copies of the Software, and to permit persons to whom the Software is
11
 * furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
 * SOFTWARE.
23
 */
24
namespace WSDL\XML\Styles;
25
26
use WSDL\Parser\MethodParser;
27
use WSDL\Types\Type;
28
use WSDL\Utilities\TypeHelper;
29
30
/**
31
 * DocumentLiteralWrapped
32
 *
33
 * @author Piotr Olaszewski <[email protected]>
34
 */
35
class DocumentLiteralWrapped extends Style
36
{
37 1
    public function bindingStyle()
38
    {
39 1
        return 'document';
40
    }
41
42 1
    public function bindingUse()
43
    {
44 1
        return 'literal';
45
    }
46
47
    public function methodInput(MethodParser $method)
48
    {
49
        return array($this->_createPart($method));
50
    }
51
52
    public function methodOutput(MethodParser $method)
53
    {
54
        return $this->_createPart($method, 'Response');
55
    }
56
57
    private function _createPart(MethodParser $method, $type = '')
58
    {
59
        $name = 'parameters';
60
        $elementName = 'ns:' . $method->getName() . $type;
61
        $element = array(
62
            'name' => $name,
63
            'element' => $elementName
64
        );
65
        return $element;
66
    }
67
68 7
    public function typeParameters(MethodParser $method)
69 1
    {
70 7
        $element = new TypesElement();
71 7
        $element->setName($method->getName());
72 7
        foreach ($method->parameters() as $parameter) {
73 7
            $this->_generateElements($parameter, $element);
0 ignored issues
show
Documentation introduced by
$parameter is of type object<WSDL\Parser\ParameterParser>, but the function expects a object<WSDL\Types\Type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
74 7
        }
75 7
        return array($element);
76
    }
77
78 6
    public function typeReturning(MethodParser $method)
79
    {
80 6
        $element = new TypesElement();
81 6
        $element->setName($method->getName() . 'Response');
82 6
        foreach($method->returning() as $parameter) {
0 ignored issues
show
Bug introduced by
The expression $method->returning() of type array<integer,object<WSD...ject<WSDL\Types\Simple> is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
83 6
            $this->_generateElements($parameter, $element);
84 6
        }
85 6
        return $element;
86
    }
87
88 13
    private function _generateElements(Type $parameter, TypesElement $element)
89
    {
90 13
        list($type, $value) = $this->_prepareTypeAndValue($parameter);
91 13
        $element->setElementAttributes($type, $value, $parameter->getName());
92 13
        if (!TypeHelper::isSimple($parameter)) {
93 13
            $complexType = $this->_generateComplexType($parameter);
94 13
            $element->setComplex($complexType);
95 13
        }
96 13
    }
97
}
98