Visits a class node.

@param Node\Stmt\Class_ $class Represents a class in the namespace

@return void
508611
protected function visitClass(Node\Stmt\Class_ $class)
    {
        $this->testClass = false;

        $parent = $class->extends;

        if (empty($parent)) {
            // No ancestry
            // Treat the class as a test case class if the name
            // of the parent class ends with "TestCase".

            if (substr($class->name, -8) == 'TestCase') {
                $this->testClass = true;
            }
        } else {
            // Ancestry
            // Treat the class as a test case class if the name
            // of the parent class equals to "PHPUnit_Framework_TestCase".

            if ((string) $parent === 'PHPUnit_Framework_TestCase') {
                $this->testClass = true;
            }
        }
    }
8757
protected function classExists(string $class, string $message): void
    {
        if (!class_exists($class)) {
            $this->log($message, Project::MSG_ERR);
            throw new BuildException($message);
        }
    }
878604
public function load_class( $org_class ) {
		$this->lookup_class = $org_class;
		if ( $this->is_valid_lookup() ) {
			$filenames = array();
			$folders   = array();
			$is_loaded = false;

			$this->debug( 'Class Requested : ' . $org_class );
			$this->debug( 'Checking in Mapping Array' );

			if ( isset( $this->mapping[ $org_class ] ) && ( file_exists( $this->mapping[ $org_class ] ) || file_exists( $this->base_path . $this->mapping[ $org_class ] ) ) ) {
				$is_loaded = $this->load_file( $this->mapping[ $org_class ], $org_class );

				if ( false === $is_loaded ) {
					$is_loaded = $this->load_file( $this->base_path . $this->mapping[ $org_class ], $org_class );
				}
			}

			if ( false === $is_loaded ) {
				$filenames = $this->get_file_name( $org_class );
				$folders   = $this->get_folder_name( $org_class );
				$this->debug( 'Not Found In Remap Array' );
			}

			if ( false === $is_loaded ) {
				$this->debug( '' );
				$this->debug( 'Checking Using Requested Class Namespace' );
				if ( is_array( $filenames ) && is_array( $folders ) ) {
					foreach ( $folders as $folder ) {
						foreach ( $filenames as $file ) {
							$is_loaded = $this->load_file( $this->trailingslashit( $this->base_path . $folder ) . $file, $org_class );
							if ( $is_loaded ) {
								$this->debug( 'Class Found' );
								break;
							} else {
								$this->debug( 'File Not Found In : ' . $this->trailingslashit( $this->base_path . $folder ) . $file );
							}
						}
						if ( $is_loaded ) {
							break;
						}
					}
				}
			}

			if ( false === $is_loaded ) {
				$this->debug( '' );
				$this->debug( 'Checking In All subfolders Inside Base Path' );
				$folders = $this->get_folders( $this->base_path );
				if( is_array( $folders ) ){
					foreach ( $folders as $folder ) {
						foreach ( $filenames as $file ) {
							$is_loaded = $this->load_file( $this->trailingslashit( $folder ) . $file, $org_class );
							if ( $is_loaded ) {
								$this->debug( 'Class Found' );
								break;
							} else {
								$this->debug( 'File Not Found In : ' . $this->trailingslashit( $folder ) . $file );
							}
						}
					}
				}
			}

			$this->debug( '' );
		}

		$this->lookup_class = false;
	}
324865
public function addClass($class) {
        $this->setVariable(self::VIEW_MODEL_CLASS, $this->addValue($this->getVariable(self::VIEW_MODEL_CLASS), $class));
    }
1033013
public function afterCompile(Nette\PhpGenerator\ClassType $class)
	{
		$initialize = $class->getMethod('initialize');
		$builder = $this->getContainerBuilder();

		if ($builder->parameters['debugMode'] && $builder->hasDefinition(self::TRACY_PANEL)) {
			$initialize->addBody($builder->formatPhp('?;', [
				new Nette\DI\Statement('@Tracy\Bar::addPanel', ['@' . self::TRACY_PANEL, self::TRACY_PANEL]),
			]));
		}
	}
1328490
protected function findOrCreateMethod(Class_ $class, $name)
    {
        $foundMethods = array_filter(
            $class->getMethods(),
            function (ClassMethod $method) use ($name) {
                return $name === $method->name;
            }
        );

        $method = reset($foundMethods);

        if (!$method) {
            $class->stmts[] = $method = new ClassMethod($name);
        }

        return $method;
    }
