1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the xAPI package. |
5
|
|
|
* |
6
|
|
|
* (c) Christian Flothmann <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Xabbuh\XApi\Serializer\Symfony; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Serializer\Encoder\JsonEncoder; |
15
|
|
|
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer; |
16
|
|
|
use Symfony\Component\Serializer\Normalizer\PropertyNormalizer; |
17
|
|
|
use Symfony\Component\Serializer\SerializerInterface; |
18
|
|
|
use Symfony\Component\Serializer\Serializer as SymfonySerializer; |
19
|
|
|
use Xabbuh\XApi\Serializer\Symfony\Normalizer\AccountNormalizer; |
20
|
|
|
use Xabbuh\XApi\Serializer\Symfony\Normalizer\ActorNormalizer; |
21
|
|
|
use Xabbuh\XApi\Serializer\Symfony\Normalizer\AttachmentNormalizer; |
22
|
|
|
use Xabbuh\XApi\Serializer\Symfony\Normalizer\ContextActivitiesNormalizer; |
23
|
|
|
use Xabbuh\XApi\Serializer\Symfony\Normalizer\ContextNormalizer; |
24
|
|
|
use Xabbuh\XApi\Serializer\Symfony\Normalizer\DefinitionNormalizer; |
25
|
|
|
use Xabbuh\XApi\Serializer\Symfony\Normalizer\DocumentDataNormalizer; |
26
|
|
|
use Xabbuh\XApi\Serializer\Symfony\Normalizer\ExtensionsNormalizer; |
27
|
|
|
use Xabbuh\XApi\Serializer\Symfony\Normalizer\FilterNullValueNormalizer; |
28
|
|
|
use Xabbuh\XApi\Serializer\Symfony\Normalizer\InteractionComponentNormalizer; |
29
|
|
|
use Xabbuh\XApi\Serializer\Symfony\Normalizer\LanguageMapNormalizer; |
30
|
|
|
use Xabbuh\XApi\Serializer\Symfony\Normalizer\ObjectNormalizer; |
31
|
|
|
use Xabbuh\XApi\Serializer\Symfony\Normalizer\ResultNormalizer; |
32
|
|
|
use Xabbuh\XApi\Serializer\Symfony\Normalizer\StatementNormalizer; |
33
|
|
|
use Xabbuh\XApi\Serializer\Symfony\Normalizer\StatementResultNormalizer; |
34
|
|
|
use Xabbuh\XApi\Serializer\Symfony\Normalizer\TimestampNormalizer; |
35
|
|
|
use Xabbuh\XApi\Serializer\Symfony\Normalizer\VerbNormalizer; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Entry point to set up the {@link \Symfony\Component\Serializer\Serializer Symfony Serializer component} |
39
|
|
|
* for the Experience API. |
40
|
|
|
* |
41
|
|
|
* @author Christian Flothmann <[email protected]> |
42
|
|
|
*/ |
43
|
|
|
class Serializer |
44
|
|
|
{ |
45
|
|
|
/** |
46
|
|
|
* Creates a new Serializer. |
47
|
|
|
* |
48
|
|
|
* @return SerializerInterface The Serializer |
49
|
|
|
*/ |
50
|
|
|
public static function createSerializer() |
51
|
|
|
{ |
52
|
|
|
$normalizers = array( |
53
|
|
|
new AccountNormalizer(), |
54
|
|
|
new ActorNormalizer(), |
55
|
|
|
new AttachmentNormalizer(), |
56
|
|
|
new ContextNormalizer(), |
57
|
|
|
new ContextActivitiesNormalizer(), |
58
|
|
|
new DefinitionNormalizer(), |
59
|
|
|
new DocumentDataNormalizer(), |
60
|
|
|
new ExtensionsNormalizer(), |
61
|
|
|
new InteractionComponentNormalizer(), |
62
|
|
|
new LanguageMapNormalizer(), |
63
|
|
|
new ObjectNormalizer(), |
64
|
|
|
new ResultNormalizer(), |
65
|
|
|
new StatementNormalizer(), |
66
|
|
|
new StatementResultNormalizer(), |
67
|
|
|
new TimestampNormalizer(), |
68
|
|
|
new VerbNormalizer(), |
69
|
|
|
new ArrayDenormalizer(), |
70
|
|
|
new FilterNullValueNormalizer(new PropertyNormalizer()), |
|
|
|
|
71
|
|
|
new PropertyNormalizer(), |
72
|
|
|
); |
73
|
|
|
$encoders = array( |
74
|
|
|
new JsonEncoder(), |
75
|
|
|
); |
76
|
|
|
|
77
|
|
|
return new SymfonySerializer($normalizers, $encoders); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.