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.

ToStringTrait::toString()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
cc 4
nc 3
nop 0
1
<?php
2
3
namespace zaporylie\Vipps\Model;
4
5
use Doctrine\Common\Annotations\AnnotationRegistry;
6
use JMS\Serializer\SerializerInterface;
7
8
trait ToStringTrait
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    public function toString()
14
    {
15
        if (!isset($this->serializer) && ($this instanceof SupportsSerializationInterface)) {
16
            AnnotationRegistry::registerLoader('class_exists');
0 ignored issues
show
Deprecated Code introduced by
The method Doctrine\Common\Annotati...istry::registerLoader() has been deprecated with message: this method is deprecated and will be removed in doctrine/annotations 2.0 autoloading should be deferred to the globally registered autoloader by then. For now, use @example AnnotationRegistry::registerLoader('class_exists')

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
17
            $serializer = static::getSerializer();
18
        } elseif (!isset($this->serializer)) {
19
            throw new \InvalidArgumentException(sprintf('Missing %s', SerializerInterface::class));
20
        } else {
21
            $serializer = $this->serializer;
0 ignored issues
show
Bug introduced by
The property serializer does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
22
        }
23
        return $serializer->serialize(
24
            $this,
25
            'json'
26
        );
27
    }
28
}
29