721195
public function afterCompile(ClassType $class): void
	{
		$config = $this->config;

		if ($config->debug === true) {
			$initialize = $class->getMethod('initialize');
			$initialize->addBody(
				'$this->getService(?)->addPanel($this->getService(?));',
				['tracy.bar', $this->prefix('panel')]
			);
		}
	}
1359299
public function autoload($class) {
        $classKey = strtolower($class);

        if (isset($this->classes[$classKey])) {
            list($_, $path) = $this->classes[$classKey];
            include_once $path;
        }
    }
822585
private void visitClass(final NodeTraversal t, final Node classNode, final Node parent) {
    checkClassReassignment(classNode);
    // Collect Metadata
    ClassDeclarationMetadata metadata =
        ClassDeclarationMetadata.create(classNode, parent, astFactory);

    if (metadata == null) {
      throw new IllegalStateException(
          "Can only convert classes that are declarations or the right hand"
          + " side of a simple assignment: " + classNode);
    }
    if (metadata.hasSuperClass() && !metadata.getSuperClassNameNode().isQualifiedName()) {
      compiler.report(JSError.make(metadata.getSuperClassNameNode(), DYNAMIC_EXTENDS_TYPE));
      return;
    }

    Preconditions.checkState(
        NodeUtil.isStatement(metadata.getInsertionPoint().getNode()),
        "insertion point must be a statement: %s",
        metadata.getInsertionPoint().getNode());

    Node constructor = null;
    JSDocInfo ctorJSDocInfo = null;
    // Process all members of the class
    Node classMembers = classNode.getLastChild();
    for (Node member : classMembers.children()) {
      if ((member.isComputedProp()
              && (member.getBooleanProp(Node.COMPUTED_PROP_GETTER)
                  || member.getBooleanProp(Node.COMPUTED_PROP_SETTER)))
          || (member.isGetterDef() || member.isSetterDef())) {
        visitNonMethodMember(member, metadata);
      } else if (NodeUtil.isEs6ConstructorMemberFunctionDef(member)) {
        ctorJSDocInfo = member.getJSDocInfo();
        constructor = member.getFirstChild().detach().setJSType(classNode.getJSType());
        constructor.setJSTypeBeforeCast(classNode.getJSTypeBeforeCast());
        if (!metadata.isAnonymous()) {
          // Turns class Foo { constructor: function() {} } into function Foo() {},
          // i.e. attaches the name to the ctor function.
          constructor.replaceChild(
              constructor.getFirstChild(), metadata.getClassNameNode().cloneNode());
        }
      } else if (member.isEmpty()) {
        // Do nothing.
      } else {
        Preconditions.checkState(member.isMemberFunctionDef() || member.isComputedProp(),
            "Unexpected class member:", member);
        Preconditions.checkState(!member.getBooleanProp(Node.COMPUTED_PROP_VARIABLE),
            "Member variables should have been transpiled earlier:", member);
        visitMethod(member, metadata);
      }
    }
    checkNotNull(
        constructor,
        "Es6RewriteClasses expects all classes to have (possibly synthetic) constructors");

    if (metadata.getDefinePropertiesObjForPrototype().hasChildren()) {
      compiler.ensureLibraryInjected("util/global", false);
      Node definePropsCall =
          IR.exprResult(
              astFactory.createCall(
                  createObjectDotDefineProperties(t.getScope()),
                  metadata.getClassPrototypeNode().cloneTree(),
                  metadata.getDefinePropertiesObjForPrototype()));
      definePropsCall.useSourceInfoIfMissingFromForTree(classNode);
      metadata.insertNodeAndAdvance(definePropsCall);
    }

    if (metadata.getDefinePropertiesObjForClass().hasChildren()) {
      compiler.ensureLibraryInjected("util/global", false);
      Node definePropsCall =
          IR.exprResult(
              astFactory.createCall(
                  createObjectDotDefineProperties(t.getScope()),
                  metadata.getFullClassNameNode().cloneTree(),
                  metadata.getDefinePropertiesObjForClass()));
      definePropsCall.useSourceInfoIfMissingFromForTree(classNode);
      metadata.insertNodeAndAdvance(definePropsCall);
    }
    JSDocInfo classJSDoc = NodeUtil.getBestJSDocInfo(classNode);
    JSDocInfoBuilder newInfo = JSDocInfoBuilder.maybeCopyFrom(classJSDoc);

    newInfo.recordConstructor();

    Node enclosingStatement = NodeUtil.getEnclosingStatement(classNode);
    if (metadata.hasSuperClass()) {
      String superClassString = metadata.getSuperClassNameNode().getQualifiedName();
      if (newInfo.isInterfaceRecorded()) {
        newInfo.recordExtendedInterface(
            new JSTypeExpression(
                new Node(Token.BANG, IR.string(superClassString)),
                metadata.getSuperClassNameNode().getSourceFileName()));
      } else {
        newInfo.recordBaseType(
            new JSTypeExpression(
                new Node(Token.BANG, IR.string(superClassString)),
                metadata.getSuperClassNameNode().getSourceFileName()));
      }
      if (!classNode.isFromExterns()) {
        compiler.ensureLibraryInjected("es6/util/inherits", false);
        Node inheritsCall =
            IR.exprResult(
                    astFactory.createCall(
                        astFactory.createQName(t.getScope(), "$jscomp.inherits"),
                        metadata.getFullClassNameNode().cloneTree(),
                        metadata.getSuperClassNameNode().cloneTree()))
                .useSourceInfoIfMissingFromForTree(metadata.getSuperClassNameNode());
        enclosingStatement.getParent().addChildAfter(inheritsCall, enclosingStatement);
      }
    }

    addTypeDeclarations(t.getScope(), metadata, enclosingStatement);

    updateClassJsDoc(ctorJSDocInfo, newInfo);

    if (NodeUtil.isStatement(classNode)) {
      constructor.getFirstChild().setString("");
      Node ctorVar = IR.let(metadata.getClassNameNode().cloneNode(), constructor);
      ctorVar.useSourceInfoIfMissingFromForTree(classNode);
      parent.replaceChild(classNode, ctorVar);
      NodeUtil.addFeatureToScript(t.getCurrentScript(), Feature.LET_DECLARATIONS);
    } else {
      parent.replaceChild(classNode, constructor);
    }
    NodeUtil.markFunctionsDeleted(classNode, compiler);

    if (NodeUtil.isStatement(constructor)) {
      constructor.setJSDocInfo(newInfo.build());
    } else if (parent.isName()) {
      // The constructor function is the RHS of a var statement.
      // Add the JSDoc to the VAR node.
      Node var = parent.getParent();
      var.setJSDocInfo(newInfo.build());
    } else if (constructor.getParent().isName()) {
      // Is a newly created VAR node.
      Node var = constructor.getGrandparent();
      var.setJSDocInfo(newInfo.build());
    } else if (parent.isAssign()) {
      // The constructor function is the RHS of an assignment.
      // Add the JSDoc to the ASSIGN node.
      parent.setJSDocInfo(newInfo.build());
    } else {
      throw new IllegalStateException("Unexpected parent node " + parent);
    }

    FunctionType classType = JSType.toMaybeFunctionType(classNode.getJSType());
    if (classType != null) {
      // classNode is no longer in the AST, so we need to update the reference to it that is
      // stored in the class's type, if any.
      classType.setSource(constructor);
    }

    constructor.putBooleanProp(Node.IS_ES6_CLASS, true);
    t.reportCodeChange();
  }
