1 | <?php |
||
21 | class TypeConverter |
||
22 | { |
||
23 | 40 | public static function convertLegacyArrayToObject($array) |
|
34 | |||
35 | 24 | public static function convertObjectToLegacyArray($object) |
|
46 | |||
47 | 26 | public static function convertToLegacyType($value) |
|
48 | { |
||
49 | switch (true) { |
||
50 | 26 | case $value instanceof \MongoDB\BSON\ObjectID: |
|
1 ignored issue
–
show
|
|||
51 | 8 | return new \MongoId($value); |
|
52 | case $value instanceof \MongoDB\BSON\Binary: |
||
1 ignored issue
–
show
|
|||
53 | return new \MongoBinData($value); |
||
54 | case $value instanceof \MongoDB\BSON\Javascript: |
||
1 ignored issue
–
show
|
|||
55 | return new \MongoCode($value); |
||
56 | case $value instanceof \MongoDB\BSON\MaxKey: |
||
1 ignored issue
–
show
|
|||
57 | return new \MongoMaxKey(); |
||
58 | case $value instanceof \MongoDB\BSON\MinKey: |
||
1 ignored issue
–
show
|
|||
59 | return new \MongoMinKey(); |
||
60 | case $value instanceof \MongoDB\BSON\Regex: |
||
1 ignored issue
–
show
|
|||
61 | return new \MongoRegex($value); |
||
62 | case $value instanceof \MongoDB\BSON\Timestamp: |
||
1 ignored issue
–
show
|
|||
63 | return new \MongoTimestamp($value); |
||
64 | 26 | case $value instanceof \MongoDB\BSON\UTCDatetime: |
|
1 ignored issue
–
show
|
|||
65 | return new \MongoDate($value); |
||
66 | default: |
||
67 | 26 | return $value; |
|
68 | } |
||
69 | } |
||
70 | |||
71 | 40 | public static function convertToBSONType($value) |
|
72 | { |
||
73 | switch (true) { |
||
74 | 40 | case $value instanceof TypeInterface: |
|
75 | 9 | return $value->toBSONType(); |
|
76 | |||
77 | default: |
||
78 | 40 | return $value; |
|
79 | } |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * @param array $array |
||
84 | * @return bool |
||
85 | */ |
||
86 | 40 | public static function isNumericArray(array $array) |
|
90 | |||
91 | /** |
||
92 | * Converts all arrays with non-numeric keys to stdClass |
||
93 | * |
||
94 | * @param array $array |
||
95 | * @return array|\stdClass |
||
96 | */ |
||
97 | 40 | private static function ensureCorrectType(array $array) |
|
112 | } |
||
113 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.