protected static function parseConstructor(\ReflectionClass $reflectionClass)
    {
        // Check if constructor is our common and well known __construct
        if (true === $reflectionClass->isInstantiable()) {
            $constructor = Doozr_Di_Constants::CONSTRUCTOR_METHOD;
        } else {
            // Only in other cases we need to parse ...
            $constructorCandidates = $reflectionClass->getMethods(ReflectionMethod::IS_STATIC);

            // Assume default singleton constructor method name
            $constructor = Doozr_Di_Constants::CONSTRUCTOR_METHOD_SINGLETON;

            $lastProcessedFileName = null;

            // iterate over static methods and check for instantiation
            foreach ($constructorCandidates as $constructorCandidate) {
                /* @var ReflectionMethod $constructorCandidate */
                $fileName = $constructorCandidate->getFileName();

                if ($lastProcessedFileName !== $fileName) {
                    $sourcecode            = file($fileName);
                    $lastProcessedFileName = $fileName;
                }

                // Start Extract method source
                $start            = $constructorCandidate->getStartLine() + 1;
                $end              = $constructorCandidate->getEndLine()   - 1;
                $methodSourcecode = '';

                // Concat sourcecode lines
                for ($i = $start; $i < $end; ++$i) {
                    $methodSourcecode .= $sourcecode[$i];
                }
                // End Extract method source

                // Check for instantiation code ... possibly the constructor
                if (
                    strpos(
                        $methodSourcecode,
                        'n'.'e'.'w'.' self('
                    ) ||
                    strpos(
                        $methodSourcecode,
                        'new '.$reflectionClass->getName().'('
                    )
                ) {
                    $constructor = $constructorCandidate->name;
                    break;
                }
            }
        }

        return $constructor;
    }
protected static function parseConstructor(\ReflectionClass $reflectionClass)
    {
        // Check if constructor is our common and well known __construct
        if (true === $reflectionClass->isInstantiable()) {
            $constructor = Doozr_Di_Constants::CONSTRUCTOR_METHOD;
        } else {
            // Only in other cases we need to parse ...
            $constructorCandidates = $reflectionClass->getMethods(ReflectionMethod::IS_STATIC);

            // Assume default singleton constructor method name
            $constructor = Doozr_Di_Constants::CONSTRUCTOR_METHOD_SINGLETON;

            $lastProcessedFileName = null;

            // iterate over static methods and check for instantiation
            foreach ($constructorCandidates as $constructorCandidate) {
                /* @var ReflectionMethod $constructorCandidate */
                $fileName = $constructorCandidate->getFileName();

                if ($lastProcessedFileName !== $fileName) {
                    $sourcecode            = file($fileName);
                    $lastProcessedFileName = $fileName;
                }

                // Start Extract method source
                $start            = $constructorCandidate->getStartLine() + 1;
                $end              = $constructorCandidate->getEndLine()   - 1;
                $methodSourcecode = '';

                // Concat sourcecode lines
                for ($i = $start; $i < $end; ++$i) {
                    $methodSourcecode .= $sourcecode[$i];
                }
                // End Extract method source

                // Check for instantiation code ... possibly the constructor
                if (
                    strpos(
                        $methodSourcecode,
                        'n'.'e'.'w'.' self('
                    ) ||
                    strpos(
                        $methodSourcecode,
                        'new '.$reflectionClass->getName().'('
                    )
                ) {
                    $constructor = $constructorCandidate->name;
                    break;
                }
            }
        }

        return $constructor;
    }
protected static function parseConstructor ( \ ReflectionClass $ reflectionClass ) { // Check if constructor is our common and well known __construct if ( true === $ reflectionClass -> isInstantiable ( ) ) { $ constructor = Doozr_Di_Constants :: CONSTRUCTOR_METHOD ; } else { // Only in other cases we need to parse ... $ constructorCandidates = $ reflectionClass -> getMethods ( ReflectionMethod :: IS_STATIC ) ; // Assume default singleton constructor method name $ constructor = Doozr_Di_Constants :: CONSTRUCTOR_METHOD_SINGLETON ; $ lastProcessedFileName = null ; // iterate over static methods and check for instantiation foreach ( $ constructorCandidates as $ constructorCandidate ) { /* @var ReflectionMethod $constructorCandidate */ $ fileName = $ constructorCandidate -> getFileName ( ) ; if ( $ lastProcessedFileName !== $ fileName ) { $ sourcecode = file ( $ fileName ) ; $ lastProcessedFileName = $ fileName ; } // Start Extract method source $ start = $ constructorCandidate -> getStartLine ( ) + 1 ; $ end = $ constructorCandidate -> getEndLine ( ) - 1 ; $ methodSourcecode = '' ; // Concat sourcecode lines for ( $ i = $ start ; $ i < $ end ; ++ $ i ) { $ methodSourcecode .= $ sourcecode [ $ i ] ; } // End Extract method source // Check for instantiation code ... possibly the constructor if ( strpos ( $ methodSourcecode , 'n' . 'e' . 'w' . ' self(' ) || strpos ( $ methodSourcecode , 'new ' . $ reflectionClass -> getName ( ) . '(' ) ) { $ constructor = $ constructorCandidate -> name ; break ; } } } return $ constructor ; }
Returns constructor of  a class by ReflectionClass instance.
No matter if singleton or default class.

@param ReflectionClass $reflectionClass A reflection class instance.

@author Benjamin Carl <opensource@clickalicious.de>

@return string Constructor parsed or detected

@static
Returns constructor of a class by ReflectionClass instance . No matter if singleton or default class .