582052
private static function load($class_name)
    {
        $class_name = trim($class_name, '\\');

        foreach (self::$_namespace_list as $namespace => $path_list) {
            $pattern = '/^' . str_replace('\\', '\\\\', $namespace) . '/';

            if (!preg_match($pattern, $class_name)) {
                continue;
            }

            $class_name = str_replace($namespace, '', trim($class_name, '\\'));
            $class_name = str_replace('\\', '/', trim($class_name, '\\'));

            foreach ($path_list as $path) {
                if (!file_exists("{$path}/{$class_name}.php")) {
                    continue;
                }

                require "{$path}/{$class_name}.php";

                return true;
            }
        }

        throw new Exception("Class: {$class_name} is not found.");
    }
75656
public function enterNode(Node $node)
    {
        if ($node instanceof Class_) {
            $this->class = $node;
            $this->abstractMethods = [];
        } elseif ($node instanceof ClassMethod) {
            if ($node->isAbstract()) {
                $name = \sprintf('%s::%s', $this->class->name, $node->name);
                $this->abstractMethods[] = $name;

                if ($node->stmts !== null) {
                    $msg = \sprintf('Abstract function %s cannot contain body', $name);
                    throw new FatalErrorException($msg, 0, E_ERROR, null, $node->getLine());
                }
            }
        }
    }
1357631
public function call($class)
    {
        $this->resolve($class)->run();

        if (isset($this->command)) {
            $this->command->getOutput()->writeln("<info>Seeded:</info> $class");
        }
    }
