1 | <?php |
||
2 | /** |
||
3 | * @author CONTENT CONTROL http://www.contentcontrol-berlin.de/ |
||
4 | * @copyright CONTENT CONTROL http://www.contentcontrol-berlin.de/ |
||
5 | * @license http://www.gnu.org/licenses/gpl.html GNU General Public License |
||
6 | */ |
||
7 | |||
8 | use midgard\portable\storage\subscriber; |
||
9 | use midgard\portable\mgdschema\translator; |
||
10 | use midgard\portable\api\error\exception; |
||
0 ignored issues
–
show
|
|||
11 | use midgard\portable\api\config; |
||
12 | use midgard\portable\api\dbobject; |
||
13 | use midgard\portable\api\mgdobject; |
||
14 | use midgard\portable\api\metadata; |
||
15 | use midgard\portable\api\blob; |
||
16 | |||
17 | const MGD_OBJECT_ACTION_NONE = subscriber::ACTION_NONE; |
||
18 | const MGD_OBJECT_ACTION_DELETE = subscriber::ACTION_DELETE; |
||
19 | const MGD_OBJECT_ACTION_PURGE = subscriber::ACTION_PURGE; |
||
20 | const MGD_OBJECT_ACTION_CREATE = subscriber::ACTION_CREATE; |
||
21 | const MGD_OBJECT_ACTION_UPDATE = subscriber::ACTION_UPDATE; |
||
22 | |||
23 | const MGD_TYPE_NONE = translator::TYPE_NONE; |
||
24 | const MGD_TYPE_STRING = translator::TYPE_STRING; |
||
25 | const MGD_TYPE_INT = translator::TYPE_INT; |
||
26 | const MGD_TYPE_UINT = translator::TYPE_UINT; |
||
27 | const MGD_TYPE_FLOAT = translator::TYPE_FLOAT; |
||
28 | const MGD_TYPE_BOOLEAN = translator::TYPE_BOOLEAN; |
||
29 | const MGD_TYPE_TIMESTAMP = translator::TYPE_TIMESTAMP; |
||
30 | const MGD_TYPE_LONGTEXT = translator::TYPE_LONGTEXT; |
||
31 | const MGD_TYPE_GUID = translator::TYPE_GUID; |
||
32 | |||
33 | const MGD_ERR_OK = exception::OK; |
||
34 | const MGD_ERR_ERROR = exception::ERROR; |
||
35 | const MGD_ERR_ACCESS_DENIED = exception::ACCESS_DENIED; |
||
36 | const MGD_ERR_NO_METADATA = exception::NO_METADATA; |
||
37 | const MGD_ERR_NOT_OBJECT = exception::NOT_OBJECT; |
||
38 | const MGD_ERR_NOT_EXISTS = exception::NOT_EXISTS; |
||
39 | const MGD_ERR_INVALID_NAME = exception::INVALID_NAME; |
||
40 | const MGD_ERR_DUPLICATE = exception::DUPLICATE; |
||
41 | const MGD_ERR_HAS_DEPENDANTS = exception::HAS_DEPENDANTS; |
||
42 | const MGD_ERR_RANGE = exception::RANGE; |
||
43 | const MGD_ERR_NOT_CONNECTED = exception::NOT_CONNECTED; |
||
44 | const MGD_ERR_SG_NOTFOUND = exception::SG_NOTFOUND; |
||
45 | const MGD_ERR_INVALID_OBJECT = exception::INVALID_OBJECT; |
||
46 | const MGD_ERR_QUOTA = exception::QUOTA; |
||
47 | const MGD_ERR_INTERNAL = exception::INTERNAL; |
||
48 | const MGD_ERR_OBJECT_NAME_EXISTS = exception::OBJECT_NAME_EXISTS; |
||
49 | const MGD_ERR_OBJECT_NO_STORAGE = exception::OBJECT_NO_STORAGE; |
||
50 | const MGD_ERR_OBJECT_NO_PARENT = exception::OBJECT_NO_PARENT; |
||
51 | const MGD_ERR_INVALID_PROPERTY_VALUE = exception::INVALID_PROPERTY_VALUE; |
||
52 | const MGD_ERR_INVALID_PROPERTY = exception::INVALID_PROPERTY; |
||
53 | const MGD_ERR_USER_DATA = exception::USER_DATA; |
||
54 | const MGD_ERR_OBJECT_DELETED = exception::OBJECT_DELETED; |
||
55 | const MGD_ERR_OBJECT_PURGED = exception::OBJECT_PURGED; |
||
56 | const MGD_ERR_OBJECT_EXPORTED = exception::OBJECT_EXPORTED; |
||
57 | const MGD_ERR_OBJECT_IMPORTED = exception::OBJECT_IMPORTED; |
||
58 | const MGD_ERR_MISSED_DEPENDENCE = exception::MISSED_DEPENDENCE; |
||
59 | const MGD_ERR_TREE_IS_CIRCULAR = exception::TREE_IS_CIRCULAR; |
||
60 | const MGD_ERR_OBJECT_IS_LOCKED = exception::OBJECT_IS_LOCKED; |
||
61 | |||
62 | // TODO: this should be moved into an autoloader function at some point |
||
63 | class_alias(exception::class, 'midgard_error_exception'); |
||
64 | class_alias(config::class, 'midgard_config'); |
||
65 | class_alias(dbobject::class, 'midgard_dbobject'); |
||
66 | class_alias(mgdobject::class, 'midgard_object'); |
||
67 | class_alias(metadata::class, 'midgard_metadata'); |
||
68 | class_alias(blob::class, 'midgard_blob'); |
||
69 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: