Ejemplo n.º 1
0
 /**
  * Constructs a new ezcReflectionFunction object
  *
  * Throws an Exception in case the given function does not exist
  * @param string|ReflectionFunction $function
  *        Name or ReflectionFunction object of the function to be reflected
  */
 public function __construct($function)
 {
     if (!$function instanceof ReflectionFunction) {
         parent::__construct($function);
     }
     $this->reflectionSource = $function;
     $this->docParser = ezcReflection::getDocCommentParser();
     $this->docParser->parse($this->getDocComment());
 }
Ejemplo n.º 2
0
 /**
  * Constructs a new ezcReflectionProperty object
  *
  * Throws an Exception in case the given property does not exist
  * @param string|object|ReflectionProperty $class
  *        Name, instance of the property's class
  *        or ReflectionProperty object of the property
  * @param string $name
  *        Name of the property to be reflected.
  *        Can be null or will be ignored if a ReflectionProperty object is
  *        given as first parameter.
  */
 public function __construct($class, $name = null)
 {
     if (!$class instanceof ReflectionProperty) {
         parent::__construct($class, $name);
     }
     $this->reflectionSource = $class;
     $this->docParser = ezcReflection::getDocCommentParser();
     $this->docParser->parse($this->getDocComment());
 }
Ejemplo n.º 3
0
 /**
  * Constructs a new ezcReflectionClass object.
  *
  * @param string|object|ReflectionClass $argument
  *        Name, instance or ReflectionClass object of the class to be
  *        reflected
  * @throws ReflectionException if the specified class doesn't exist
  */
 public function __construct($argument)
 {
     if (!$argument instanceof parent) {
         parent::__construct($argument);
     }
     $this->reflectionSource = $argument;
     // TODO: Parse comment on demand to save CPU time and memory
     $this->docParser = ezcReflection::getDocCommentParser();
     $this->docParser->parse($this->getDocComment());
 }
Ejemplo n.º 4
0
 /**
  * Constructs an new ezcReflectionMethod
  *
  * Usage Examples:
  * <code>
  * new ezcReflectionMethod( 'SomeClass',                        'someMethod' );
  * new ezcReflectionMethod( new ReflectionClass( 'SomeClass' ), 'someMethod' );
  * new ezcReflectionMethod( 'SomeClass',                        new ReflectionMethod( 'SomeClass', 'someMethod' ) );
  * new ezcReflectionMethod( new ReflectionClass( 'SomeClass' ), new ReflectionMethod( 'SomeClass', 'someMethod' ) );
  * </code>
  * 
  * The following way of creating an ezcReflectionMethod results in the
  * current class being the declaring class, i.e., isInherited() and
  * isIntroduced() may not return the expected results:
  * <code>
  * new ezcReflectionMethod( new ReflectionMethod( 'SomeClass', 'someMethod' ) );
  * </code>
  * 
  * @param string|ReflectionClass|ReflectionMethod $classOrSource
  *        Name of class, ReflectionClass, or ReflectionMethod of the method
  *        to be reflected
  * @param string|ReflectionMethod $nameOrSource
  *        Name or ReflectionMethod instance of the method to be reflected
  *        Optional if $classOrSource is an instance of ReflectionMethod
  */
 public function __construct($classOrSource, $nameOrSource = null)
 {
     if ($nameOrSource instanceof parent) {
         $this->reflectionSource = $nameOrSource;
         if ($classOrSource instanceof ReflectionClass) {
             $this->currentClass = $classOrSource;
         } else {
             $this->currentClass = new ReflectionClass((string) $classOrSource);
         }
     } elseif ($classOrSource instanceof parent) {
         $this->reflectionSource = $classOrSource;
         $this->currentClass = new ReflectionClass($this->reflectionSource->class);
     } elseif ($classOrSource instanceof ReflectionClass) {
         parent::__construct($classOrSource->getName(), $nameOrSource);
         $this->currentClass = $classOrSource;
     } else {
         parent::__construct($classOrSource, $nameOrSource);
         $this->currentClass = new ReflectionClass((string) $classOrSource);
     }
     $this->docParser = ezcReflection::getDocCommentParser();
     $this->docParser->parse($this->getDocComment());
 }
Ejemplo n.º 5
0
 public function testSetDocCommentParser()
 {
     $docCommentParser = new ezcReflectionDocCommentParserImpl();
     ezcReflection::setDocCommentParser($docCommentParser);
     self::assertEquals($docCommentParser, ezcReflection::getDocCommentParser());
 }
Ejemplo n.º 6
0
 public function testGetLongDescription()
 {
     $class = new ReflectionClass('TestWebservice');
     $doc = $class->getDocComment();
     $parser = ezcReflection::getDocCommentParser();
     $parser->parse($doc);
     $desc = $parser->getLongDescription();
     $expected = "This is the long description with may be additional infos and much more lines\nof text.\n\nEmpty lines are valid, too.\n\nfoo bar";
     self::assertEquals($expected, $desc);
 }
Ejemplo n.º 7
0
    public function testGetLongDescription()
    {
        $class = new ReflectionClass('TestWebservice');
        $doc = $class->getDocComment();
        $parser = ezcReflection::getDocCommentParser();
        $parser->parse($doc);
        $desc = $parser->getLongDescription();
        $expected = <<<ENDDATA
This is the long description with may be additional infos and much more lines
of text.

Empty lines are valid, too.

foo bar

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
ENDDATA;
        self::assertEquals($expected, $desc);
    }