|
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
|
|
|
namespace midgard\portable\mgdschema; |
|
9
|
|
|
|
|
10
|
|
|
class translator |
|
11
|
|
|
{ |
|
12
|
|
|
const TYPE_NONE = 4; |
|
13
|
|
|
const TYPE_BOOLEAN = 20; |
|
14
|
|
|
const TYPE_INT = 24; |
|
15
|
|
|
const TYPE_UINT = 28; |
|
16
|
|
|
const TYPE_FLOAT = 56; |
|
17
|
|
|
const TYPE_STRING = 64; |
|
18
|
|
|
const TYPE_LONGTEXT = 196; |
|
19
|
|
|
const TYPE_TIMESTAMP = 139645924049440; |
|
20
|
|
|
const TYPE_GUID = 139645923896704; |
|
21
|
|
|
|
|
22
|
|
|
private static $typemap = array( |
|
23
|
|
|
'unsigned integer' => self::TYPE_UINT, |
|
24
|
|
|
'integer' => self::TYPE_INT, |
|
25
|
|
|
'boolean' => self::TYPE_BOOLEAN, |
|
26
|
|
|
'bool' => self::TYPE_BOOLEAN, |
|
27
|
|
|
'guid' => self::TYPE_GUID, |
|
28
|
|
|
//'varchar(80)' => self::TYPE_GUID, // <== true for all cases? |
|
|
|
|
|
|
29
|
|
|
'string' => self::TYPE_STRING, |
|
30
|
|
|
'datetime' => self::TYPE_TIMESTAMP, |
|
31
|
|
|
'text' => self::TYPE_LONGTEXT, |
|
32
|
|
|
'longtext' => self::TYPE_LONGTEXT, |
|
33
|
|
|
'float' => self::TYPE_FLOAT |
|
34
|
|
|
); |
|
35
|
|
|
|
|
36
|
15 |
|
public static function to_constant($typeattribute) |
|
37
|
|
|
{ |
|
38
|
15 |
|
if (!array_key_exists($typeattribute, self::$typemap)) { |
|
39
|
|
|
throw new \Exception('unknown type ' . $typeattribute); |
|
40
|
|
|
} |
|
41
|
15 |
|
return self::$typemap[$typeattribute]; |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.