1 | <?php |
||
7 | class ImportCoordinates { |
||
8 | |||
9 | const IMPORTERS_GLOBAL_KEY = 'msls_importers'; |
||
10 | |||
11 | /** |
||
12 | * @var int |
||
13 | */ |
||
14 | public $source_blog_id; |
||
15 | /** |
||
16 | * @var int |
||
17 | */ |
||
18 | public $source_post_id; |
||
19 | /** |
||
20 | * @var int |
||
21 | */ |
||
22 | public $dest_blog_id; |
||
23 | /** |
||
24 | * @var int |
||
25 | */ |
||
26 | public $dest_post_id; |
||
27 | |||
28 | /** |
||
29 | * @var \WP_Post |
||
30 | */ |
||
31 | public $source_post; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | public $source_lang; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | public $dest_lang; |
||
42 | |||
43 | /** |
||
44 | * @var array An array keeping track of which importer (slug) should be used for |
||
45 | * a specific import type, shape [ <import-type> => <slug> ] |
||
46 | */ |
||
47 | public $importers = []; |
||
48 | |||
49 | /** |
||
50 | * Validates the coordinates. |
||
51 | * |
||
52 | * @return bool |
||
53 | */ |
||
54 | public function validate() { |
||
74 | |||
75 | /** |
||
76 | * Returns the importer (slug) for a specific type of imports. |
||
77 | * |
||
78 | * @param string $importer_type |
||
79 | * |
||
80 | * @return string|null The import slug if set or `null` if not set. |
||
81 | */ |
||
82 | public function get_importer_for( $importer_type ) { |
||
87 | |||
88 | /** |
||
89 | * Parses the importers from request superglobals. |
||
90 | */ |
||
91 | public function parse_importers_from_request() { |
||
92 | // bitmask |
||
93 | $source = isset( $_REQUEST[ self::IMPORTERS_GLOBAL_KEY ] ) * 100 |
||
94 | + isset( $_POST[ self::IMPORTERS_GLOBAL_KEY ] ) * 10 |
||
95 | + isset( $_GET[ self::IMPORTERS_GLOBAL_KEY ] ); |
||
96 | |||
97 | switch ( $source ) { |
||
98 | case 100: |
||
99 | case 101; |
||
100 | case 111: |
||
101 | case 110: |
||
102 | $source = $_REQUEST; |
||
103 | break; |
||
104 | case 010: |
||
105 | case 011: |
||
106 | case 000: |
||
107 | default: |
||
108 | $source = $_POST; |
||
109 | break; |
||
110 | case 001: |
||
111 | $source = $_GET; |
||
112 | break; |
||
113 | } |
||
114 | |||
115 | $importers = isset( $source[ self::IMPORTERS_GLOBAL_KEY ] ) && is_array( $source[ self::IMPORTERS_GLOBAL_KEY ] ) |
||
116 | ? $source[ self::IMPORTERS_GLOBAL_KEY ] |
||
117 | : []; |
||
118 | |||
119 | foreach ( $importers as $importer_type => $slug ) { |
||
120 | $this->set_importer_for( $importer_type, $slug ); |
||
121 | } |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * Sets the slug of the importer that should be used for a type of import. |
||
126 | * |
||
127 | * @param string $importer_type |
||
128 | * @param string $slug |
||
129 | */ |
||
130 | public function set_importer_for( $importer_type, $slug ) { |
||
133 | } |
||
134 |
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.