!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache/2.2.22 (Debian). PHP/5.6.36 

uname -a: Linux h05.hvosting.ua 4.9.110-amd64 #3 SMP Sun Nov 4 16:27:09 UTC 2018 x86_64 

uid=1389(h33678) gid=1099(h33678) groups=1099(h33678),502(mgrsecure) 

Safe-mode: OFF (not secure)

/home/h33678/data/www/it-man.ztu.edu.ua/src/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/   drwxr-xr-x
Free 117.27 GB of 200.55 GB (58.47%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     ClassMirror.php (7.63 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

/*
 * This file is part of the Prophecy.
 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
 *     Marcello Duarte <marcello.duarte@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Prophecy\Doubler\Generator;

use 
Prophecy\Exception\InvalidArgumentException;
use 
Prophecy\Exception\Doubler\ClassMirrorException;
use 
ReflectionClass;
use 
ReflectionMethod;
use 
ReflectionParameter;

/**
 * Class mirror.
 * Core doubler class. Mirrors specific class and/or interfaces into class node tree.
 *
 * @author Konstantin Kudryashov <ever.zet@gmail.com>
 */
class ClassMirror
{
    private static 
$reflectableMethods = array(
        
'__construct',
        
'__destruct',
        
'__sleep',
        
'__wakeup',
        
'__toString',
        
'__call',
        
'__invoke'
    
);

    
/**
     * Reflects provided arguments into class node.
     *
     * @param ReflectionClass   $class
     * @param ReflectionClass[] $interfaces
     *
     * @return Node\ClassNode
     *
     * @throws \Prophecy\Exception\InvalidArgumentException
     */
    
public function reflect(ReflectionClass $class null, array $interfaces)
    {
        
$node = new Node\ClassNode;

        if (
null !== $class) {
            if (
true === $class->isInterface()) {
                throw new 
InvalidArgumentException(sprintf(
                    
"Could not reflect %s as a class, because it\n".
                    
"is interface - use the second argument instead.",
                    
$class->getName()
                ));
            }

            
$this->reflectClassToNode($class$node);
        }

        foreach (
$interfaces as $interface) {
            if (!
$interface instanceof ReflectionClass) {
                throw new 
InvalidArgumentException(sprintf(
                    
"[ReflectionClass \$interface1 [, ReflectionClass \$interface2]] array expected as\n".
                    
"a second argument to `ClassMirror::reflect(...)`, but got %s.",
                    
is_object($interface) ? get_class($interface).' class' gettype($interface)
                ));
            }
            if (
false === $interface->isInterface()) {
                throw new 
InvalidArgumentException(sprintf(
                    
"Could not reflect %s as an interface, because it\n".
                    
"is class - use the first argument instead.",
                    
$interface->getName()
                ));
            }

            
$this->reflectInterfaceToNode($interface$node);
        }

        
$node->addInterface('Prophecy\Doubler\Generator\ReflectionInterface');

        return 
$node;
    }

    private function 
reflectClassToNode(ReflectionClass $classNode\ClassNode $node)
    {
        if (
true === $class->isFinal()) {
            throw new 
ClassMirrorException(sprintf(
                
'Could not reflect class %s as it is marked final.'$class->getName()
            ), 
$class);
        }

        
$node->setParentClass($class->getName());

        foreach (
$class->getMethods(ReflectionMethod::IS_ABSTRACT) as $method) {
            if (
false === $method->isProtected()) {
                continue;
            }

            
$this->reflectMethodToNode($method$node);
        }

        foreach (
$class->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
            if (
=== strpos($method->getName(), '_')
                && !
in_array($method->getName(), self::$reflectableMethods)) {
                continue;
            }

            if (
true === $method->isFinal()) {
                
$node->addUnextendableMethod($method->getName());
                continue;
            }

            
$this->reflectMethodToNode($method$node);
        }
    }

    private function 
reflectInterfaceToNode(ReflectionClass $interfaceNode\ClassNode $node)
    {
        
$node->addInterface($interface->getName());

        foreach (
$interface->getMethods() as $method) {
            
$this->reflectMethodToNode($method$node);
        }
    }

    private function 
reflectMethodToNode(ReflectionMethod $methodNode\ClassNode $classNode)
    {
        
$node = new Node\MethodNode($method->getName());

        if (
true === $method->isProtected()) {
            
$node->setVisibility('protected');
        }

        if (
true === $method->isStatic()) {
            
$node->setStatic();
        }

        if (
true === $method->returnsReference()) {
            
$node->setReturnsReference();
        }

        if (
version_compare(PHP_VERSION'7.0''>=') && true === $method->hasReturnType()) {
            
$returnType = (string) $method->getReturnType();
            
$returnTypeLower strtolower($returnType);

            if (
'self' === $returnTypeLower) {
                
$returnType $method->getDeclaringClass()->getName();
            }
            if (
'parent' === $returnTypeLower) {
                
$returnType $method->getDeclaringClass()->getParentClass()->getName();
            }

            
$node->setReturnType($returnType);
        }

        if (
is_array($params $method->getParameters()) && count($params)) {
            foreach (
$params as $param) {
                
$this->reflectArgumentToNode($param$node);
            }
        }

        
$classNode->addMethod($node);
    }

    private function 
reflectArgumentToNode(ReflectionParameter $parameterNode\MethodNode $methodNode)
    {
        
$name $parameter->getName() == '...' '__dot_dot_dot__' $parameter->getName();
        
$node = new Node\ArgumentNode($name);

        
$node->setTypeHint($this->getTypeHint($parameter));

        if (
$this->isVariadic($parameter)) {
            
$node->setAsVariadic();
        }

        if (
$this->hasDefaultValue($parameter)) {
            
$node->setDefault($this->getDefaultValue($parameter));
        }

        if (
$parameter->isPassedByReference()) {
            
$node->setAsPassedByReference();
        }

        
$methodNode->addArgument($node);
    }

    private function 
hasDefaultValue(ReflectionParameter $parameter)
    {
        if (
$this->isVariadic($parameter)) {
            return 
false;
        }

        if (
$parameter->isDefaultValueAvailable()) {
            return 
true;
        }

        return 
$parameter->isOptional() || $this->isNullable($parameter);
    }

    private function 
getDefaultValue(ReflectionParameter $parameter)
    {
        if (!
$parameter->isDefaultValueAvailable()) {
            return 
null;
        }

        return 
$parameter->getDefaultValue();
    }

    private function 
getTypeHint(ReflectionParameter $parameter)
    {
        if (
null !== $className $this->getParameterClassName($parameter)) {
            return 
$className;
        }

        if (
true === $parameter->isArray()) {
            return 
'array';
        }

        if (
version_compare(PHP_VERSION'5.4''>=') && true === $parameter->isCallable()) {
            return 
'callable';
        }

        if (
version_compare(PHP_VERSION'7.0''>=') && true === $parameter->hasType()) {
            return (string) 
$parameter->getType();
        }

        return 
null;
    }

    private function 
isVariadic(ReflectionParameter $parameter)
    {
        return 
PHP_VERSION_ID >= 50600 && $parameter->isVariadic();
    }

    private function 
isNullable(ReflectionParameter $parameter)
    {
        return 
$parameter->allowsNull() && null !== $this->getTypeHint($parameter);
    }

    private function 
getParameterClassName(ReflectionParameter $parameter)
    {
        try {
            return 
$parameter->getClass() ? $parameter->getClass()->getName() : null;
        } catch (\
ReflectionException $e) {
            
preg_match('/\[\s\<\w+?>\s([\w,\\\]+)/s'$parameter$matches);

            return isset(
$matches[1]) ? $matches[1] : null;
        }
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by PinoyWH1Z | C99Shell Github | Generation time: 0.041 ]--