Arbit - project tracking

PHP Depend

Browse source code

File: / PHP/ Depend/ Builder/ Default.php

Type
text/plain text/plain
Last Author
mapi
Version
1317
Line Rev. Author Source
1 1 mapi <?php
2 7 mapi /**
3 mapi * This file is part of PHP_Depend.
4 537 mapi *
5 7 mapi * PHP Version 5
6 mapi *
7 1030 mapi * Copyright (c) 2008-2010, Manuel Pichler <mapi@pdepend.org>.
8 7 mapi * All rights reserved.
9 mapi *
10 mapi * Redistribution and use in source and binary forms, with or without
11 mapi * modification, are permitted provided that the following conditions
12 mapi * are met:
13 mapi *
14 mapi * * Redistributions of source code must retain the above copyright
15 mapi * notice, this list of conditions and the following disclaimer.
16 mapi *
17 mapi * * Redistributions in binary form must reproduce the above copyright
18 mapi * notice, this list of conditions and the following disclaimer in
19 mapi * the documentation and/or other materials provided with the
20 mapi * distribution.
21 mapi *
22 mapi * * Neither the name of Manuel Pichler nor the names of his
23 mapi * contributors may be used to endorse or promote products derived
24 mapi * from this software without specific prior written permission.
25 mapi *
26 mapi * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 mapi * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 mapi * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
29 mapi * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
30 mapi * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
31 mapi * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
32 mapi * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33 mapi * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34 mapi * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 mapi * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
36 mapi * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 mapi * POSSIBILITY OF SUCH DAMAGE.
38 mapi *
39 171 mapi * @category QualityAssurance
40 mapi * @package PHP_Depend
41 584 mapi * @subpackage Builder
42 268 mapi * @author Manuel Pichler <mapi@pdepend.org>
43 1030 mapi * @copyright 2008-2010 Manuel Pichler. All rights reserved.
44 171 mapi * @license http://www.opensource.org/licenses/bsd-license.php BSD License
45 1115 mapi * @version SVN: $Id: Default.php 1317 2010-06-17 11:38:24Z mapi $
46 824 mapi * @link http://pdepend.org/
47 7 mapi */
48 mapi
49 654 mapi require_once 'PHP/Depend/BuilderI.php';
50 1 mapi require_once 'PHP/Depend/Code/Class.php';
51 119 mapi require_once 'PHP/Depend/Code/Interface.php';
52 38 mapi require_once 'PHP/Depend/Code/NodeIterator.php';
53 1 mapi require_once 'PHP/Depend/Code/Function.php';
54 mapi require_once 'PHP/Depend/Code/Method.php';
55 mapi require_once 'PHP/Depend/Code/Package.php';
56 341 mapi require_once 'PHP/Depend/Code/Parameter.php';
57 148 mapi require_once 'PHP/Depend/Code/Property.php';
58 656 mapi require_once 'PHP/Depend/Util/Log.php';
59 654 mapi require_once 'PHP/Depend/Util/Type.php';
60 1 mapi
61 12 mapi /**
62 mapi * Default code tree builder implementation.
63 mapi *
64 171 mapi * @category QualityAssurance
65 mapi * @package PHP_Depend
66 584 mapi * @subpackage Builder
67 268 mapi * @author Manuel Pichler <mapi@pdepend.org>
68 1030 mapi * @copyright 2008-2010 Manuel Pichler. All rights reserved.
69 171 mapi * @license http://www.opensource.org/licenses/bsd-license.php BSD License
70 mapi * @version Release: @package_version@
71 824 mapi * @link http://pdepend.org/
72 12 mapi */
73 559 mapi class PHP_Depend_Builder_Default implements PHP_Depend_BuilderI pdepend-warning pdepend-error pdepend-error pdepend-error pdepend-warning pdepend-error pdepend-error pdepend-error pdepend-error pdepend-warning
74 1 mapi {
75 12 mapi /**
76 1177 mapi * This property holds all packages found during the parsing phase.
77 mapi *
78 mapi * @param array(PHP_Depend_Code_Package)
79 mapi * @since 0.9.12
80 mapi */
81 mapi private $_preparedPackages = null;
82 mapi
83 mapi /**
84 537 mapi * Default package which contains all functions and classes with an unknown
85 mapi * scope.
86 12 mapi *
87 mapi * @var PHP_Depend_Code_Package $defaultPackage
88 mapi */
89 1 mapi protected $defaultPackage = null;
90 537 mapi
91 12 mapi /**
92 210 mapi * Default source file that acts as a dummy.
93 mapi *
94 mapi * @var PHP_Depend_Code_File $defaultFile
95 mapi */
96 mapi protected $defaultFile = null;
97 537 mapi
98 210 mapi /**
99 12 mapi * All generated {@link PHP_Depend_Code_Class} objects
100 mapi *
101 860 mapi * @var array(string=>PHP_Depend_Code_Class) $_classes
102 12 mapi */
103 860 mapi private $_classes = array();
104 537 mapi
105 12 mapi /**
106 119 mapi * All generated {@link PHP_Depend_Code_Interface} instances.
107 mapi *
108 860 mapi * @var array(string=>PHP_Depend_Code_Interface) $_interfaces
109 119 mapi */
110 860 mapi private $_interfaces = array();
111 537 mapi
112 119 mapi /**
113 12 mapi * All generated {@link PHP_Depend_Code_Package} objects
114 mapi *
115 857 mapi * @var array(string=>PHP_Depend_Code_Package) $_packages
116 12 mapi */
117 857 mapi private $_packages = array();
118 537 mapi
119 12 mapi /**
120 857 mapi * Internal status flag used to check that a build request is internal.
121 119 mapi *
122 857 mapi * @var boolean $_internal
123 119 mapi */
124 857 mapi private $_internal = false;
125 537 mapi
126 119 mapi /**
127 857 mapi * Internal used flag that marks the parsing process as frozen.
128 119 mapi *
129 857 mapi * @var boolean $_frozen
130 119 mapi */
131 857 mapi private $_frozen = false;
132 537 mapi
133 119 mapi /**
134 857 mapi * Cache of all classes created during the regular parsing process.
135 341 mapi *
136 857 mapi * @var array(PHP_Depend_Code_Class) $_frozenClasses
137 341 mapi */
138 857 mapi private $_frozenClasses = array();
139 537 mapi
140 341 mapi /**
141 857 mapi * Cache of all interfaces created during the regular parsing process.
142 319 mapi *
143 857 mapi * @var array(PHP_Depend_Code_Interface) $_frozenInterfaces
144 319 mapi */
145 857 mapi private $_frozenInterfaces = array();
146 537 mapi
147 319 mapi /**
148 12 mapi * Constructs a new builder instance.
149 mapi */
150 1 mapi public function __construct()
151 mapi {
152 mapi $this->defaultPackage = new PHP_Depend_Code_Package(self::DEFAULT_PACKAGE);
153 210 mapi $this->defaultFile = new PHP_Depend_Code_File(null);
154 537 mapi
155 857 mapi $this->_packages[self::DEFAULT_PACKAGE] = $this->defaultPackage;
156 1 mapi }
157 537 mapi
158 10 mapi /**
159 857 mapi * Builds a new code type reference instance.
160 537 mapi *
161 857 mapi * @param string $qualifiedName The qualified name of the referenced type.
162 537 mapi *
163 930 mapi * @return PHP_Depend_Code_ASTClassOrInterfaceReference
164 857 mapi * @since 0.9.5
165 119 mapi */
166 930 mapi public function buildASTClassOrInterfaceReference($qualifiedName)
167 119 mapi {
168 859 mapi $this->checkBuilderState();
169 mapi
170 930 mapi include_once 'PHP/Depend/Code/ASTClassOrInterfaceReference.php';
171 537 mapi
172 929 mapi // Debug method creation
173 mapi PHP_Depend_Util_Log::debug(
174 930 mapi 'Creating: PHP_Depend_Code_ASTClassOrInterfaceReference(' .
175 929 mapi $qualifiedName .
176 mapi ')'
177 mapi );
178 mapi
179 930 mapi return new PHP_Depend_Code_ASTClassOrInterfaceReference(
180 mapi $this,
181 mapi $qualifiedName
182 mapi );
183 119 mapi }
184 537 mapi
185 857 mapi /**
186 mapi * This method will try to find an already existing instance for the given
187 mapi * qualified name. It will create a new {@link PHP_Depend_Code_Class}
188 mapi * instance when no matching type exists.
189 mapi *
190 mapi * @param string $qualifiedName The full qualified type identifier.
191 mapi *
192 mapi * @return PHP_Depend_Code_AbstractClassOrInterface
193 mapi * @since 0.9.5
194 mapi */
195 855 mapi public function getClassOrInterface($qualifiedName)
196 mapi {
197 mapi $classOrInterface = $this->findClass($qualifiedName);
198 mapi if ($classOrInterface !== null) {
199 mapi return $classOrInterface;
200 mapi }
201 mapi
202 mapi $classOrInterface = $this->findInterface($qualifiedName);
203 mapi if ($classOrInterface !== null) {
204 mapi return $classOrInterface;
205 mapi }
206 857 mapi return $this->buildClassInternal($qualifiedName);
207 855 mapi }
208 mapi
209 119 mapi /**
210 192 mapi * Builds a new class instance or reuses a previous created class.
211 537 mapi *
212 192 mapi * Where possible you should give a qualified class name, that is prefixed
213 mapi * with the package identifier.
214 537 mapi *
215 192 mapi * <code>
216 mapi * $builder->buildClass('php::depend::Parser');
217 mapi * </code>
218 537 mapi *
219 192 mapi * To determine the correct class, this method implements the following
220 mapi * algorithm.
221 537 mapi *
222 192 mapi * <ol>
223 mapi * <li>Check for an exactly matching instance and reuse it.</li>
224 mapi * <li>Check for a class instance that belongs to the default package. If
225 mapi * such an instance exists, reuse it and replace the default package with
226 mapi * the newly given package information.</li>
227 537 mapi * <li>Check that the requested class is in the default package, if this
228 192 mapi * is true, reuse the first class instance and ignore the default package.
229 mapi * </li>
230 mapi * <li>Create a new instance for the specified package.</li>
231 mapi * </ol>
232 10 mapi *
233 675 mapi * @param string $name The class name.
234 537 mapi *
235 10 mapi * @return PHP_Depend_Code_Class The created class object.
236 mapi */
237 675 mapi public function buildClass($name)
238 1 mapi {
239 857 mapi $this->checkBuilderState();
240 mapi
241 855 mapi $className = $this->extractTypeName($name);
242 mapi $packageName = $this->extractPackageName($name);
243 mapi
244 mapi $class = new PHP_Depend_Code_Class($className);
245 mapi $class->setSourceFile($this->defaultFile);
246 mapi
247 860 mapi $this->storeClass($className, $packageName, $class);
248 855 mapi
249 mapi return $class;
250 mapi }
251 mapi
252 857 mapi /**
253 mapi * This method will try to find an already existing instance for the given
254 mapi * qualified name. It will create a new {@link PHP_Depend_Code_Class}
255 mapi * instance when no matching type exists.
256 mapi *
257 mapi * @param string $qualifiedName The full qualified type identifier.
258 mapi *
259 mapi * @return PHP_Depend_Code_Class
260 mapi * @since 0.9.5
261 mapi */
262 855 mapi public function getClass($qualifiedName)
263 mapi {
264 mapi $class = $this->findClass($qualifiedName);
265 mapi if ($class === null) {
266 857 mapi $class = $this->buildClassInternal($qualifiedName);
267 855 mapi }
268 mapi return $class;
269 mapi }
270 537 mapi
271 1 mapi /**
272 828 mapi * Builds a new code type reference instance.
273 mapi *
274 mapi * @param string $qualifiedName The qualified name of the referenced type.
275 mapi *
276 930 mapi * @return PHP_Depend_Code_ASTClassReference
277 828 mapi * @since 0.9.5
278 mapi */
279 930 mapi public function buildASTClassReference($qualifiedName)
280 828 mapi {
281 857 mapi $this->checkBuilderState();
282 mapi
283 930 mapi include_once 'PHP/Depend/Code/ASTClassReference.php';
284 828 mapi
285 929 mapi // Debug method creation
286 mapi PHP_Depend_Util_Log::debug(
287 930 mapi 'Creating: PHP_Depend_Code_ASTClassReference(' . $qualifiedName . ')'
288 929 mapi );
289 mapi
290 930 mapi return new PHP_Depend_Code_ASTClassReference($this, $qualifiedName);
291 828 mapi }
292 mapi
293 mapi /**
294 723 mapi * Builds a new closure instance.
295 mapi *
296 mapi * @return PHP_Depend_Code_Closure
297 mapi */
298 mapi public function buildClosure()
299 mapi {
300 857 mapi $this->checkBuilderState();
301 mapi
302 723 mapi include_once 'PHP/Depend/Code/Closure.php';
303 mapi
304 929 mapi // Debug type constant creation
305 mapi PHP_Depend_Util_Log::debug(
306 mapi 'Creating: PHP_Depend_Code_Closure()'
307 mapi );
308 mapi
309 723 mapi return new PHP_Depend_Code_Closure();
310 mapi }
311 mapi
312 mapi /**
313 119 mapi * Builds a new new interface instance.
314 537 mapi *
315 192 mapi * If there is an existing class instance for the given name, this method
316 mapi * checks if this class is part of the default namespace. If this is the
317 mapi * case this method will update all references to the new interface and it
318 mapi * removes the class instance. Otherwise it creates new interface instance.
319 537 mapi *
320 mapi * Where possible you should give a qualified interface name, that is
321 192 mapi * prefixed with the package identifier.
322 537 mapi *
323 192 mapi * <code>
324 mapi * $builder->buildInterface('php::depend::Parser');
325 mapi * </code>
326 537 mapi *
327 192 mapi * To determine the correct interface, this method implements the following
328 mapi * algorithm.
329 537 mapi *
330 192 mapi * <ol>
331 mapi * <li>Check for an exactly matching instance and reuse it.</li>
332 mapi * <li>Check for a interface instance that belongs to the default package.
333 537 mapi * If such an instance exists, reuse it and replace the default package
334 192 mapi * with the newly given package information.</li>
335 537 mapi * <li>Check that the requested interface is in the default package, if
336 192 mapi * this is true, reuse the first interface instance and ignore the default
337 mapi * package.
338 mapi * </li>
339 mapi * <li>Create a new instance for the specified package.</li>
340 mapi * </ol>
341 537 mapi *
342 675 mapi * @param string $name The interface name.
343 537 mapi *
344 119 mapi * @return PHP_Depend_Code_Interface The created interface object.
345 mapi */
346 675 mapi public function buildInterface($name)
347 119 mapi {
348 857 mapi $this->checkBuilderState();
349 855 mapi
350 mapi $interfaceName = $this->extractTypeName($name);
351 mapi $packageName = $this->extractPackageName($name);
352 mapi
353 mapi $interface = new PHP_Depend_Code_Interface($interfaceName);
354 mapi $interface->setSourceFile($this->defaultFile);
355 mapi
356 860 mapi $this->storeInterface($interfaceName, $packageName, $interface);
357 855 mapi
358 mapi return $interface;
359 mapi }
360 mapi
361 857 mapi /**
362 mapi * This method will try to find an already existing instance for the given
363 mapi * qualified name. It will create a new {@link PHP_Depend_Code_Interface}
364 mapi * instance when no matching type exists.
365 mapi *
366 mapi * @param string $qualifiedName The full qualified type identifier.
367 mapi *
368 mapi * @return PHP_Depend_Code_Interface
369 mapi * @since 0.9.5
370 mapi */
371 855 mapi public function getInterface($qualifiedName)
372 mapi {
373 mapi $interface = $this->findInterface($qualifiedName);
374 mapi if ($interface === null) {
375 857 mapi $interface = $this->buildInterfaceInternal($qualifiedName);
376 855 mapi }
377 mapi return $interface;
378 mapi }
379 857 mapi
380 119 mapi /**
381 842 mapi * Builds a new code type reference instance.
382 mapi *
383 mapi * @param string $qualifiedName The qualified name of the referenced type.
384 mapi *
385 930 mapi * @return PHP_Depend_Code_ASTInterfaceReference
386 842 mapi * @since 0.9.5
387 mapi */
388 mapi public function buildInterfaceReference($qualifiedName)
389 mapi {
390 857 mapi $this->checkBuilderState();
391 mapi
392 930 mapi include_once 'PHP/Depend/Code/ASTInterfaceReference.php';
393 842 mapi
394 929 mapi // Debug method creation
395 mapi PHP_Depend_Util_Log::debug(
396 930 mapi 'Creating: PHP_Depend_Code_ASTInterfaceReference(' . $qualifiedName . ')'
397 929 mapi );
398 mapi
399 930 mapi return new PHP_Depend_Code_ASTInterfaceReference($this, $qualifiedName);
400 842 mapi }
401 mapi
402 mapi /**
403 10 mapi * Builds a new method instance.
404 1 mapi *
405 675 mapi * @param string $name The method name.
406 537 mapi *
407 10 mapi * @return PHP_Depend_Code_Method The created class method object.
408 1 mapi */
409 675 mapi public function buildMethod($name)
410 1 mapi {
411 857 mapi $this->checkBuilderState();
412 mapi
413 656 mapi // Debug method creation
414 929 mapi PHP_Depend_Util_Log::debug(
415 mapi 'Creating: PHP_Depend_Code_Method(' . $name . ')'
416 mapi );
417 656 mapi
418 119 mapi // Create a new method instance
419 857 mapi return new PHP_Depend_Code_Method($name);
420 1 mapi }
421 537 mapi
422 10 mapi /**
423 mapi * Builds a new package instance.
424 mapi *
425 mapi * @param string $name The package name.
426 537 mapi *
427 10 mapi * @return PHP_Depend_Code_Package The created package object.
428 mapi */
429 1 mapi public function buildPackage($name)
430 mapi {
431 857 mapi if (!isset($this->_packages[$name])) {
432 656 mapi // Debug package creation
433 929 mapi PHP_Depend_Util_Log::debug(
434 mapi 'Creating: PHP_Depend_Code_Package(' . $name . ')'
435 mapi );
436 656 mapi
437 857 mapi $this->_packages[$name] = new PHP_Depend_Code_Package($name);
438 1 mapi }
439 857 mapi return $this->_packages[$name];
440 1 mapi }
441 537 mapi
442 10 mapi /**
443 mapi * Builds a new function instance.
444 mapi *
445 675 mapi * @param string $name The function name.
446 537 mapi *
447 12 mapi * @return PHP_Depend_Code_Function The function instance.
448 10 mapi */
449 675 mapi public function buildFunction($name)
450 1 mapi {
451 857 mapi $this->checkBuilderState();
452 656 mapi
453 857 mapi // Debug function creation
454 929 mapi PHP_Depend_Util_Log::debug(
455 mapi 'Creating: PHP_Depend_Code_Function(' . $name . ')'
456 mapi );
457 537 mapi
458 857 mapi // Create new function
459 mapi $function = new PHP_Depend_Code_Function($name);
460 mapi $function->setSourceFile($this->defaultFile);
461 mapi
462 38 mapi return $function;
463 1 mapi }
464 537 mapi
465 12 mapi /**
466 923 mapi * Builds a new self reference instance.
467 mapi *
468 mapi * @param PHP_Depend_Code_AbstractClassOrInterface $type The type instance
469 mapi * that reference the concrete target of self.
470 mapi *
471 930 mapi * @return PHP_Depend_Code_ASTSelfReference
472 923 mapi * @since 0.9.6
473 mapi */
474 930 mapi public function buildASTSelfReference(
475 927 mapi PHP_Depend_Code_AbstractClassOrInterface $type
476 mapi ) {
477 930 mapi include_once 'PHP/Depend/Code/ASTSelfReference.php';
478 923 mapi
479 929 mapi PHP_Depend_Util_Log::debug(
480 930 mapi 'Creating: PHP_Depend_Code_ASTSelfReference(' . $type->getName() . ')'
481 929 mapi );
482 mapi
483 930 mapi return new PHP_Depend_Code_ASTSelfReference($type);
484 923 mapi }
485 mapi
486 mapi /**
487 941 mapi * Builds a new parent reference instance.
488 mapi *
489 mapi * @param PHP_Depend_Code_ASTClassOrInterfaceReference $reference The type
490 mapi * instance that reference the concrete target of parent.
491 mapi *
492 mapi * @return PHP_Depend_Code_ASTParentReference
493 mapi * @since 0.9.6
494 mapi */
495 mapi public function buildASTParentReference(
496 mapi PHP_Depend_Code_ASTClassOrInterfaceReference $reference
497 mapi ) {
498 mapi include_once 'PHP/Depend/Code/ASTParentReference.php';
499 mapi
500 mapi PHP_Depend_Util_Log::debug(
501 mapi 'Creating: PHP_Depend_Code_ASTParentReference()'
502 mapi );
503 mapi
504 mapi return new PHP_Depend_Code_ASTParentReference($reference);
505 mapi }
506 mapi
507 mapi /**
508 mapi * Builds a new static reference instance.
509 mapi *
510 mapi * @param PHP_Depend_Code_AbstractClassOrInterface $owner The owning instance
511 mapi * that reference the concrete target of static.
512 mapi *
513 mapi * @return PHP_Depend_Code_ASTStaticReference
514 mapi * @since 0.9.6
515 mapi */
516 mapi public function buildASTStaticReference(
517 mapi PHP_Depend_Code_AbstractClassOrInterface $owner
518 mapi ) {
519 mapi include_once 'PHP/Depend/Code/ASTStaticReference.php';
520 mapi
521 mapi PHP_Depend_Util_Log::debug(
522 mapi 'Creating: PHP_Depend_Code_ASTStaticReference()'
523 mapi );
524 mapi
525 mapi return new PHP_Depend_Code_ASTStaticReference($owner);
526 mapi }
527 mapi
528 mapi /**
529 916 mapi * Builds a new field declaration node.
530 mapi *
531 930 mapi * @return PHP_Depend_Code_ASTFieldDeclaration
532 916 mapi * @since 0.9.6
533 mapi */
534 930 mapi public function buildASTFieldDeclaration()
535 916 mapi {
536 1244 mapi return $this->_buildASTNodeInstance('ASTFieldDeclaration');
537 916 mapi }
538 mapi
539 mapi /**
540 915 mapi * Builds a new variable declarator node.
541 mapi *
542 mapi * @param string $image The source image for the variable declarator.
543 mapi *
544 930 mapi * @return PHP_Depend_Code_ASTVariableDeclarator
545 915 mapi * @since 0.9.6
546 mapi */
547 930 mapi public function buildASTVariableDeclarator($image)
548 915 mapi {
549 1243 mapi return $this->_buildASTNodeInstance('ASTVariableDeclarator', $image);
550 915 mapi }
551 mapi
552 mapi /**
553 mapi * Builds a new static variable declaration node.
554 mapi *
555 mapi * @param string $image The source image for the statuc declaration.
556 mapi *
557 930 mapi * @return PHP_Depend_Code_ASTStaticVariableDeclaration
558 915 mapi * @since 0.9.6
559 mapi */
560 930 mapi public function buildASTStaticVariableDeclaration($image)
561 915 mapi {
562 1243 mapi return $this->_buildASTNodeInstance('ASTStaticVariableDeclaration', $image);
563 915 mapi }
564 mapi
565 mapi /**
566 941 mapi * Builds a new constant node.
567 mapi *
568 mapi * @param string $image The source image for the constant.
569 mapi *
570 mapi * @return PHP_Depend_Code_ASTConstant
571 mapi * @since 0.9.6
572 mapi */
573 mapi public function buildASTConstant($image)
574 mapi {
575 1243 mapi return $this->_buildASTNodeInstance('ASTConstant', $image);
576 941 mapi }
577 mapi
578 mapi /**
579 mapi * Builds a new variable node.
580 mapi *
581 mapi * @param string $image The source image for the variable.
582 mapi *
583 mapi * @return PHP_Depend_Code_ASTVariable
584 mapi * @since 0.9.6
585 mapi */
586 mapi public function buildASTVariable($image)
587 mapi {
588 1243 mapi return $this->_buildASTNodeInstance('ASTVariable', $image);
589 941 mapi }
590 mapi
591 mapi /**
592 mapi * Builds a new variable variable node.
593 mapi *
594 mapi * @param string $image The source image for the variable variable.
595 mapi *
596 mapi * @return PHP_Depend_Code_ASTVariableVariable
597 mapi * @since 0.9.6
598 mapi */
599 mapi public function buildASTVariableVariable($image)
600 mapi {
601 1243 mapi return $this->_buildASTNodeInstance('ASTVariableVariable', $image);
602 941 mapi }
603 mapi
604 mapi /**
605 mapi * Builds a new compound variable node.
606 mapi *
607 mapi * @param string $image The source image for the compound variable.
608 mapi *
609 mapi * @return PHP_Depend_Code_ASTCompoundVariable
610 mapi * @since 0.9.6
611 mapi */
612 mapi public function buildASTCompoundVariable($image)
613 mapi {
614 1243 mapi return $this->_buildASTNodeInstance('ASTCompoundVariable', $image);
615 941 mapi }
616 mapi
617 mapi /**
618 mapi * Builds a new compound expression node.
619 mapi *
620 mapi * @return PHP_Depend_Code_ASTCompoundExpression
621 mapi * @since 0.9.6
622 mapi */
623 mapi public function buildASTCompoundExpression()
624 mapi {
625 1243 mapi return $this->_buildASTNodeInstance('ASTCompoundExpression');
626 941 mapi }
627 mapi
628 mapi /**
629 1142 mapi * Builds a new closure node.
630 mapi *
631 mapi * @return PHP_Depend_Code_ASTClosure
632 mapi * @since 0.9.12
633 mapi */
634 mapi public function buildASTClosure()
635 mapi {
636 mapi return $this->_buildASTNodeInstance('ASTClosure');
637 mapi }
638 mapi
639 mapi /**
640 920 mapi * Builds a new formal parameters node.
641 mapi *
642 930 mapi * @return PHP_Depend_Code_ASTFormalParameters
643 920 mapi * @since 0.9.6
644 mapi */
645 930 mapi public function buildASTFormalParameters()
646 920 mapi {
647 1243 mapi return $this->_buildASTNodeInstance('ASTFormalParameters');
648 920 mapi }
649 mapi
650 mapi /**
651 929 mapi * Builds a new formal parameter node.
652 mapi *
653 930 mapi * @return PHP_Depend_Code_ASTFormalParameter
654 929 mapi * @since 0.9.6
655 mapi */
656 930 mapi public function buildASTFormalParameter()
657 929 mapi {
658 1243 mapi return $this->_buildASTNodeInstance('ASTFormalParameter');
659 929 mapi }
660 mapi
661 mapi /**
662 988 mapi * Builds a new expression node.
663 mapi *
664 mapi * @return PHP_Depend_Code_ASTExpression
665 mapi * @since 0.9.8
666 mapi */
667 mapi public function buildASTExpression()
668 mapi {
669 1243 mapi return $this->_buildASTNodeInstance('ASTExpression');
670 988 mapi }
671 mapi
672 mapi /**
673 990 mapi * Builds a new assignment expression node.
674 mapi *
675 mapi * @param string $image The assignment operator.
676 mapi *
677 mapi * @return PHP_Depend_Code_ASTAssignmentExpression
678 mapi * @since 0.9.8
679 mapi */
680 mapi public function buildASTAssignmentExpression($image)
681 mapi {
682 1243 mapi return $this->_buildASTNodeInstance('ASTAssignmentExpression', $image);
683 990 mapi }
684 mapi
685 mapi /**
686 940 mapi * Builds a new allocation expression node.
687 mapi *
688 mapi * @param string $image The source image of this expression.
689 mapi *
690 mapi * @return PHP_Depend_Code_ASTAllocationExpression
691 mapi * @since 0.9.6
692 mapi */
693 mapi public function buildASTAllocationExpression($image)
694 mapi {
695 1178 mapi return $this->_buildASTNodeInstance('ASTAllocationExpression', $image);
696 mapi }
697 940 mapi
698 1178 mapi /**
699 mapi * Builds a new eval-expression node.
700 mapi *
701 mapi * @param string $image The source image of this expression.
702 mapi *
703 mapi * @return PHP_Depend_Code_ASTEvalExpression
704 mapi * @since 0.9.12
705 mapi */
706 mapi public function buildASTEvalExpression($image)
707 mapi {
708 mapi return $this->_buildASTNodeInstance('ASTEvalExpression', $image);
709 mapi }
710 940 mapi
711 1178 mapi /**
712 mapi * Builds a new exit-expression instance.
713 mapi *
714 mapi * @param string $image The source code image for this node.
715 mapi *
716 mapi * @return PHP_Depend_Code_ASTExitExpression
717 mapi * @since 0.9.12
718 mapi */
719 mapi public function buildASTExitExpression($image)
720 mapi {
721 mapi return $this->_buildASTNodeInstance('ASTExitExpression', $image);
722 940 mapi }
723 mapi
724 mapi /**
725 1178 mapi * Builds a new clone-expression node.
726 mapi *
727 mapi * @param string $image The source image of this expression.
728 mapi *
729 mapi * @return PHP_Depend_Code_ASTCloneExpression
730 mapi * @since 0.9.12
731 mapi */
732 mapi public function buildASTCloneExpression($image)
733 mapi {
734 mapi return $this->_buildASTNodeInstance('ASTCloneExpression', $image);
735 mapi }
736 mapi
737 mapi /**
738 1224 mapi * Builds a new list-expression node.
739 mapi *
740 mapi * @param string $image The source image of this expression.
741 mapi *
742 mapi * @return PHP_Depend_Code_ASTListExpression
743 mapi * @author Joey Mazzarelli
744 mapi * @since 0.9.12
745 mapi */
746 mapi public function buildASTListExpression($image)
747 mapi {
748 mapi return $this->_buildASTNodeInstance('ASTListExpression', $image);
749 mapi }
750 mapi
751 mapi /**
752 1242 mapi * Builds a new include- or include_once-expression.
753 mapi *
754 mapi * @return PHP_Depend_Code_ASTIncludeExpression
755 mapi * @since 0.9.12
756 mapi */
757 mapi public function buildASTIncludeExpression()
758 mapi {
759 mapi return $this->_buildASTNodeInstance('ASTIncludeExpression');
760 mapi }
761 mapi
762 mapi /**
763 1240 mapi * Builds a new require- or require_once-expression.
764 mapi *
765 mapi * @return PHP_Depend_Code_ASTRequireExpression
766 mapi * @since 0.9.12
767 mapi */
768 mapi public function buildASTRequireExpression()
769 mapi {
770 mapi return $this->_buildASTNodeInstance('ASTRequireExpression');
771 mapi }
772 mapi
773 mapi /**
774 1178 mapi * Builds a new array-expression node.
775 mapi *
776 1235 mapi * @return PHP_Depend_Code_ASTArrayIndexExpression
777 1178 mapi * @since 0.9.12
778 mapi */
779 1235 mapi public function buildASTArrayIndexExpression()
780 1178 mapi {
781 1235 mapi return $this->_buildASTNodeInstance('ASTArrayIndexExpression');
782 1178 mapi }
783 mapi
784 mapi /**
785 1235 mapi * Builds a new string-expression node.
786 mapi *
787 mapi * <code>
788 mapi * // --------
789 mapi * $string{$index}
790 mapi * // --------
791 mapi * </code>
792 mapi *
793 mapi * @return PHP_Depend_Code_ASTStringIndexExpression
794 mapi * @since 0.9.12
795 mapi */
796 mapi public function buildASTStringIndexExpression()
797 mapi {
798 mapi return $this->_buildASTNodeInstance('ASTStringIndexExpression');
799 mapi }
800 mapi
801 mapi /**
802 941 mapi * Builds a new instanceof expression node.
803 mapi *
804 mapi * @param string $image The source image of this expression.
805 mapi *
806 mapi * @return PHP_Depend_Code_ASTInstanceOfExpression
807 mapi * @since 0.9.6
808 mapi */
809 mapi public function buildASTInstanceOfExpression($image)
810 mapi {
811 1243 mapi return $this->_buildASTNodeInstance('ASTInstanceOfExpression', $image);
812 941 mapi }
813 mapi
814 mapi /**
815 1226 mapi * Builds a new isset-expression node.
816 mapi *
817 mapi * <code>
818 mapi * // -----------
819 mapi * if (isset($foo)) {
820 mapi * // -----------
821 mapi * }
822 mapi *
823 mapi * // -----------------------
824 mapi * if (isset($foo, $bar, $baz)) {
825 mapi * // -----------------------
826 mapi * }
827 mapi * </code>
828 mapi *
829 mapi * @return PHP_Depend_Code_ASTIssetExpression
830 mapi * @since 0.9.12
831 mapi */
832 mapi public function buildASTIssetExpression()
833 mapi {
834 mapi return $this->_buildASTNodeInstance('ASTIssetExpression');
835 mapi }
836 mapi
837 mapi /**
838 976 mapi * Builds a new boolean conditional-expression.
839 mapi *
840 mapi * <code>
841 mapi * --------------
842 mapi * $bar = ($foo ? 42 : 23);
843 mapi * --------------
844 mapi * </code>
845 mapi *
846 mapi * @return PHP_Depend_Code_ASTConditionalExpression
847 mapi * @since 0.9.8
848 mapi */
849 mapi public function buildASTConditionalExpression()
850 mapi {
851 1243 mapi return $this->_buildASTNodeInstance('ASTConditionalExpression', '?');
852 976 mapi }
853 mapi
854 mapi /**
855 975 mapi * Builds a new boolean and-expression.
856 mapi *
857 mapi * @return PHP_Depend_Code_ASTBooleanAndExpression
858 976 mapi * @since 0.9.8
859 975 mapi */
860 mapi public function buildASTBooleanAndExpression()
861 mapi {
862 1243 mapi return $this->_buildASTNodeInstance('ASTBooleanAndExpression', '&&');
863 975 mapi }
864 mapi
865 mapi /**
866 mapi * Builds a new boolean or-expression.
867 mapi *
868 mapi * @return PHP_Depend_Code_ASTBooleanOrExpression
869 976 mapi * @since 0.9.8
870 975 mapi */
871 mapi public function buildASTBooleanOrExpression()
872 mapi {
873 1243 mapi return $this->_buildASTNodeInstance('ASTBooleanOrExpression', '||');
874 975 mapi }
875 mapi
876 mapi /**
877 976 mapi * Builds a new logical <b>and</b>-expression.
878 mapi *
879 mapi * @return PHP_Depend_Code_ASTLogicalAndExpression
880 mapi * @since 0.9.8
881 mapi */
882 mapi public function buildASTLogicalAndExpression()
883 mapi {
884 1243 mapi return $this->_buildASTNodeInstance('ASTLogicalAndExpression', 'and');
885 976 mapi }
886 mapi
887 mapi /**
888 mapi * Builds a new logical <b>or</b>-expression.
889 mapi *
890 mapi * @return PHP_Depend_Code_ASTLogicalOrExpression
891 mapi * @since 0.9.8
892 mapi */
893 mapi public function buildASTLogicalOrExpression()
894 mapi {
895 1243 mapi return $this->_buildASTNodeInstance('ASTLogicalOrExpression', 'or');
896 976 mapi }
897 mapi
898 mapi /**
899 mapi * Builds a new logical <b>xor</b>-expression.
900 mapi *
901 mapi * @return PHP_Depend_Code_ASTLogicalXorExpression
902 mapi * @since 0.9.8
903 mapi */
904 mapi public function buildASTLogicalXorExpression()
905 mapi {
906 1243 mapi return $this->_buildASTNodeInstance('ASTLogicalXorExpression', 'xor');
907 976 mapi }
908 mapi
909 mapi /**
910 988 mapi * Builds a new switch-statement-node.
911 mapi *
912 mapi * @return PHP_Depend_Code_ASTSwitchStatement
913 mapi * @since 0.9.8
914 mapi */
915 mapi public function buildASTSwitchStatement()
916 mapi {
917 1167 mapi return $this->_buildASTNodeInstance('ASTSwitchStatement');
918 988 mapi }
919 mapi
920 mapi /**
921 975 mapi * Builds a new switch-label node.
922 mapi *
923 mapi * @param string $image The source image of this label.
924 mapi *
925 mapi * @return PHP_Depend_Code_ASTSwitchLabel
926 mapi * @since 0.9.8
927 mapi */
928 mapi public function buildASTSwitchLabel($image)
929 mapi {
930 1167 mapi return $this->_buildASTNodeInstance('ASTSwitchLabel', $image);
931 975 mapi }
932 mapi
933 mapi /**
934 1178 mapi * Builds a new global-statement instance.
935 mapi *
936 mapi * @return PHP_Depend_Code_ASTGlobalStatement
937 mapi * @since 0.9.12
938 mapi */
939 mapi function buildASTGlobalStatement()
940 mapi {
941 mapi return $this->_buildASTNodeInstance('ASTGlobalStatement');
942 mapi }
943 mapi
944 mapi /**
945 mapi * Builds a new unset-statement instance.
946 mapi *
947 mapi * @return PHP_Depend_Code_ASTUnsetStatement
948 mapi * @since 0.9.12
949 mapi */
950 mapi public function buildASTUnsetStatement()
951 mapi {
952 mapi return $this->_buildASTNodeInstance('ASTUnsetStatement');
953 mapi }
954 mapi
955 mapi /**
956 974 mapi * Builds a new catch-statement node.
957 mapi *
958 mapi * @param string $image The source image of this statement.
959 mapi *
960 mapi * @return PHP_Depend_Code_ASTCatchStatement
961 mapi * @since 0.9.8
962 mapi */
963 mapi public function buildASTCatchStatement($image)
964 mapi {
965 1243 mapi return $this->_buildASTNodeInstance('ASTCatchStatement', $image);
966 974 mapi }
967 mapi
968 mapi /**
969 mapi * Builds a new if statement node.
970 mapi *
971 mapi * @param string $image The source image of this statement.
972 mapi *
973 mapi * @return PHP_Depend_Code_ASTIfStatement
974 mapi * @since 0.9.8
975 mapi */
976 mapi public function buildASTIfStatement($image)
977 mapi {
978 1243 mapi return $this->_buildASTNodeInstance('ASTIfStatement', $image);
979 974 mapi }
980 mapi
981 mapi /**
982 mapi * Builds a new elseif statement node.
983 mapi *
984 mapi * @param string $image The source image of this statement.
985 mapi *
986 mapi * @return PHP_Depend_Code_ASTElseIfStatement
987 mapi * @since 0.9.8
988 mapi */
989 mapi public function buildASTElseIfStatement($image)
990 mapi {
991 1243 mapi return $this->_buildASTNodeInstance('ASTElseIfStatement', $image);
992 974 mapi }
993 mapi
994 mapi /**
995 mapi * Builds a new for statement node.
996 mapi *
997 mapi * @param string $image The source image of this statement.
998 mapi *
999 mapi * @return PHP_Depend_Code_ASTForStatement
1000 mapi * @since 0.9.8
1001 mapi */
1002 mapi public function buildASTForStatement($image)
1003 mapi {
1004 1243 mapi return $this->_buildASTNodeInstance('ASTForStatement', $image);
1005 974 mapi }
1006 mapi
1007 mapi /**
1008 984 mapi * Builds a new for-init node.
1009 mapi *
1010 mapi * <code>
1011 mapi * ------------------------
1012 mapi * for ($x = 0, $y = 23, $z = 42; $x < $y; ++$x) {}
1013 mapi * ------------------------
1014 mapi * </code>
1015 mapi *
1016 mapi * @return PHP_Depend_Code_ASTForInit
1017 mapi * @since 0.9.8
1018 mapi */
1019 mapi public function buildASTForInit()
1020 mapi {
1021 1152 mapi return $this->_buildASTNodeInstance('ASTForInit');
1022 mapi }
1023 984 mapi
1024 1152 mapi /**
1025 mapi * Builds a new for-update node.
1026 mapi *
1027 mapi * <code>
1028 mapi * -------------------------------
1029 mapi * for ($x = 0, $y = 23, $z = 42; $x < $y; ++$x, $y = $x + 1, $z = $x + 2) {}
1030 mapi * -------------------------------
1031 mapi * </code>
1032 mapi *
1033 mapi * @return PHP_Depend_Code_ASTForUpdate
1034 mapi * @since 0.9.12
1035 mapi */
1036 mapi public function buildASTForUpdate()
1037 mapi {
1038 mapi return $this->_buildASTNodeInstance('ASTForUpdate');
1039 984 mapi }
1040 mapi
1041 mapi /**
1042 974 mapi * Builds a new foreach-statement node.
1043 mapi *
1044 mapi * @param string $image The source image of this statement.
1045 mapi *
1046 mapi * @return PHP_Depend_Code_ASTForeachStatement
1047 mapi * @since 0.9.8
1048 mapi */
1049 mapi public function buildASTForeachStatement($image)
1050 mapi {
1051 1243 mapi return $this->_buildASTNodeInstance('ASTForeachStatement', $image);
1052 974 mapi }
1053 mapi
1054 mapi /**
1055 mapi * Builds a new while-statement node.
1056 mapi *
1057 mapi * @param string $image The source image of this statement.
1058 mapi *
1059 mapi * @return PHP_Depend_Code_ASTWhileStatement
1060 mapi * @since 0.9.8
1061 mapi */
1062 mapi public function buildASTWhileStatement($image)
1063 mapi {
1064 1243 mapi return $this->_buildASTNodeInstance('ASTWhileStatement', $image);
1065 974 mapi }
1066 mapi
1067 mapi /**
1068 1142 mapi * Builds a new do/while-statement node.
1069 mapi *
1070 mapi * @param string $image The source image of this statement.
1071 mapi *
1072 mapi * @return PHP_Depend_Code_ASTDoWhileStatement
1073 mapi * @since 0.9.12
1074 mapi */
1075 mapi public function buildASTDoWhileStatement($image)
1076 mapi {
1077 mapi return $this->_buildASTNodeInstance('ASTDoWhileStatement', $image);
1078 mapi }
1079 mapi
1080 mapi /**
1081 941 mapi * Builds a new member primary expression node.
1082 mapi *
1083 mapi * <code>
1084 mapi * //--------
1085 mapi * Foo::bar();
1086 mapi * //--------
1087 mapi *
1088 mapi * //---------
1089 mapi * Foo::$bar();
1090 mapi * //---------
1091 mapi *
1092 mapi * //---------
1093 mapi * $obj->bar();
1094 mapi * //---------
1095 mapi *
1096 mapi * //----------
1097 mapi * $obj->$bar();
1098 mapi * //----------
1099 mapi * </code>
1100 mapi *
1101 mapi * @param string $image The source image of this expression.
1102 mapi *
1103 mapi * @return PHP_Depend_Code_ASTMemberPrimaryPrefix
1104 mapi * @since 0.9.6
1105 mapi */
1106 mapi public function buildASTMemberPrimaryPrefix($image)
1107 mapi {
1108 1243 mapi return $this->_buildASTNodeInstance('ASTMemberPrimaryPrefix', $image);
1109 941 mapi }
1110 mapi
1111 mapi /**
1112 mapi * Builds a new identifier node.
1113 mapi *
1114 mapi * @param string $image The image of this identifier.
1115 mapi *
1116 mapi * @return PHP_Depend_Code_ASTIdentifier
1117 mapi * @since 0.9.6
1118 mapi */
1119 mapi public function buildASTIdentifier($image)
1120 mapi {
1121 1243 mapi return $this->_buildASTNodeInstance('ASTIdentifier', $image);
1122 941 mapi }
1123 mapi
1124 mapi /**
1125 mapi * Builds a new function postfix expression.
1126 mapi *
1127 mapi * <code>
1128 mapi * //-------
1129 mapi * foo($bar);
1130 mapi * //-------
1131 mapi *
1132 mapi * //--------
1133 mapi * $foo($bar);
1134 mapi * //--------
1135 mapi * </code>
1136 mapi *
1137 mapi * @param string $image The image of this node.
1138 mapi *
1139 mapi * @return PHP_Depend_Code_ASTFunctionPostfix
1140 mapi * @since 0.9.6
1141 mapi */
1142 mapi public function buildASTFunctionPostfix($image)
1143 mapi {
1144 1243 mapi return $this->_buildASTNodeInstance('ASTFunctionPostfix', $image);
1145 941 mapi }
1146 mapi
1147 mapi /**
1148 mapi * Builds a new method postfix expression.
1149 mapi *
1150 mapi * <code>
1151 mapi * // ---------
1152 mapi * Foo::bar($baz);
1153 mapi * // ---------
1154 mapi *
1155 mapi * // ----------
1156 mapi * Foo::$bar($baz);
1157 mapi * // ----------
1158 mapi * </code>
1159 mapi *
1160 mapi * @param string $image The image of this node.
1161 mapi *
1162 mapi * @return PHP_Depend_Code_ASTMethodPostfix
1163 mapi * @since 0.9.6
1164 mapi */
1165 mapi public function buildASTMethodPostfix($image)
1166 mapi {
1167 1243 mapi return $this->_buildASTNodeInstance('ASTMethodPostfix', $image);
1168 941 mapi }
1169 mapi
1170 mapi /**
1171 mapi * Builds a new constant postfix expression.
1172 mapi *
1173 mapi * <code>
1174 mapi * // ---
1175 mapi * Foo::BAR;
1176 mapi * // ---
1177 mapi * </code>
1178 mapi *
1179 mapi * @param string $image The image of this node.
1180 mapi *
1181 mapi * @return PHP_Depend_Code_ASTConstantPostfix
1182 mapi * @since 0.9.6
1183 mapi */
1184 mapi public function buildASTConstantPostfix($image)
1185 mapi {
1186 1243 mapi return $this->_buildASTNodeInstance('ASTConstantPostfix', $image);
1187 941 mapi }
1188 mapi
1189 mapi /**
1190 mapi * Builds a new property postfix expression.
1191 mapi *
1192 mapi * <code>
1193 mapi * // ----
1194 mapi * Foo::$bar;
1195 mapi * // ----
1196 mapi *
1197 mapi * // ---
1198 mapi * $object->bar;
1199 mapi * // ---
1200 mapi * </code>
1201 mapi *
1202 mapi * @param string $image The image of this node.
1203 mapi *
1204 mapi * @return PHP_Depend_Code_ASTPropertyPostfix
1205 mapi * @since 0.9.6
1206 mapi */
1207 mapi public function buildASTPropertyPostfix($image)
1208 mapi {
1209 1243 mapi return $this->_buildASTNodeInstance('ASTPropertyPostfix', $image);
1210 941 mapi }
1211 mapi
1212 mapi /**
1213 mapi * Builds a new arguments list.
1214 mapi *
1215 mapi * <code>
1216 mapi * // ------------
1217 mapi * Foo::bar($x, $y, $z);
1218 mapi * // ------------
1219 mapi *
1220 mapi * // ------------
1221 mapi * $foo->bar($x, $y, $z);
1222 mapi * // ------------
1223 mapi * </code>
1224 mapi *
1225 mapi * @return PHP_Depend_Code_ASTArguments();
1226 mapi * @since 0.9.6
1227 mapi */
1228 mapi public function buildASTArguments()
1229 mapi {
1230 1243 mapi return $this->_buildASTNodeInstance('ASTArguments');
1231 941 mapi }
1232 mapi
1233 mapi /**
1234 921 mapi * Builds a new array type node.
1235 mapi *
1236 930 mapi * @return PHP_Depend_Code_ASTArrayType
1237 921 mapi * @since 0.9.6
1238 mapi */
1239 930 mapi public function buildASTArrayType()
1240 921 mapi {
1241 1243 mapi return $this->_buildASTNodeInstance('ASTArrayType');
1242 921 mapi }
1243 mapi
1244 mapi /**
1245 mapi * Builds a new primitive type node.
1246 mapi *
1247 mapi * @param string $image The source image for the primitive type.
1248 mapi *
1249 930 mapi * @return PHP_Depend_Code_ASTPrimitiveType
1250 921 mapi * @since 0.9.6
1251 mapi */
1252 930 mapi public function buildASTPrimitiveType($image)
1253 921 mapi {
1254 1243 mapi return $this->_buildASTNodeInstance('ASTPrimitiveType', $image);
1255 921 mapi }
1256 mapi
1257 mapi /**
1258 941 mapi * Builds a new literal node.
1259 mapi *
1260 mapi * @param string $image The source image for the literal node.
1261 mapi *
1262 mapi * @return PHP_Depend_Code_ASTLiteral
1263 mapi * @since 0.9.6
1264 mapi */
1265 mapi public function buildASTLiteral($image)
1266 mapi {
1267 1243 mapi return $this->_buildASTNodeInstance('ASTLiteral', $image);
1268 941 mapi }
1269 mapi
1270 mapi /**
1271 1034 mapi * Builds a new php string node.
1272 mapi *
1273 1035 mapi * <code>
1274 mapi * $string = "Manuel $Pichler <{$email}>";
1275 mapi *
1276 mapi * // PHP_Depend_Code_ASTString
1277 mapi * // |-- ASTLiteral - "Manuel ")
1278 mapi * // |-- ASTVariable - $Pichler
1279 mapi * // |-- ASTLiteral - " <"
1280 mapi * // |-- ASTCompoundExpression - {...}
1281 mapi * // | |-- ASTVariable - $email
1282 mapi * // |-- ASTLiteral - ">"
1283 mapi * </code>
1284 mapi *
1285 1034 mapi * @return PHP_Depend_Code_ASTString
1286 mapi * @since 0.9.10
1287 mapi */
1288 mapi public function buildASTString()
1289 mapi {
1290 1243 mapi return $this->_buildASTNodeInstance('ASTString');
1291 1034 mapi }
1292 mapi
1293 mapi /**
1294 1221 mapi * Builds a new heredoc node.
1295 mapi *
1296 mapi * @return PHP_Depend_Code_ASTHeredoc
1297 mapi * @since 0.9.12
1298 mapi */
1299 mapi public function buildASTHeredoc()
1300 mapi {
1301 mapi return $this->_buildASTNodeInstance('ASTHeredoc');
1302 mapi }
1303 mapi
1304 mapi /**
1305 931 mapi * Builds a new constant definition node.
1306 mapi *
1307 mapi * <code>
1308 mapi * class Foo
1309 mapi * {
1310 mapi * // ------------------------
1311 mapi * const FOO = 42, BAR = 23;
1312 mapi * // ------------------------
1313 mapi * }
1314 mapi * </code>
1315 mapi *
1316 mapi * @param string $image The source code image for this node.
1317 mapi *
1318 mapi * @return PHP_Depend_Code_ASTConstantDefinition
1319 mapi * @since 0.9.6
1320 mapi */
1321 mapi public function buildASTConstantDefinition($image)
1322 mapi {
1323 1243 mapi return $this->_buildASTNodeInstance('ASTConstantDefinition', $image);
1324 931 mapi }
1325 mapi
1326 mapi /**
1327 mapi * Builds a new constant declarator node.
1328 mapi *
1329 mapi * <code>
1330 mapi * class Foo
1331 mapi * {
1332 mapi * // --------
1333 mapi * const BAR = 42;
1334 mapi * // --------
1335 mapi * }
1336 mapi * </code>
1337 mapi *
1338 mapi * Or in a comma separated constant defintion:
1339 mapi *
1340 mapi * <code>
1341 mapi * class Foo
1342 mapi * {
1343 mapi * // --------
1344 mapi * const BAR = 42,
1345 mapi * // --------
1346 mapi *
1347 mapi * // --------------
1348 mapi * const BAZ = 'Foobar',
1349 mapi * // --------------
1350 mapi *
1351 mapi * // ----------
1352 mapi * const FOO = 3.14;
1353 mapi * // ----------
1354 mapi * }
1355 mapi * </code>
1356 mapi *
1357 mapi * @param string $image The source code image for this node.
1358 mapi *
1359 mapi * @return PHP_Depend_Code_ASTConstantDeclarator
1360 mapi * @since 0.9.6
1361 mapi */
1362 mapi public function buildASTConstantDeclarator($image)
1363 mapi {
1364 1243 mapi return $this->_buildASTNodeInstance('ASTConstantDeclarator', $image);
1365 931 mapi }
1366 mapi
1367 mapi /**
1368 988 mapi * Builds a new comment node instance.
1369 mapi *
1370 mapi * @param string $cdata The comment text.
1371 mapi *
1372 mapi * @return PHP_Depend_Code_ASTComment
1373 mapi * @since 0.9.8
1374 mapi */
1375 mapi public function buildASTComment($cdata)
1376 mapi {
1377 1243 mapi return $this->_buildASTNodeInstance('ASTComment', $cdata);
1378 988 mapi }
1379 mapi
1380 mapi /**
1381 1115 mapi * Builds a new unary expression node instance.
1382 mapi *
1383 mapi * @param string $image The unary expression image/character.
1384 mapi *
1385 mapi * @return PHP_Depend_Code_ASTUnaryExpression
1386 mapi * @since 0.9.11
1387 mapi */
1388 mapi public function buildASTUnaryExpression($image)
1389 mapi {
1390 1123 mapi return $this->_buildASTNodeInstance('ASTUnaryExpression', $image);
1391 1115 mapi }
1392 mapi
1393 mapi /**
1394 1283 mapi * Builds a new cast-expression node instance.
1395 mapi *
1396 mapi * @param string $image The cast-expression image/character.
1397 mapi *
1398 mapi * @return PHP_Depend_Code_ASTCastExpression
1399 1314 mapi * @since 0.10.0
1400 1283 mapi */
1401 mapi public function buildASTCastExpression($image)
1402 mapi {
1403 mapi return $this->_buildASTNodeInstance('ASTCastExpression', $image);
1404 mapi }
1405 mapi
1406 mapi /**
1407 1314 mapi * Builds a new postfix-expression node instance.
1408 mapi *
1409 mapi * @param string $image The postfix-expression image/character.
1410 mapi *
1411 mapi * @return PHP_Depend_Code_ASTPostfixExpression
1412 mapi * @since 0.10.0
1413 mapi */
1414 mapi public function buildASTPostfixExpression($image)
1415 mapi {
1416 mapi return $this->_buildASTNodeInstance('ASTPostfixExpression', $image);
1417 mapi }
1418 mapi
1419 mapi /**
1420 mapi * Builds a new pre-increment-expression node instance.
1421 mapi *
1422 mapi * @return PHP_Depend_Code_ASTPreIncrementExpression
1423 mapi * @since 0.10.0
1424 mapi */
1425 mapi public function buildASTPreIncrementExpression()
1426 mapi {
1427 mapi return $this->_buildASTNodeInstance('ASTPreIncrementExpression');
1428 mapi }
1429 mapi
1430 mapi /**
1431 1317 mapi * Builds a new pre-decrement-expression node instance.
1432 mapi *
1433 mapi * @return PHP_Depend_Code_ASTPreDecrementExpression
1434 mapi * @since 0.10.0
1435 mapi */
1436 mapi public function buildASTPreDecrementExpression()
1437 mapi {
1438 mapi return $this->_buildASTNodeInstance('ASTPreDecrementExpression');
1439 mapi }
1440 mapi
1441 mapi /**
1442 1151 mapi * Builds a new function/method scope instance.
1443 mapi *
1444 mapi * @return PHP_Depend_Code_ASTScope
1445 mapi * @since 0.9.12
1446 mapi */
1447 mapi public function buildASTScope()
1448 mapi {
1449 mapi return $this->_buildASTNodeInstance('ASTScope');
1450 mapi }
1451 mapi
1452 mapi /**
1453 1135 mapi * Builds a new statement instance.
1454 mapi *
1455 mapi * @return PHP_Depend_Code_ASTStatement
1456 mapi * @since 0.9.12
1457 mapi */
1458 mapi public function buildASTStatement()
1459 mapi {
1460 mapi return $this->_buildASTNodeInstance('ASTStatement');
1461 mapi }
1462 mapi
1463 mapi /**
1464 1119 mapi * Builds a new return statement node instance.
1465 mapi *
1466 mapi * @param string $image The source code image for this node.
1467 mapi *
1468 mapi * @return PHP_Depend_Code_ASTReturnStatement
1469 mapi * @since 0.9.12
1470 mapi */
1471 mapi public function buildASTReturnStatement($image)
1472 mapi {
1473 1123 mapi return $this->_buildASTNodeInstance('ASTReturnStatement', $image);
1474 mapi }
1475 1119 mapi
1476 1123 mapi /**
1477 mapi * Builds a new break-statement node instance.
1478 mapi *
1479 mapi * @param string $image The source code image for this node.
1480 mapi *
1481 mapi * @return PHP_Depend_Code_ASTBreakStatement
1482 mapi * @since 0.9.12
1483 mapi */
1484 mapi public function buildASTBreakStatement($image)
1485 mapi {
1486 mapi return $this->_buildASTNodeInstance('ASTBreakStatement', $image);
1487 mapi }
1488 1119 mapi
1489 1123 mapi /**
1490 mapi * Builds a new continue-statement node instance.
1491 mapi *
1492 mapi * @param string $image The source code image for this node.
1493 mapi *
1494 mapi * @return PHP_Depend_Code_ASTContinueStatement
1495 mapi * @since 0.9.12
1496 mapi */
1497 mapi public function buildASTContinueStatement($image)
1498 mapi {
1499 mapi return $this->_buildASTNodeInstance('ASTContinueStatement', $image);
1500 1119 mapi }
1501 mapi
1502 mapi /**
1503 1135 mapi * Builds a new scope-statement instance.
1504 mapi *
1505 mapi * @return PHP_Depend_Code_ASTScopeStatement
1506 mapi * @since 0.9.12
1507 mapi */
1508 mapi public function buildASTScopeStatement()
1509 mapi {
1510 mapi return $this->_buildASTNodeInstance('ASTScopeStatement');
1511 mapi }
1512 mapi
1513 mapi /**
1514 1139 mapi * Builds a new try-statement instance.
1515 mapi *
1516 mapi * @param string $image The source code image for this node.
1517 mapi *
1518 mapi * @return PHP_Depend_Code_ASTTryStatement
1519 mapi * @since 0.9.12
1520 mapi */
1521 mapi public function buildASTTryStatement($image)
1522 mapi {
1523 mapi return $this->_buildASTNodeInstance('ASTTryStatement', $image);
1524 mapi }
1525 mapi
1526 mapi /**
1527 1178 mapi * Builds a new throw-statement instance.
1528 mapi *
1529 mapi * @param string $image The source code image for this node.
1530 mapi *
1531 mapi * @return PHP_Depend_Code_ASTThrowStatement
1532 mapi * @since 0.9.12
1533 mapi */
1534 mapi public function buildASTThrowStatement($image)
1535 mapi {
1536 mapi return $this->_buildASTNodeInstance('ASTThrowStatement', $image);
1537 mapi }
1538 mapi
1539 mapi /**
1540 mapi * Builds a new goto-statement instance.
1541 mapi *
1542 mapi * @param string $image The source code image for this node.
1543 mapi *
1544 mapi * @return PHP_Depend_Code_ASTGotoStatement
1545 mapi * @since 0.9.12
1546 mapi */
1547 mapi public function buildASTGotoStatement($image)
1548 mapi {
1549 mapi return $this->_buildASTNodeInstance('ASTGotoStatement', $image);
1550 mapi }
1551 mapi
1552 mapi /**
1553 mapi * Builds a new label-statement instance.
1554 mapi *
1555 mapi * @param string $image The source code image for this node.
1556 mapi *
1557 mapi * @return PHP_Depend_Code_ASTLabelStatement
1558 mapi * @since 0.9.12
1559 mapi */
1560 mapi public function buildASTLabelStatement($image)
1561 mapi {
1562 mapi return $this->_buildASTNodeInstance('ASTLabelStatement', $image);
1563 mapi }
1564 mapi
1565 mapi /**
1566 1151 mapi * Builds a new exit-statement instance.
1567 mapi *
1568 mapi * @param string $image The source code image for this node.
1569 mapi *
1570 1178 mapi * @return PHP_Depend_Code_ASTEchoStatement
1571 1151 mapi * @since 0.9.12
1572 mapi */
1573 1178 mapi public function buildASTEchoStatement($image)
1574 1151 mapi {
1575 1178 mapi return $this->_buildASTNodeInstance('ASTEchoStatement', $image);
1576 1151 mapi }
1577 mapi
1578 mapi /**
1579 12 mapi * Returns an iterator with all generated {@link PHP_Depend_Code_Package}
1580 mapi * objects.
1581 mapi *
1582 38 mapi * @return PHP_Depend_Code_NodeIterator
1583 12 mapi */
1584 1 mapi public function getIterator()
1585 mapi {
1586 mapi return $this->getPackages();
1587 mapi }
1588 537 mapi
1589 12 mapi /**
1590 mapi * Returns an iterator with all generated {@link PHP_Depend_Code_Package}
1591 mapi * objects.
1592 mapi *
1593 38 mapi * @return PHP_Depend_Code_NodeIterator
1594 12 mapi */
1595 1 mapi public function getPackages()
1596 mapi {
1597 1177 mapi if ($this->_preparedPackages === null) {
1598 mapi $this->_preparedPackages = $this->_getPreparedPackages();
1599 mapi }
1600 mapi return new PHP_Depend_Code_NodeIterator($this->_preparedPackages);
1601 mapi }
1602 mapi
1603 mapi /**
1604 mapi * Returns an iterator with all generated {@link PHP_Depend_Code_Package}
1605 mapi * objects.
1606 mapi *
1607 mapi * @return PHP_Depend_Code_NodeIterator
1608 mapi * @since 0.9.12
1609 mapi */
1610 mapi private function _getPreparedPackages()
1611 mapi {
1612 112 mapi // Create a package array copy
1613 857 mapi $packages = $this->_packages;
1614 537 mapi
1615 112 mapi // Remove default package if empty
1616 537 mapi if ($this->defaultPackage->getTypes()->count() === 0
1617 806 mapi && $this->defaultPackage->getFunctions()->count() === 0
1618 mapi ) {
1619 112 mapi unset($packages[self::DEFAULT_PACKAGE]);
1620 mapi }
1621 1177 mapi return $packages;
1622 1 mapi }
1623 537 mapi
1624 119 mapi /**
1625 857 mapi * Builds a new new interface instance.
1626 mapi *
1627 mapi * If there is an existing class instance for the given name, this method
1628 mapi * checks if this class is part of the default namespace. If this is the
1629 mapi * case this method will update all references to the new interface and it
1630 mapi * removes the class instance. Otherwise it creates new interface instance.
1631 mapi *
1632 mapi * Where possible you should give a qualified interface name, that is
1633 mapi * prefixed with the package identifier.
1634 mapi *
1635 mapi * <code>
1636 mapi * $builder->buildInterface('php::depend::Parser');
1637 mapi * </code>
1638 mapi *
1639 mapi * To determine the correct interface, this method implements the following
1640 mapi * algorithm.
1641 mapi *
1642 mapi * <ol>
1643 mapi * <li>Check for an exactly matching instance and reuse it.</li>
1644 mapi * <li>Check for a interface instance that belongs to the default package.
1645 mapi * If such an instance exists, reuse it and replace the default package
1646 mapi * with the newly given package information.</li>
1647 mapi * <li>Check that the requested interface is in the default package, if
1648 mapi * this is true, reuse the first interface instance and ignore the default
1649 mapi * package.
1650 mapi * </li>
1651 mapi * <li>Create a new instance for the specified package.</li>
1652 mapi * </ol>
1653 mapi *
1654 mapi * @param string $qualifiedName The full qualified interface name.
1655 mapi *
1656 mapi * @return PHP_Depend_Code_Interface
1657 mapi * @since 0.9.5
1658 mapi */
1659 858 mapi protected function buildInterfaceInternal($qualifiedName)
1660 857 mapi {
1661 mapi $this->_internal = true;
1662 986 mapi
1663 mapi $package = $this->buildPackage($this->extractPackageName($qualifiedName));
1664 mapi return $package->addType(
1665 mapi $this->buildInterface($qualifiedName)
1666 mapi );
1667 857 mapi }
1668 mapi
1669 mapi /**
1670 mapi * This method tries to find an interface instance matching for the given
1671 mapi * qualified name in all scopes already processed. It will return the best
1672 mapi * matching instance or <b>null</b> if no match exists.
1673 mapi *
1674 mapi * @param string $qualifiedName The qualified interface name.
1675 mapi *
1676 mapi * @return PHP_Depend_Code_Interface
1677 mapi * @since 0.9.5
1678 mapi */
1679 mapi protected function findInterface($qualifiedName)
1680 mapi {
1681 mapi $this->freeze();
1682 mapi
1683 mapi $interface = $this->findClassOrInterface(
1684 mapi $this->_frozenInterfaces,
1685 mapi $qualifiedName
1686 mapi );
1687 mapi
1688 mapi if ($interface === null) {
1689 mapi $interface = $this->findClassOrInterface(
1690 860 mapi $this->_interfaces,
1691 857 mapi $qualifiedName
1692 mapi );
1693 mapi }
1694 mapi return $interface;
1695 mapi }
1696 mapi
1697 mapi /**
1698 mapi * Builds a new class instance or reuses a previous created class.
1699 mapi *
1700 mapi * Where possible you should give a qualified class name, that is prefixed
1701 mapi * with the package identifier.
1702 mapi *
1703 mapi * <code>
1704 mapi * $builder->buildClass('php::depend::Parser');
1705 mapi * </code>
1706 mapi *
1707 mapi * To determine the correct class, this method implements the following
1708 mapi * algorithm.
1709 mapi *
1710 mapi * <ol>
1711 mapi * <li>Check for an exactly matching instance and reuse it.</li>
1712 mapi * <li>Check for a class instance that belongs to the default package. If
1713 mapi * such an instance exists, reuse it and replace the default package with
1714 mapi * the newly given package information.</li>
1715 mapi * <li>Check that the requested class is in the default package, if this
1716 mapi * is true, reuse the first class instance and ignore the default package.
1717 mapi * </li>
1718 mapi * <li>Create a new instance for the specified package.</li>
1719 mapi * </ol>
1720 mapi *
1721 mapi * @param string $qualifiedName The qualified class name.
1722 mapi *
1723 mapi * @return PHP_Depend_Code_Class
1724 mapi * @since 0.9.5
1725 mapi */
1726 mapi protected function buildClassInternal($qualifiedName)
1727 mapi {
1728 mapi $this->_internal = true;
1729 986 mapi
1730 mapi $package = $this->buildPackage($this->extractPackageName($qualifiedName));
1731 mapi return $package->addType(
1732 mapi $this->buildClass($qualifiedName)
1733 mapi );
1734 857 mapi }
1735 mapi
1736 mapi /**
1737 mapi * This method tries to find a class instance matching for the given
1738 mapi * qualified name in all scopes already processed. It will return the best
1739 mapi * matching instance or <b>null</b> if no match exists.
1740 mapi *
1741 mapi * @param string $qualifiedName The qualified class name.
1742 mapi *
1743 mapi * @return PHP_Depend_Code_Class
1744 mapi * @since 0.9.5
1745 mapi */
1746 mapi protected function findClass($qualifiedName)
1747 mapi {
1748 mapi $this->freeze();
1749 mapi
1750 mapi $class = $this->findClassOrInterface(
1751 mapi $this->_frozenClasses,
1752 mapi $qualifiedName
1753 mapi );
1754 mapi
1755 mapi if ($class === null) {
1756 860 mapi $class = $this->findClassOrInterface($this->_classes, $qualifiedName);
1757 857 mapi }
1758 mapi return $class;
1759 mapi }
1760 mapi
1761 mapi /**
1762 mapi * This method tries to find an interface or class instance matching for the
1763 mapi * given qualified name in all scopes already processed. It will return the
1764 mapi * best matching instance or <b>null</b> if no match exists.
1765 mapi *
1766 mapi * @param array $instances Map of already created instances.
1767 mapi * @param string $qualifiedName The qualified interface or class name.
1768 mapi *
1769 mapi * @return PHP_Depend_Code_AbstractClassOrInterface
1770 mapi * @since 0.9.5
1771 mapi */
1772 mapi protected function findClassOrInterface(array $instances, $qualifiedName) pdepend-warning
1773 mapi {
1774 mapi $classOrInterfaceName = $this->extractTypeName($qualifiedName);
1775 mapi $packageName = $this->extractPackageName($qualifiedName);
1776 mapi
1777 mapi $caseInsensitiveName = strtolower($classOrInterfaceName);
1778 mapi
1779 mapi if (!isset($instances[$caseInsensitiveName])) {
1780 mapi return null;
1781 mapi }
1782 mapi
1783 mapi // Check for exact match and return first matching instance
1784 mapi if (isset($instances[$caseInsensitiveName][$packageName])) {
1785 mapi return reset($instances[$caseInsensitiveName][$packageName]);
1786 mapi }
1787 mapi
1788 mapi if (!$this->isDefault($packageName)) {
1789 mapi return null;
1790 mapi }
1791 mapi
1792 mapi $classesOrInterfaces = reset($instances[$caseInsensitiveName]);
1793 mapi return reset($classesOrInterfaces);
1794 mapi }
1795 mapi
1796 mapi /**
1797 mapi * This method will freeze the actual builder state and create a second
1798 mapi * runtime scope.
1799 mapi *
1800 mapi * @return void
1801 mapi * @since 0.9.5
1802 mapi */
1803 mapi protected function freeze()
1804 mapi {
1805 mapi if ($this->_frozen === true) {
1806 mapi return;
1807 mapi }
1808 mapi
1809 mapi $this->_frozen = true;
1810 mapi
1811 986 mapi $this->_frozenClasses = $this->_copyTypesWithPackage($this->_classes);
1812 mapi $this->_frozenInterfaces = $this->_copyTypesWithPackage($this->_interfaces);
1813 mapi //$this->_frozenClasses = $this->_classes;
1814 mapi //$this->_frozenInterfaces = $this->_interfaces;
1815 857 mapi
1816 860 mapi $this->_classes = array();
1817 mapi $this->_interfaces = array();
1818 857 mapi }
1819 mapi
1820 mapi /**
1821 986 mapi * Creates a copy of the given input array, but skips all types that do not
1822 mapi * contain a parent package.
1823 mapi *
1824 mapi * @param array $originalTypes The original types created during the parsing
1825 mapi * process.
1826 mapi *
1827 mapi * @return array
1828 mapi */
1829 mapi private function _copyTypesWithPackage(array $originalTypes)
1830 mapi {
1831 mapi $copiedTypes = array();
1832 mapi foreach ($originalTypes as $typeName => $packages) {
1833 mapi foreach ($packages as $package => $types) {
1834 mapi foreach ($types as $index => $type) {
1835 mapi if (is_object($type->getPackage())) {
1836 mapi $copiedTypes[$typeName][$package][$index] = $type;
1837 mapi }
1838 mapi }
1839 mapi }
1840 mapi }
1841 mapi return $copiedTypes;
1842 mapi }
1843 mapi
1844 mapi /**
1845 860 mapi * This method will persist a class instance for later reuse.
1846 mapi *
1847 mapi * @param string $className The local class name.
1848 mapi * @param string $packageName The package name
1849 mapi * @param PHP_Depend_Code_Class $class The context class.
1850 mapi *
1851 mapi * @return void
1852 mapi * @@since 0.9.5
1853 mapi */
1854 mapi protected function storeClass(
1855 mapi $className, $packageName, PHP_Depend_Code_Class $class
1856 mapi ) {
1857 mapi $caseInsensitiveName = strtolower($className);
1858 mapi if (!isset($this->_classes[$caseInsensitiveName][$packageName])) {
1859 mapi $this->_classes[$caseInsensitiveName][$packageName] = array();
1860 mapi }