1148425
public function process(File $phpcs_file, $stack_ptr): void
    {
        // only check for use statements that are before the first class declaration
        // classes can have use statements for traits, for which we are not interested in this sniff
        $first_class_occurrence = $phpcs_file->findPrevious([T_CLASS, T_TRAIT], $stack_ptr);
        if ($first_class_occurrence > 0 && $stack_ptr > $first_class_occurrence) {
            return;
        }

        $tokens = $phpcs_file->getTokens();

        // Reach the end of the current statement
        $stack_ptr = $phpcs_file->findNext([T_SEMICOLON], $stack_ptr + 1);
        $end_stmt  = $stack_ptr;

        // if there is another 'use' statement, it should be at $stack_ptr + 1
        $next_use   = $phpcs_file->findNext([T_USE], $stack_ptr + 1);
        $next_class = $phpcs_file->findNext([T_CLASS, T_TRAIT], $stack_ptr + 1);

        //There is a class and the next use statement is after the class definition. skipp it
        if ($next_class && $next_use > $next_class) {
            return;
        }

        //Loop from the end of the use statement (;) until the next use statement
        for ($i = ($end_stmt + 1); $i <= $next_use; $i++) {
            //the current token ($i) contains an end of line
            //And it's on the next line than the end of the use statement
            if ($tokens[$i]['line'] === $tokens[$end_stmt]['line']
                || false === stripos($tokens[$i]['content'], "\n")
            ) {
                continue;
            }

            $this->checkForNewlineOrComments($phpcs_file, $i);
        }
    }
878307
public function load_class($class_name) {
		foreach ($this->namespaces as $namespace => $namespace_path) {
			$file_path = str_replace(' ', '/', ucwords(str_replace('_', ' ', str_replace('\\', ' ', strtolower($class_name))))) . '.php';
			$path = $namespace_path . '/' . substr($file_path, strpos('/', $file_path));
			try {
				$this->require_file($path);

				if (class_exists($class_name, false)) {
					class_parents($class_name, true);
					return true;
				}
			} catch (\Exception $e) { }
		}

		foreach ($this->include_paths as $include_path) {
			$file_path = str_replace(' ', '/', ucwords(str_replace('_', ' ', str_replace('\\', ' ', strtolower(str_replace($include_path['class_prefix'], '', $class_name)))))) . '.php';

			try {
				$path = $include_path['include_path'] . '/' . $file_path;
				$this->require_file($path);

				if (class_exists($class_name, false)) {
					class_parents($class_name, true);
					return true;
				}
			} catch (\Exception $e) { }

			/**
			 * If the file is not found, try with all lower case. This should be
			 * improved with PSR loading techniques
			 */
			try {
				$path = strtolower($include_path['include_path'] . '/' . $file_path);
				$this->require_file($path);

				if (class_exists($class_name, false)) {
					class_parents($class_name, true);
					return true;
				}
			} catch (\Exception $e) { }

		}
	}
715474
public function loadClass($class)
    {
        if (0 === strpos($class, 'Admingenerated')) {
            $file_path = $this->base_path.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php';

            if (!file_exists($file_path)) {
                $this->generateEmptyController($class);
            }

            if (file_exists($file_path)) {
                require $file_path;
            }
        }
    }
740696
protected function setClass($class): void
    {
        // @todo fix logic about storing the classname
        $this->className = $class;
        if (is_object($class)) {
            $this->className = get_class($class);
        }
        $this->class = new ReflectionClass($class);
    }
894040
public void visitClass(ClassNode classNode) {
        try {
            this.classNode = classNode;
            this.internalClassName = BytecodeHelper.getClassInternalName(classNode);

            //System.out.println("Generating class: " + classNode.getName());

            this.internalBaseClassName = BytecodeHelper.getClassInternalName(classNode.getSuperClass());

            cv.visit(
                    Opcodes.V1_3,
                    classNode.getModifiers(),
                    internalClassName,
                    (String) null,
                    internalBaseClassName,
                    BytecodeHelper.getClassInternalNames(classNode.getInterfaces())
            );

            classNode.visitContents(this);

            for (Iterator iter = innerClasses.iterator(); iter.hasNext();) {
                ClassNode innerClass = (ClassNode) iter.next();
                ClassNode innerClassType = innerClass;
                String innerClassInternalName = BytecodeHelper.getClassInternalName(innerClassType);
                String outerClassName = internalClassName; // default for inner classes
                MethodNode enclosingMethod = innerClass.getEnclosingMethod();
                if (enclosingMethod != null) {
                    // local inner classes do not specify the outer class name
                    outerClassName = null;
                }
                cv.visitInnerClass(
                        innerClassInternalName,
                        outerClassName,
                        innerClassType.getName(),
                        innerClass.getModifiers());
            }
            cv.visitEnd();
        }
        catch (GroovyRuntimeException e) {
            e.setModule(classNode.getModule());
            throw e;
        }
    }