Process classes.

@param array $classes
@param string $file
434438
public function processFileClasses(array $classes, string $file)
    {
        foreach ($classes as $name => $class) {
            if (is_null($class['docblock'])) {
                $this->errors[] = [
                    'type' => 'class',
                    'file' => $file,
                    'class' => $name,
                    'line' => $class['line'],
                ];
            }
        }
    }
562782
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        // In case we have more than one class/interface/trait
        // per file, we want to reset at the start of each.
        if ($tokens[$stackPtr]['code'] !== T_FUNCTION) {
            $this->lastMethodName = null;
            return;
        }

        // We only care about class methods, so ignore global functions (level 0).
        if ($tokens[$stackPtr]['level'] === 1) {
            $methodName = $phpcsFile->getDeclarationName($stackPtr);
            if ($this->lastMethodName !== null && $methodName <= $this->lastMethodName) {
                $phpcsFile->addError('Method "%s" is not in alphabetical order.', $stackPtr, 'OutOfOrder', [$methodName]);
            }

            $this->lastMethodName = $methodName;
        }

    }
412566
public function whitelist($classes)
	{
		if ( ! is_array($classes))
		{
			$classes = func_get_args();
		}

		$this->whitelist = array_unique(array_merge($this->whitelist, $classes));
	}
1047321
public static function loadClassFile($file) {
		$before = array_merge(get_declared_classes(), get_declared_interfaces());
		require_once $file;
		$after = array_merge(get_declared_classes(), get_declared_interfaces());

		$diff = array_diff($after, $before);

		#class was maybe already loaded
		if(!$diff) {
			foreach(array_merge(get_declared_classes(), get_declared_interfaces()) as $class) {
				$reflector = new \ReflectionClass($class);
				if($reflector->getFileName() == realpath($file)) {
					$result = $class;
					break;
				}
			}
			if(!isset($result))
				throw new \Exception('File '.$file.' does not contain any class.');
		}
		else
			$result = array_values($diff)[count($diff)-1];

		return $result;
	}
585391
private function convertFileToClass($path, $file, $prefix)
    {
        $candidates = array(
            // namespaced class
            $namespacedClass = str_replace(array($path.DIRECTORY_SEPARATOR, '.php', '/'), array('', '', '\\'), $file),
            // namespaced class (with target dir)
            $prefix.$namespacedClass,
            // namespaced class (with target dir and separator)
            $prefix.'\\'.$namespacedClass,
            // PEAR class
            str_replace('\\', '_', $namespacedClass),
            // PEAR class (with target dir)
            str_replace('\\', '_', $prefix.$namespacedClass),
            // PEAR class (with target dir and separator)
            str_replace('\\', '_', $prefix.'\\'.$namespacedClass),
        );

        if ($prefix) {
            $candidates = array_filter($candidates, function ($candidate) use ($prefix) { return 0 === strpos($candidate, $prefix); });
        }

        // We cannot use the autoloader here as most of them use require; but if the class
        // is not found, the new autoloader call will require the file again leading to a
        // "cannot redeclare class" error.
        foreach ($candidates as $candidate) {
            if ($this->classExists($candidate)) {
                return $candidate;
            }
        }

        require_once $file;

        foreach ($candidates as $candidate) {
            if ($this->classExists($candidate)) {
                return $candidate;
            }
        }
    }
1053909
private void processFiles(File[] files) {
        phaseOutput(format("=== %s ===", getApplicationName()));
        phaseOutput(format("Compiling %d BEL Document(s)", files.length));

        boolean pedantic = withPedantic();
        boolean verbose = withVerbose();

        int validated = 0;

        for (int i = 1; i <= files.length; i++) {
            File file = files[i - 1];

            if (verbose) {
                phaseOutput("Compiling " + i + " of " + files.length
                        + " BEL Document(s)");
            }

            // validate document
            Document document = stage1(file);
            if (document == null) {
                if (pedantic) {
                    bail(VALIDATION_FAILURE);
                }
                continue;
            }
            validated++;

            // run stages 2 - 7
            runCommonStages(pedantic, document);
        }

        if (validated == 0) {
            bail(NO_VALID_DOCUMENTS);
        }
    }
535282
protected function load(string $file): void
	{
		$this->configuration[$file] = $this->loader->load($file, $this->environment);
	}
38580
public function init($file)
	{
		try {
			
			$this->load($file);

		} catch (Exceptions\FileNotExists $e) {

			$this->create($file);
		}
	}
962304
public function updateCMSTreeClasses(&$classes)
    {
        if ($this->owner->getField('Disabled')) {
            $classes .= ' is-disabled';
        } elseif ($this->owner->getField('Cached')) {
            $classes .= ' is-cached';
        }
    }
467135
public function removeClass(?string $class): void
  {
    // If class is empty or no classes are set return immediately.
    if ($class===null || $class==='' || !isset($this->attributes['class'])) return;

    // Remove the class from the list of classes.
    $this->attributes['class'] = implode(' ', array_diff(explode(' ', $this->attributes['class']), [$class]));
  }
712899
public function init($file, array $data = null)
    {
        if ($data === null) {
            $data = $this->setJsonDefaults([]);
        }
        $this->app['filesystem']->write($file, Json::dump($data, Json::HUMAN));
    }
179605
public function check(\SplFileInfo $file, Tokens $tokens)
    {
        $classes = array_keys($tokens->findGivenKind(T_CLASS));
        $numClasses = count($classes);

        for ($i = 0; $i < $numClasses; ++$i) {
            $index = $classes[$i];

            // figure out where the classy starts
            $classStart = $tokens->getNextTokenOfKind($index, array('{'));

            // figure out where the classy ends
            $classEnd = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $classStart);

            $this->checkMethods($tokens, $classStart, $classEnd);
        }
    }
508432
public function addClassFilter($classes)
    {
        if (is_array($classes) && count($classes) !== 0) {
            $filters = array();
            foreach ($classes as $class) {
                class_exists($class);
                $filters[] = 'cc INSTANCE OF \''.  $class .'\'';
            }

            $filter = implode(' OR ', $filters);

            $this->andWhere($filter);
        }
    }
1117512
public static function apply($file, $filters)
    {
        if( ! empty($filters) )
        { 
            $gd = self::getSingletonGDClass();

            $gd->canvas($file);
            
            foreach( $filters as $filter )
            {
                $method     = $filter[0];
                $parameters = $filter[1] ?? [];

                $gd->$method(...(array) $parameters);
            }
    
            $gd->generate(MimeTypeFinder::get($file), $file);
        }
    }
728055
public boolean processClassFile(String fileName) {
        Path path = Paths.get(fileName);
        try {
            ClassFile cf = ClassFile.read(path);
            processClass(cf);
            return true;
        } catch (NoSuchFileException nsfe) {
            errorNoFile(fileName);
        } catch (IOException | ConstantPoolException ex) {
            errorException(ex);
        }
        return false;
    }
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);
        }
    }
246744
protected function processNewFiles(array $files)
    {
        foreach ($files as $file) {
            if (!file_exists($file)) {
                //This is bad
                throw new Exception('Cant find File: '.$file);
            }
            include $file;
            
            if (!isset($arrUpdate)) {
                throw new Exception('Array $arrUpdate does not exist in '.$file);
            }
            
            try {
                $this->processArray($arrUpdate);
                $this->addFileToProcessedList($file);
            } catch (Exception $ex) {
                echo $ex->getMessage();
            }
            
            unset($arrUpdate);
        }
    }