Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
55.56% covered (warning)
55.56%
15 / 27
CRAP
92.56% covered (success)
92.56%
286 / 309
ReflectionExtractor
0.00% covered (danger)
0.00%
0 / 1
55.56% covered (warning)
55.56%
15 / 27
173.96
92.56% covered (success)
92.56%
286 / 309
 __construct
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
10 / 10
 getProperties
0.00% covered (danger)
0.00%
0 / 1
12.20
88.89% covered (warning)
88.89%
16 / 18
 getTypes
100.00% covered (success)
100.00%
1 / 1
9
100.00% covered (success)
100.00%
16 / 16
 isReadable
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
3 / 3
 isWritable
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
4 / 4
 isInitializable
0.00% covered (danger)
0.00%
0 / 1
8.81
66.67% covered (warning)
66.67%
8 / 12
 getReadInfo
0.00% covered (danger)
0.00%
0 / 1
15.13
91.67% covered (success)
91.67%
22 / 24
 getWriteInfo
0.00% covered (danger)
0.00%
0 / 1
22
95.08% covered (success)
95.08%
58 / 61
 extractFromMutator
100.00% covered (success)
100.00%
1 / 1
5
100.00% covered (success)
100.00%
11 / 11
 extractFromAccessor
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
8 / 8
 extractFromConstructor
0.00% covered (danger)
0.00%
0 / 1
7.14
85.71% covered (warning)
85.71%
12 / 14
 extractFromDefaultValue
0.00% covered (danger)
0.00%
0 / 1
3.14
75.00% covered (warning)
75.00%
6 / 8
 extractFromReflectionType
0.00% covered (danger)
0.00%
0 / 1
8.02
92.86% covered (success)
92.86%
13 / 14
 resolveTypeName
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
5 / 5
 isAllowedProperty
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
4 / 4
 getAccessorMethod
0.00% covered (danger)
0.00%
0 / 1
5.03
88.89% covered (warning)
88.89%
8 / 9
 getMutatorMethod
0.00% covered (danger)
0.00%
0 / 1
8.02
93.33% covered (success)
93.33%
14 / 15
 getPropertyName
100.00% covered (success)
100.00%
1 / 1
7
100.00% covered (success)
100.00%
10 / 10
 findAdderAndRemover
0.00% covered (danger)
0.00%
0 / 1
10.02
94.12% covered (success)
94.12%
16 / 17
 isMethodAccessible
100.00% covered (success)
100.00%
1 / 1
6
100.00% covered (success)
100.00%
9 / 9
 camelize
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getMethodsFlags
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
8 / 8
 getPropertyFlags
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
8 / 8
 getReadVisiblityForProperty
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
5 / 5
 getReadVisiblityForMethod
0.00% covered (danger)
0.00%
0 / 1
3.58
60.00% covered (warning)
60.00%
3 / 5
 getWriteVisiblityForProperty
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
5 / 5
 getWriteVisiblityForMethod
0.00% covered (danger)
0.00%
0 / 1
3.58
60.00% covered (warning)
60.00%
3 / 5
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\PropertyInfo\Extractor;
13
14use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
15use Symfony\Component\PropertyInfo\PropertyInitializableExtractorInterface;
16use Symfony\Component\PropertyInfo\PropertyListExtractorInterface;
17use Symfony\Component\PropertyInfo\PropertyReadInfo;
18use Symfony\Component\PropertyInfo\PropertyReadInfoExtractorInterface;
19use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
20use Symfony\Component\PropertyInfo\PropertyWriteInfo;
21use Symfony\Component\PropertyInfo\PropertyWriteInfoExtractorInterface;
22use Symfony\Component\PropertyInfo\Type;
23use Symfony\Component\String\Inflector\EnglishInflector;
24use Symfony\Component\String\Inflector\InflectorInterface;
25
26/**
27 * Extracts data using the reflection API.
28 *
29 * @author K√©vin Dunglas <dunglas@gmail.com>
30 *
31 * @final
32 */
33class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTypeExtractorInterface, PropertyAccessExtractorInterface, PropertyInitializableExtractorInterface, PropertyReadInfoExtractorInterface, PropertyWriteInfoExtractorInterface
34{
35    /**
36     * @internal
37     */
38    public static $defaultMutatorPrefixes = ['add', 'remove', 'set'];
39
40    /**
41     * @internal
42     */
43    public static $defaultAccessorPrefixes = ['get', 'is', 'has', 'can'];
44
45    /**
46     * @internal
47     */
48    public static $defaultArrayMutatorPrefixes = ['add', 'remove'];
49
50    public const ALLOW_PRIVATE = 1;
51    public const ALLOW_PROTECTED = 2;
52    public const ALLOW_PUBLIC = 4;
53
54    private const MAP_TYPES = [
55        'integer' => Type::BUILTIN_TYPE_INT,
56        'boolean' => Type::BUILTIN_TYPE_BOOL,
57        'double' => Type::BUILTIN_TYPE_FLOAT,
58    ];
59
60    private $mutatorPrefixes;
61    private $accessorPrefixes;
62    private $arrayMutatorPrefixes;
63    private $enableConstructorExtraction;
64    private $methodReflectionFlags;
65    private $propertyReflectionFlags;
66    private $inflector;
67
68    private $arrayMutatorPrefixesFirst;
69    private $arrayMutatorPrefixesLast;
70
71    /**
72     * @param string[]|null $mutatorPrefixes
73     * @param string[]|null $accessorPrefixes
74     * @param string[]|null $arrayMutatorPrefixes
75     */
76    public function __construct(array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null, bool $enableConstructorExtraction = true, int $accessFlags = self::ALLOW_PUBLIC, InflectorInterface $inflector = null)
77    {
78        $this->mutatorPrefixes = null !== $mutatorPrefixes ? $mutatorPrefixes : self::$defaultMutatorPrefixes;