Bonjour
J'ai un gros soucis avec ArrayObject. j'ai developpé un outil qui analyse un texte et qui en fait des tableaux de tableaux etc...
j'ai voulu remplacé un constructeur array() par new ArrayObject() en me dissant que ça devrait tout être compatible... que nenni
j'ai une trace qui ressemble à ça:
il faut voir que l'arrayobject a des valeurs internes qui sont toutes les mêmes...
et des bouts de codes
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191 Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:127 ( OB:0 ) ArrayObject Object ( [storage:ArrayObject:private] => Array ( ) ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:127 ( OB:0 ) ArrayObject Object ( [storage:ArrayObject:private] => Array ( ) ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:130 ( OB:0 ) Array ( [0] => item [1] => plaspistol_ammo ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:134 ( OB:0 ) ArrayObject Object ( [storage:ArrayObject:private] => Array ( [0] => Array ( ) ) ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:127 ( OB:0 ) ArrayObject Object ( [storage:ArrayObject:private] => Array ( ) ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:127 ( OB:0 ) ArrayObject Object ( [storage:ArrayObject:private] => Array ( ) ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:130 ( OB:0 ) Array ( [0] => name [1] => _Plasma Pistol Charger ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:134 ( OB:0 ) ArrayObject Object ( [storage:ArrayObject:private] => Array ( [0] => Array ( ) ) ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:127 ( OB:0 ) ArrayObject Object ( [storage:ArrayObject:private] => Array ( [0] => Array ( [0] => model [1] => weapons/plaspistol/plaspistol_clip ) ) ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:130 ( OB:0 ) Array ( [0] => model [1] => weapons/plaspistol/plaspistol_clip ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:134 ( OB:0 ) ArrayObject Object ( [storage:ArrayObject:private] => Array ( [0] => Array ( ) [1] => Array ( ) ) ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:127 ( OB:0 ) ArrayObject Object ( [storage:ArrayObject:private] => Array ( [0] => Array ( [0] => type [1] => ammo ) [1] => Array ( [0] => type [1] => ammo ) ) ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:130 ( OB:0 ) Array ( [0] => type [1] => ammo ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:134 ( OB:0 ) ArrayObject Object ( [storage:ArrayObject:private] => Array ( [0] => Array ( ) [1] => Array ( ) [2] => Array ( ) ) ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:127 ( OB:0 ) ArrayObject Object ( [storage:ArrayObject:private] => Array ( [0] => Array ( [0] => animationindex [1] => 0 ) [1] => Array ( [0] => animationindex [1] => 0 ) [2] => Array ( [0] => animationindex [1] => 0 ) ) )
voilou si je remplace le arrayObject par un array() ça marche bien j'ai la trace suivante:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147 <?php Class UfoParser { protected $filename; protected $tokens; function __construct($filename) { if ( file_exists($filename) ) { $this->filename = $filename; $this->tokens= token_get_all( "<?php ".file_get_contents($filename)); // Debug::here(); } else { Debug::var_dump($filename); throw new MyException("file error"); } } /***/ function analyze() { /** * don't use class var here... need them recursivelys **/ // $symbol = array();// $symbol = new ArrayObject(); $context =array(); $index = 0; // $p = new Prompt(); $separator_before = true; // $previous_was_whitespaces while( $token = next($this->tokens) ) { if ( is_array( $token ) ) { if ( $token[0] == T_COMMENT ) { $separator_before = true; // if we have a end-of-line comment (//), we have to "end" the line. // i think we just have to test this: $token[1][1] === '/' if( /* more easy to read, no equivalent... */ strpos($token[1],"\n") !== false ) { self::meetTerminal($symbol, $context, $index ); } } else if ( strpos($token[1],"\n") !== false ) { self::meetTerminal($symbol, $context, $index ); $separator_before = true; } else if ( $token[0] === T_WHITESPACE ) { $separator_before = true; } else { self::stackOrConcat($context,self::unquoteString($token[1]),$separator_before ); $separator_before = false; } } else //token is a string (not an array in fact) { if ( $token === '{' ) { $separator_before = true; if ( 0 == count($context) ) // case where there is an line end "before" the { { $symbol[$index-1][]= $this->analyze(); Debug::print_r($symbol); } else // there is { $context[] = $this->analyze(); Debug::print_r($context); self::meetTerminal($symbol,$context, $index); } } else if ( $token === '}' ) { $separator_before = true; //fin de la bataille préparer tout pour retour. self::meetTerminal($symbol,$context, $index); return $symbol; } else if ( is_string($token) ) { self::stackOrConcat($context,$token, $separator_before ); $separator_before = false; } else { throw exception('This exception should N E V E R run'); } } }//while self::meetTerminal($symbol,$context, $index); return $symbol; }//fct static protected function stackOrConcat( &$context, $token, $separator_before ) { if ( $separator_before ) { $context[]= $token;// push, don't concat. } else { $tmp = array_pop($context); $tmp.=$token; $context[]= $tmp; } } static protected function meetTerminal(&$symbol, &$context, &$index ) { Debug::print_r($symbol); if ( count($context) ) { Debug::print_r($context); $symbol[$index] = $context; $index++; $context = array(); Debug::print_r($symbol); return true; } return false; } static protected function unquoteString($str) { if ( '"' === $str[0] ) { return substr($str, 1, -1); } else { return $str; } } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138 Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:127 ( OB:0 ) Array ( ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:127 ( OB:0 ) Array ( ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:130 ( OB:0 ) Array ( [0] => item [1] => plaspistol_ammo ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:134 ( OB:0 ) Array ( [0] => Array ( [0] => item [1] => plaspistol_ammo ) ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:127 ( OB:0 ) Array ( ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:127 ( OB:0 ) Array ( ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:130 ( OB:0 ) Array ( [0] => name [1] => _Plasma Pistol Charger ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:134 ( OB:0 ) Array ( [0] => Array ( [0] => name [1] => _Plasma Pistol Charger ) ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:127 ( OB:0 ) Array ( [0] => Array ( [0] => name [1] => _Plasma Pistol Charger ) ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:130 ( OB:0 ) Array ( [0] => model [1] => weapons/plaspistol/plaspistol_clip ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:134 ( OB:0 ) Array ( [0] => Array ( [0] => name [1] => _Plasma Pistol Charger ) [1] => Array ( [0] => model [1] => weapons/plaspistol/plaspistol_clip ) ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:127 ( OB:0 ) Array ( [0] => Array ( [0] => name [1] => _Plasma Pistol Charger ) [1] => Array ( [0] => model [1] => weapons/plaspistol/plaspistol_clip ) ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:130 ( OB:0 ) Array ( [0] => type [1] => ammo ) Debug::print_r appelé en /var/www/jerikojerk.free.fr/ufo-ai/include/UfoParser.class.php:134 ( OB:0 ) Array ( [0] => Array ( [0] => name [1] => _Plasma Pistol Charger ) [1] => Array ( [0] => model [1] => weapons/plaspistol/plaspistol_clip ) [2] => Array ( [0] => type [1] => ammo ) )
Partager