Analyze the classes in the application codebase.
186266
private void analyzeApplication() throws InterruptedException {
        int passCount = 0;
        Profiler profiler = bugReporter.getProjectStats().getProfiler();
        profiler.start(this.getClass());
        AnalysisContext.currentXFactory().canonicalizeAll();
        try {
            boolean multiplePasses = executionPlan.getNumPasses() > 1;
            if (executionPlan.getNumPasses() == 0) {
                throw new AssertionError("no analysis passes");
            }
            int[] classesPerPass = new int[executionPlan.getNumPasses()];
            classesPerPass[0] = referencedClassSet.size();
            for (int i = 0; i < classesPerPass.length; i++) {
                classesPerPass[i] = i == 0 ? referencedClassSet.size() : appClassList.size();
            }
            progressReporter.predictPassCount(classesPerPass);
            XFactory factory = AnalysisContext.currentXFactory();
            Collection<ClassDescriptor> badClasses = new LinkedList<>();
            for (ClassDescriptor desc : referencedClassSet) {
                try {
                    XClass info = Global.getAnalysisCache().getClassAnalysis(XClass.class, desc);
                    factory.intern(info);
                } catch (CheckedAnalysisException e) {
                    AnalysisContext.logError("Couldn't get class info for " + desc, e);
                    badClasses.add(desc);
                } catch (RuntimeException e) {
                    AnalysisContext.logError("Couldn't get class info for " + desc, e);
                    badClasses.add(desc);
                }
            }
            if (!badClasses.isEmpty()) {
                referencedClassSet = new LinkedHashSet<>(referencedClassSet);
                referencedClassSet.removeAll(badClasses);
            }

            long startTime = System.currentTimeMillis();
            bugReporter.getProjectStats().setReferencedClasses(referencedClassSet.size());
            for (Iterator<AnalysisPass> passIterator = executionPlan.passIterator(); passIterator.hasNext();) {
                AnalysisPass pass = passIterator.next();
                // The first pass is generally a non-reporting pass which
                // gathers information about referenced classes.
                boolean isNonReportingFirstPass = multiplePasses && passCount == 0;

                // Instantiate the detectors
                Detector2[] detectorList = pass.instantiateDetector2sInPass(bugReporter);

                // If there are multiple passes, then on the first pass,
                // we apply detectors to all classes referenced by the
                // application classes.
                // On subsequent passes, we apply detector only to application
                // classes.
                Collection<ClassDescriptor> classCollection = (isNonReportingFirstPass) ? referencedClassSet : appClassList;
                AnalysisContext.currentXFactory().canonicalizeAll();
                if (PROGRESS || LIST_ORDER) {
                    System.out.printf("%6d : Pass %d: %d classes%n", (System.currentTimeMillis() - startTime)/1000, passCount,  classCollection.size());
                    if (DEBUG) {
                        XFactory.profile();
                    }
                }
                if (!isNonReportingFirstPass) {
                    OutEdges<ClassDescriptor> outEdges = e -> {
                        try {
                            XClass classNameAndInfo = Global.getAnalysisCache().getClassAnalysis(XClass.class, e);
                            return classNameAndInfo.getCalledClassDescriptors();
                        } catch (CheckedAnalysisException e2) {
                            AnalysisContext.logError("error while analyzing " + e.getClassName(), e2);
                            return Collections.emptyList();

                        }
                    };

                    classCollection = sortByCallGraph(classCollection, outEdges);
                }
                if (LIST_ORDER) {
                    System.out.println("Analysis order:");
                    for (ClassDescriptor c : classCollection) {
                        System.out.println("  " + c);
                    }
                }
                AnalysisContext currentAnalysisContext = AnalysisContext.currentAnalysisContext();
                currentAnalysisContext.updateDatabases(passCount);

                progressReporter.startAnalysis(classCollection.size());
                int count = 0;
                Global.getAnalysisCache().purgeAllMethodAnalysis();
                Global.getAnalysisCache().purgeClassAnalysis(FBClassReader.class);
                for (ClassDescriptor classDescriptor : classCollection) {
                    long classStartNanoTime = 0;
                    if (PROGRESS) {
                        classStartNanoTime = System.nanoTime();
                        System.out.printf("%6d %d/%d  %d/%d %s%n", (System.currentTimeMillis() - startTime)/1000,
                                passCount, executionPlan.getNumPasses(), count,
                                classCollection.size(), classDescriptor);
                    }
                    count++;

                    // Check to see if class is excluded by the class screener.
                    // In general, we do not want to screen classes from the
                    // first pass, even if they would otherwise be excluded.
                    if ((SCREEN_FIRST_PASS_CLASSES || !isNonReportingFirstPass)
                            && !classScreener.matches(classDescriptor.toResourceName())) {
                        if (DEBUG) {
                            System.out.println("*** Excluded by class screener");
                        }
                        continue;
                    }
                    boolean isHuge = currentAnalysisContext.isTooBig(classDescriptor);
                    if (isHuge && currentAnalysisContext.isApplicationClass(classDescriptor)) {
                        bugReporter.reportBug(new BugInstance("SKIPPED_CLASS_TOO_BIG", Priorities.NORMAL_PRIORITY)
                        .addClass(classDescriptor));
                    }
                    currentClassName = ClassName.toDottedClassName(classDescriptor.getClassName());
                    notifyClassObservers(classDescriptor);
                    profiler.startContext(currentClassName);
                    currentAnalysisContext.setClassBeingAnalyzed(classDescriptor);

                    try {
                        for (Detector2 detector : detectorList) {
                            if (Thread.interrupted()) {
                                throw new InterruptedException();
                            }
                            if (isHuge && !FirstPassDetector.class.isAssignableFrom(detector.getClass())) {
                                continue;
                            }
                            if (DEBUG) {
                                System.out.println("Applying " + detector.getDetectorClassName() + " to " + classDescriptor);
                                // System.out.println("foo: " +
                                // NonReportingDetector.class.isAssignableFrom(detector.getClass())
                                // + ", bar: " + detector.getClass().getName());
                            }
                            try {
                                profiler.start(detector.getClass());
                                detector.visitClass(classDescriptor);
                            } catch (ClassFormatException e) {
                                logRecoverableException(classDescriptor, detector, e);
                            } catch (MissingClassException e) {
                                Global.getAnalysisCache().getErrorLogger().reportMissingClass(e.getClassDescriptor());
                            } catch (CheckedAnalysisException e) {
                                logRecoverableException(classDescriptor, detector, e);
                            } catch (RuntimeException e) {
                                logRecoverableException(classDescriptor, detector, e);
                            } finally {
                                profiler.end(detector.getClass());
                            }
                        }
                    } finally {

                        progressReporter.finishClass();
                        profiler.endContext(currentClassName);
                        currentAnalysisContext.clearClassBeingAnalyzed();
                        if (PROGRESS) {
                            long usecs = (System.nanoTime() - classStartNanoTime)/1000;
                            if (usecs > 15000) {
                                int classSize = currentAnalysisContext.getClassSize(classDescriptor);
                                long speed = usecs /classSize;
                                if (speed > 15) {
                                    System.out.printf("  %6d usecs/byte  %6d msec  %6d bytes  %d pass %s%n", speed, usecs/1000, classSize, passCount,
                                            classDescriptor);
                                }
                            }

                        }
                    }
                }

                // Call finishPass on each detector
                for (Detector2 detector : detectorList) {
                    detector.finishPass();
                }

                progressReporter.finishPerClassAnalysis();

                passCount++;
            }


        } finally {

            bugReporter.finish();
            bugReporter.reportQueuedErrors();
            profiler.end(this.getClass());
            if (PROGRESS) {
                System.out.println("Analysis completed");
            }
        }

    }
361218
private Collection<Candidate> findCandidateClasses(Outline outline, JClass xmlElementDeclModelClass) {
		Map<String, ClassOutline> interfaceImplementations = new HashMap<String, ClassOutline>();

		// Visit all classes to create a map "interfaceName -> ClassOutline".
		// This map is later used to resolve implementations from interfaces.
		for (ClassOutline classOutline : outline.getClasses()) {
			for (Iterator<JClass> iter = classOutline.implClass._implements(); iter.hasNext();) {
				JClass interfaceClass = iter.next();

				if (interfaceClass instanceof JDefinedClass) {
					// Don't care if some interfaces collide: value classes have exactly one implementation
					interfaceImplementations.put(interfaceClass.fullName(), classOutline);
				}
			}
		}

		Collection<Candidate> candidates = new ArrayList<Candidate>();

		JClass collectionModelClass = outline.getCodeModel().ref(Collection.class);
		JClass xmlSchemaModelClass = outline.getCodeModel().ref(XmlSchema.class);

		// Visit all classes created by JAXB processing to collect all potential wrapper classes to be removed:
		for (ClassOutline classOutline : outline.getClasses()) {
			JDefinedClass candidateClass = classOutline.implClass;

			// * The candidate class should not extend any other model class (as the total number of properties in this case will be more than 1)
			if (!isHiddenClass(candidateClass._extends())) {
				continue;
			}

			JFieldVar field = null;

			// * The candidate class should have exactly one property
			for (JFieldVar f : candidateClass.fields().values()) {
				if ((f.mods().getValue() & JMod.STATIC) == JMod.STATIC) {
					continue;
				}

				// If there are at least two non-static fields, we discard this candidate:
				if (field != null) {
					field = null;
					break;
				}

				field = f;
			}

			// "field" is null if there are no fields (or all fields are static) or there are more then two fields.
			// The only property should be a collection, hence it should be class:
			if (field == null || !(field.type() instanceof JClass)) {
				continue;
			}

			JClass fieldType = (JClass) field.type();

			// * The property should be a collection
			if (!collectionModelClass.isAssignableFrom(fieldType)) {
				continue;
			}

			List<JClass> fieldParametrisations = fieldType.getTypeParameters();

			// FIXME: All known collections have exactly one parametrisation type.
			assert fieldParametrisations.size() == 1;

			JDefinedClass fieldParametrisationClass = null;
			JDefinedClass fieldParametrisationImpl = null;

			// Parametrisations like "List<String>" or "List<Serialazable>" are not considered.
			// They are substituted as is and do not require moving of classes.
			if (fieldParametrisations.get(0) instanceof JDefinedClass) {
				fieldParametrisationClass = (JDefinedClass) fieldParametrisations.get(0);

				ClassOutline fieldParametrisationClassOutline = interfaceImplementations
				            .get(fieldParametrisationClass.fullName());

				if (fieldParametrisationClassOutline != null) {
					assert fieldParametrisationClassOutline.ref == fieldParametrisationClass;

					fieldParametrisationImpl = fieldParametrisationClassOutline.implClass;
				}
				else {
					fieldParametrisationImpl = fieldParametrisationClass;
				}
			}

			// We have a candidate class:
			Candidate candidate = new Candidate(candidateClass, classOutline.target, field, fieldParametrisationClass,
			            fieldParametrisationImpl, xmlElementDeclModelClass, xmlSchemaModelClass);
			candidates.add(candidate);

			logger.debug("Found " + candidate);
		}

		return candidates;
	}
660473
@Override
    public void build(IClassPath classPath, IClassPathBuilderProgress progress) throws CheckedAnalysisException, IOException,
    InterruptedException {
        // Discover all directly and indirectly referenced codebases
        processWorkList(classPath, projectWorkList, progress);

        // If not already located, try to locate any additional codebases
        // containing classes required for analysis.
        if (!discoveredCodeBaseList.isEmpty()) {
            locateCodebasesRequiredForAnalysis(classPath, progress);
        }

        // Add all discovered codebases to the classpath
        for (DiscoveredCodeBase discoveredCodeBase : discoveredCodeBaseList) {
            classPath.addCodeBase(discoveredCodeBase.getCodeBase());
        }

        Set<ClassDescriptor> appClassSet = new HashSet<>();

        // Build collection of all application classes.
        // Also, add resource name -> codebase entry mappings for application
        // classes.
        for (DiscoveredCodeBase discoveredCodeBase : discoveredCodeBaseList) {
            if (!discoveredCodeBase.getCodeBase().isApplicationCodeBase()) {
                continue;
            }

            codeBaseEntryLoop: for (ICodeBaseIterator i = discoveredCodeBase.iterator(); i.hasNext();) {
                ICodeBaseEntry entry = i.next();
                if (!DescriptorFactory.isClassResource(entry.getResourceName())) {
                    continue;
                }

                ClassDescriptor classDescriptor = entry.getClassDescriptor();
                if (classDescriptor == null) {
                    throw new IllegalStateException();
                }

                if (appClassSet.contains(classDescriptor)) {
                    // An earlier entry takes precedence over this class
                    continue codeBaseEntryLoop;
                }
                appClassSet.add(classDescriptor);
                appClassList.add(classDescriptor);

                classPath.mapResourceNameToCodeBaseEntry(entry.getResourceName(), entry);
            }
        }

        if (DEBUG) {
            System.out.println("Classpath:");
            dumpCodeBaseList(classPath.appCodeBaseIterator(), "Application codebases");
            dumpCodeBaseList(classPath.auxCodeBaseIterator(), "Auxiliary codebases");
        }

        // Make sure we always know if we can't find system classes
        ICodeBaseEntry resource = classPath.lookupResource("java/lang/Object.class");
        if(resource == null){
            throw new ResourceNotFoundException("java/lang/Object.class");
        }
    }
395151
protected void scanMethods(ClassFile cf) {
        List<ClassFile> methods = cf.getMethods();
        if (methods == null)
            return;
        for (Object obj : methods) {
            MethodInfo method = (MethodInfo) obj;
            if (scanMethodAnnotations) {
                AnnotationsAttribute visible = (AnnotationsAttribute) method
                        .getAttribute(AnnotationsAttribute.visibleTag);
                AnnotationsAttribute invisible = (AnnotationsAttribute) method
                        .getAttribute(AnnotationsAttribute.invisibleTag);
                if (visible != null)
                    populate(visible.getAnnotations(), cf.getName());
                if (invisible != null)
                    populate(invisible.getAnnotations(), cf.getName());
            }
            if (scanParameterAnnotations) {
                ParameterAnnotationsAttribute paramsVisible = (ParameterAnnotationsAttribute) method
                        .getAttribute(ParameterAnnotationsAttribute.visibleTag);
                ParameterAnnotationsAttribute paramsInvisible = (ParameterAnnotationsAttribute) method
                        .getAttribute(ParameterAnnotationsAttribute.invisibleTag);
                if (paramsVisible != null && paramsVisible.getAnnotations() != null) {
                    for (Annotation[] anns : paramsVisible.getAnnotations()) {
                        populate(anns, cf.getName());
                    }
                }
                if (paramsInvisible != null && paramsInvisible.getAnnotations() != null) {
                    for (Annotation[] anns : paramsInvisible.getAnnotations()) {
                        populate(anns, cf.getName());
                    }
                }
            }
        }
    }
1246739
private function analyze()
	{
		// Check for all languages here
		if (empty(glob($this->adminLangPath . "/*/*." . $this->ext . "*.ini")))
		{
			$this->hasAdminLang = false;
		}

		if (empty(glob($this->frontLangPath . "/*/*." . $this->ext . "*.ini")))
		{
			$this->hasFrontLang = false;
		}
	}
141658
@Override
    public UnpackedCode analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
        Method method = getMethod(analysisCache, descriptor);
        Code code = method.getCode();
        if (code == null) {
            return null;
        }

        byte[] instructionList = code.getCode();

        // Create callback
        UnpackedBytecodeCallback callback = new UnpackedBytecodeCallback(instructionList.length);

        // Scan the method.
        BytecodeScanner scanner = new BytecodeScanner();
        scanner.scan(instructionList, callback);

        return callback.getUnpackedCode();

    }
966816
public function analyze(
        Context $class_context = null,
        Context $global_context = null
    ) {
        $class = $this->class;

        if (!$class instanceof PhpParser\Node\Stmt\Class_) {
            throw new \LogicException('Something went badly wrong');
        }

        $fq_class_name = $class_context && $class_context->self ? $class_context->self : $this->fq_class_name;

        $storage = $this->storage;

        if ($storage->has_visitor_issues) {
            return;
        }

        if ($class->name && preg_match(
            '/(^|\\\)(int|float|bool|string|void|null|false|true|resource|object|numeric|mixed)$/i',
            $fq_class_name
        )) {
            $class_name_parts = explode('\\', $fq_class_name);
            $class_name = array_pop($class_name_parts);

            if (IssueBuffer::accepts(
                new ReservedWord(
                    $class_name . ' is a reserved word',
                    new CodeLocation(
                        $this,
                        $class->name,
                        null,
                        true
                    ),
                    $class_name
                ),
                array_merge($storage->suppressed_issues, $this->source->getSuppressedIssues())
            )) {
                // fall through
            }

            return null;
        }

        $project_analyzer = $this->file_analyzer->project_analyzer;
        $codebase = $this->getCodebase();

        $classlike_storage_provider = $codebase->classlike_storage_provider;

        $parent_fq_class_name = $this->parent_fq_class_name;

        if ($class->extends) {
            if (!$parent_fq_class_name) {
                throw new \UnexpectedValueException('Parent class should be filled in for ' . $fq_class_name);
            }

            $parent_reference_location = new CodeLocation($this, $class->extends);

            if (self::checkFullyQualifiedClassLikeName(
                $this->getSource(),
                $parent_fq_class_name,
                $parent_reference_location,
                array_merge($storage->suppressed_issues, $this->getSuppressedIssues()),
                false
            ) === false) {
                return false;
            }

            try {
                $parent_class_storage = $classlike_storage_provider->get($parent_fq_class_name);

                $code_location = new CodeLocation(
                    $this,
                    $class->extends,
                    $class_context ? $class_context->include_location : null,
                    true
                );

                if ($parent_class_storage->is_trait || $parent_class_storage->is_interface) {
                    if (IssueBuffer::accepts(
                        new UndefinedClass(
                            $parent_fq_class_name . ' is not a class',
                            $code_location,
                            $parent_fq_class_name . ' as class'
                        ),
                        array_merge($storage->suppressed_issues, $this->getSuppressedIssues())
                    )) {
                        // fall through
                    }
                }

                if ($parent_class_storage->deprecated) {
                    if (IssueBuffer::accepts(
                        new DeprecatedClass(
                            $parent_fq_class_name . ' is marked deprecated',
                            $code_location
                        ),
                        array_merge($storage->suppressed_issues, $this->getSuppressedIssues())
                    )) {
                        // fall through
                    }
                }

                if ($parent_class_storage->internal) {
                    $code_location = new CodeLocation(
                        $this,
                        $class->extends,
                        $class_context ? $class_context->include_location : null,
                        true
                    );

                    $self_root = preg_replace('/^([^\\\]+).*/', '$1', $fq_class_name);
                    $declaring_root = preg_replace('/^([^\\\]+).*/', '$1', $parent_fq_class_name);

                    if (strtolower($self_root) !== strtolower($declaring_root)) {
                        if (IssueBuffer::accepts(
                            new InternalClass(
                                $parent_fq_class_name . ' is marked internal',
                                $code_location
                            ),
                            array_merge($storage->suppressed_issues, $this->getSuppressedIssues())
                        )) {
                            // fall through
                        }
                    }
                }

                if ($codebase->store_node_types && $fq_class_name) {
                    $codebase->analyzer->addNodeReference(
                        $this->getFilePath(),
                        $class->extends,
                        $parent_fq_class_name
                    );
                }

                $code_location = new CodeLocation(
                    $this,
                    $class->name ?: $class,
                    $class_context ? $class_context->include_location : null,
                    true
                );

                if ($storage->template_type_extends_count !== null) {
                    $this->checkTemplateParams(
                        $codebase,
                        $storage,
                        $parent_class_storage,
                        $code_location,
                        $storage->template_type_extends_count
                    );
                }
            } catch (\InvalidArgumentException $e) {
                // do nothing
            }
        }

        foreach ($class->implements as $interface_name) {
            $fq_interface_name = self::getFQCLNFromNameObject(
                $interface_name,
                $this->source->getAliases()
            );

            $interface_location = new CodeLocation($this, $interface_name);

            if (self::checkFullyQualifiedClassLikeName(
                $this,
                $fq_interface_name,
                $interface_location,
                $this->getSuppressedIssues(),
                false
            ) === false) {
                return false;
            }

            if ($codebase->store_node_types && $fq_class_name) {
                $bounds = $interface_location->getSelectionBounds();

                $codebase->analyzer->addOffsetReference(
                    $this->getFilePath(),
                    $bounds[0],
                    $bounds[1],
                    $fq_interface_name
                );
            }

            try {
                $interface_storage = $classlike_storage_provider->get($fq_interface_name);
            } catch (\InvalidArgumentException $e) {
                continue;
            }

            $code_location = new CodeLocation(
                $this,
                $interface_name,
                $class_context ? $class_context->include_location : null,
                true
            );

            if (!$interface_storage->is_interface) {
                if (IssueBuffer::accepts(
                    new UndefinedInterface(
                        $fq_interface_name . ' is not an interface',
                        $code_location
                    ),
                    array_merge($storage->suppressed_issues, $this->getSuppressedIssues())
                )) {
                    // fall through
                }
            }

            if (isset($storage->template_type_implements_count[strtolower($fq_interface_name)])) {
                $expected_param_count = $storage->template_type_implements_count[strtolower($fq_interface_name)];

                $this->checkTemplateParams(
                    $codebase,
                    $storage,
                    $interface_storage,
                    $code_location,
                    $expected_param_count
                );
            }
        }

        if ($storage->template_types) {
            foreach ($storage->template_types as $param_name => $_) {
                $fq_classlike_name = Type::getFQCLNFromString(
                    $param_name,
                    $this->getAliases()
                );

                if ($codebase->classOrInterfaceExists($fq_classlike_name)) {
                    if (IssueBuffer::accepts(
                        new ReservedWord(
                            'Cannot use ' . $param_name . ' as template name since the class already exists',
                            new CodeLocation($this, $this->class),
                            'resource'
                        ),
                        $this->getSuppressedIssues()
                    )) {
                        // fall through
                    }
                }
            }
        }

        if ($storage->template_type_extends) {
            foreach ($storage->template_type_extends as $type_map) {
                foreach ($type_map as $atomic_type) {
                    $atomic_type->check(
                        $this,
                        new CodeLocation(
                            $this,
                            $class->name ?: $class,
                            null,
                            true
                        ),
                        $this->getSuppressedIssues()
                    );
                }
            }
        }

        if ($storage->invalid_dependencies) {
            return;
        }

        $class_interfaces = $storage->class_implements;

        if (!$class->isAbstract()) {
            foreach ($class_interfaces as $interface_name) {
                try {
                    $interface_storage = $classlike_storage_provider->get($interface_name);
                } catch (\InvalidArgumentException $e) {
                    continue;
                }

                $code_location = new CodeLocation(
                    $this,
                    $class->name ? $class->name : $class,
                    $class_context ? $class_context->include_location : null,
                    true
                );

                if ($interface_storage->deprecated) {
                    if (IssueBuffer::accepts(
                        new DeprecatedInterface(
                            $interface_name . ' is marked deprecated',
                            $code_location
                        ),
                        array_merge($storage->suppressed_issues, $this->getSuppressedIssues())
                    )) {
                        // fall through
                    }
                }

                foreach ($interface_storage->methods as $method_name => $interface_method_storage) {
                    if ($interface_method_storage->visibility === self::VISIBILITY_PUBLIC) {
                        $implementer_declaring_method_id = $codebase->methods->getDeclaringMethodId(
                            $this->fq_class_name . '::' . $method_name
                        );

                        $implementer_method_storage = null;
                        $implementer_classlike_storage = null;

                        if ($implementer_declaring_method_id) {
                            list($implementer_fq_class_name) = explode('::', $implementer_declaring_method_id);
                            $implementer_method_storage = $codebase->methods->getStorage(
                                $implementer_declaring_method_id
                            );
                            $implementer_classlike_storage = $classlike_storage_provider->get(
                                $implementer_fq_class_name
                            );
                        }

                        if (!$implementer_method_storage) {
                            if (IssueBuffer::accepts(
                                new UnimplementedInterfaceMethod(
                                    'Method ' . $method_name . ' is not defined on class ' .
                                    $storage->name,
                                    $code_location
                                ),
                                array_merge($storage->suppressed_issues, $this->getSuppressedIssues())
                            )) {
                                return false;
                            }

                            return null;
                        }

                        $implementer_appearing_method_id = $codebase->methods->getAppearingMethodId(
                            $this->fq_class_name . '::' . $method_name
                        );

                        $implementer_visibility = $implementer_method_storage->visibility;

                        if ($implementer_appearing_method_id
                            && $implementer_appearing_method_id !== $implementer_declaring_method_id
                        ) {
                            list($appearing_fq_class_name, $appearing_method_name) = explode(
                                '::',
                                $implementer_appearing_method_id
                            );

                            $appearing_class_storage = $classlike_storage_provider->get(
                                $appearing_fq_class_name
                            );

                            if (isset($appearing_class_storage->trait_visibility_map[$appearing_method_name])) {
                                $implementer_visibility
                                    = $appearing_class_storage->trait_visibility_map[$appearing_method_name];
                            }
                        }

                        if ($implementer_visibility !== self::VISIBILITY_PUBLIC) {
                            if (IssueBuffer::accepts(
                                new InaccessibleMethod(
                                    'Interface-defined method ' . $implementer_method_storage->cased_name
                                        . ' must be public in ' . $storage->name,
                                    $code_location
                                ),
                                array_merge($storage->suppressed_issues, $this->getSuppressedIssues())
                            )) {
                                return false;
                            }

                            return null;
                        }

                        if ($interface_method_storage->is_static && !$implementer_method_storage->is_static) {
                            if (IssueBuffer::accepts(
                                new MethodSignatureMismatch(
                                    'Method ' . $implementer_method_storage->cased_name
                                    . ' should be static like '
                                    . $storage->name . '::' . $interface_method_storage->cased_name,
                                    $code_location
                                ),
                                $implementer_method_storage->suppressed_issues
                            )) {
                                return false;
                            }
                        }

                        MethodAnalyzer::compareMethods(
                            $codebase,
                            $implementer_classlike_storage ?: $storage,
                            $interface_storage,
                            $implementer_method_storage,
                            $interface_method_storage,
                            $this->fq_class_name,
                            $implementer_visibility,
                            $code_location,
                            $implementer_method_storage->suppressed_issues,
                            false
                        );
                    }
                }
            }
        }

        if (!$class_context) {
            $class_context = new Context($this->fq_class_name);
            $class_context->collect_references = $codebase->collect_references;
            $class_context->parent = $parent_fq_class_name;
        }

        if ($global_context) {
            $class_context->strict_types = $global_context->strict_types;
        }

        if ($this->leftover_stmts) {
            (new StatementsAnalyzer($this))->analyze($this->leftover_stmts, $class_context);
        }

        if (!$storage->abstract) {
            foreach ($storage->declaring_method_ids as $declaring_method_id) {
                $method_storage = $codebase->methods->getStorage($declaring_method_id);

                list($declaring_class_name, $method_name) = explode('::', $declaring_method_id);

                if ($method_storage->abstract) {
                    if (IssueBuffer::accepts(
                        new UnimplementedAbstractMethod(
                            'Method ' . $method_name . ' is not defined on class ' .
                            $this->fq_class_name . ', defined abstract in ' . $declaring_class_name,
                            new CodeLocation(
                                $this,
                                $class->name ? $class->name : $class,
                                $class_context->include_location,
                                true
                            )
                        ),
                        array_merge($storage->suppressed_issues, $this->getSuppressedIssues())
                    )) {
                        return false;
                    }
                }
            }
        }

        foreach ($storage->appearing_property_ids as $property_name => $appearing_property_id) {
            $property_class_name = $codebase->properties->getDeclaringClassForProperty(
                $appearing_property_id,
                true
            );
            $property_class_storage = $classlike_storage_provider->get((string)$property_class_name);

            $property_storage = $property_class_storage->properties[$property_name];

            if (isset($storage->overridden_property_ids[$property_name])) {
                foreach ($storage->overridden_property_ids[$property_name] as $overridden_property_id) {
                    list($guide_class_name) = explode('::$', $overridden_property_id);
                    $guide_class_storage = $classlike_storage_provider->get($guide_class_name);
                    $guide_property_storage = $guide_class_storage->properties[$property_name];

                    if ($property_storage->visibility > $guide_property_storage->visibility
                        && $property_storage->location
                    ) {
                        if (IssueBuffer::accepts(
                            new OverriddenPropertyAccess(
                                'Property ' . $guide_class_storage->name . '::$' . $property_name
                                    . ' has different access level than '
                                    . $storage->name . '::$' . $property_name,
                                $property_storage->location
                            )
                        )) {
                            return false;
                        }

                        return null;
                    }
                }
            }

            if ($property_storage->type) {
                $property_type = clone $property_storage->type;

                if (!$property_type->isMixed() &&
                    !$property_storage->has_default &&
                    !$property_type->isNullable()
                ) {
                    $property_type->initialized = false;
                }
            } else {
                $property_type = Type::getMixed();
            }

            $property_type_location = $property_storage->type_location;

            $fleshed_out_type = !$property_type->isMixed()
                ? ExpressionAnalyzer::fleshOutType(
                    $codebase,
                    $property_type,
                    $this->fq_class_name,
                    $this->fq_class_name
                )
                : $property_type;

            /**
             * @psalm-suppress ReferenceConstraintViolation
             */
            $class_template_params = MethodCallAnalyzer::getClassTemplateParams(
                $codebase,
                $property_class_storage,
                $fq_class_name,
                null,
                new Type\Atomic\TNamedObject($fq_class_name),
                '$this'
            );

            if ($class_template_params) {
                $generic_params = [];
                $fleshed_out_type->replaceTemplateTypesWithStandins(
                    $class_template_params,
                    $generic_params,
                    $codebase
                );
            }

            if ($property_type_location && !$fleshed_out_type->isMixed()) {
                $fleshed_out_type->check(
                    $this,
                    $property_type_location,
                    array_merge($this->getSuppressedIssues(), $storage->suppressed_issues),
                    [],
                    false
                );
            }

            if ($property_storage->is_static) {
                $property_id = $this->fq_class_name . '::$' . $property_name;

                $class_context->vars_in_scope[$property_id] = $fleshed_out_type;
            } else {
                $class_context->vars_in_scope['$this->' . $property_name] = $fleshed_out_type;
            }
        }

        foreach ($storage->pseudo_property_get_types as $property_name => $property_type) {
            $fleshed_out_type = !$property_type->isMixed()
                ? ExpressionAnalyzer::fleshOutType(
                    $codebase,
                    $property_type,
                    $this->fq_class_name,
                    $this->fq_class_name
                )
                : $property_type;

            $class_context->vars_in_scope['$this->' . substr($property_name, 1)] = $fleshed_out_type;
        }

        $constructor_analyzer = null;
        $member_stmts = [];

        foreach ($class->stmts as $stmt) {
            if ($stmt instanceof PhpParser\Node\Stmt\ClassMethod) {
                $method_analyzer = $this->analyzeClassMethod(
                    $stmt,
                    $storage,
                    $this,
                    $class_context,
                    $global_context
                );

                if ($stmt->name->name === '__construct') {
                    $constructor_analyzer = $method_analyzer;
                }
            } elseif ($stmt instanceof PhpParser\Node\Stmt\TraitUse) {
                if ($this->analyzeTraitUse(
                    $this->source->getAliases(),
                    $stmt,
                    $project_analyzer,
                    $storage,
                    $class_context,
                    $global_context,
                    $constructor_analyzer
                ) === false) {
                    return false;
                }
            } elseif ($stmt instanceof PhpParser\Node\Stmt\Property) {
                foreach ($stmt->props as $prop) {
                    if ($prop->default) {
                        $member_stmts[] = $stmt;
                        break;
                    }
                }
            } elseif ($stmt instanceof PhpParser\Node\Stmt\ClassConst) {
                $member_stmts[] = $stmt;
            }
        }

        $statements_analyzer = new StatementsAnalyzer($this);
        $statements_analyzer->analyze($member_stmts, $class_context, $global_context, true);

        $config = Config::getInstance();

        $this->checkPropertyInitialization(
            $codebase,
            $config,
            $storage,
            $class_context,
            $global_context,
            $constructor_analyzer
        );

        foreach ($class->stmts as $stmt) {
            if ($stmt instanceof PhpParser\Node\Stmt\Property && !isset($stmt->type)) {
                $this->checkForMissingPropertyType($this, $stmt, $class_context);
            } elseif ($stmt instanceof PhpParser\Node\Stmt\TraitUse) {
                foreach ($stmt->traits as $trait) {
                    $fq_trait_name = self::getFQCLNFromNameObject(
                        $trait,
                        $this->source->getAliases()
                    );

                    try {
                        $trait_file_analyzer = $project_analyzer->getFileAnalyzerForClassLike($fq_trait_name);
                    } catch (\Exception $e) {
                        continue;
                    }

                    $trait_node = $codebase->classlikes->getTraitNode($fq_trait_name);
                    $trait_aliases = $codebase->classlikes->getTraitAliases($fq_trait_name);
                    $trait_analyzer = new TraitAnalyzer(
                        $trait_node,
                        $trait_file_analyzer,
                        $fq_trait_name,
                        $trait_aliases
                    );

                    if (isset($storage->template_type_uses_count[strtolower($fq_trait_name)])) {
                        $trait_storage = $codebase->classlike_storage_provider->get($fq_trait_name);
                        $expected_param_count = $storage->template_type_uses_count[strtolower($fq_trait_name)];

                        $this->checkTemplateParams(
                            $codebase,
                            $storage,
                            $trait_storage,
                            new CodeLocation(
                                $this,
                                $trait
                            ),
                            $expected_param_count
                        );
                    }

                    foreach ($trait_node->stmts as $trait_stmt) {
                        if ($trait_stmt instanceof PhpParser\Node\Stmt\Property) {
                            $this->checkForMissingPropertyType($trait_analyzer, $trait_stmt, $class_context);
                        }
                    }
                }
            }
        }

        foreach ($storage->pseudo_methods as $pseudo_method_name => $pseudo_method_storage) {
            $pseudo_method_id = $this->fq_class_name . '::' . $pseudo_method_name;

            $overridden_method_ids = $codebase->methods->getOverriddenMethodIds($pseudo_method_id);

            if ($overridden_method_ids
                && $pseudo_method_name !== '__construct'
                && $pseudo_method_storage->location
            ) {
                foreach ($overridden_method_ids as $overridden_method_id) {
                    $parent_method_storage = $codebase->methods->getStorage($overridden_method_id);

                    list($overridden_fq_class_name) = explode('::', $overridden_method_id);

                    $parent_storage = $classlike_storage_provider->get($overridden_fq_class_name);

                    MethodAnalyzer::compareMethods(
                        $codebase,
                        $storage,
                        $parent_storage,
                        $pseudo_method_storage,
                        $parent_method_storage,
                        $this->fq_class_name,
                        $pseudo_method_storage->visibility ?: 0,
                        $pseudo_method_storage->location,
                        $storage->suppressed_issues,
                        true,
                        false
                    );
                }
            }
        }

        $plugin_classes = $codebase->config->after_classlike_checks;

        if ($plugin_classes) {
            $file_manipulations = [];

            foreach ($plugin_classes as $plugin_fq_class_name) {
                if ($plugin_fq_class_name::afterStatementAnalysis(
                    $class,
                    $storage,
                    $this->getSource(),
                    $codebase,
                    $file_manipulations
                ) === false) {
                    return false;
                }
            }

            if ($file_manipulations) {
                \Psalm\Internal\FileManipulation\FileManipulationBuffer::add(
                    $this->getFilePath(),
                    $file_manipulations
                );
            }
        }
    }
800135
def action_analyze(sources,
                   endpoint=None,
                   print_opts=False,
                   verbose=False,
                   extra=False,
                   raw=False):
    
    for x in sources:
        click.secho("Parsing %s..." % str(x), fg='white')

    if extra:
        hide_base_schemas = False
        hide_implicit_types = False
        hide_implicit_preds = False
    else:
        hide_base_schemas = True
        hide_implicit_types = True
        hide_implicit_preds = True

    if raw:
        o = Ontospy(uri_or_path=sources, verbose=verbose, build_all=False)
        s = o.serialize()
        print(s)
        return
    elif endpoint:
        g = Ontospy(
            sparql_endpoint=sources[0],
            verbose=verbose,
            hide_base_schemas=hide_base_schemas,
            hide_implicit_types=hide_implicit_types,
            hide_implicit_preds=hide_implicit_preds)
        printDebug("Extracting classes info")
        g.build_classes()
        printDebug("..done")
        printDebug("Extracting properties info")
        g.build_properties()
        printDebug("..done")
    else:
        g = Ontospy(
            uri_or_path=sources,
            verbose=verbose,
            hide_base_schemas=hide_base_schemas,
            hide_implicit_types=hide_implicit_types,
            hide_implicit_preds=hide_implicit_preds)

    shellPrintOverview(g, print_opts)
126362
def GetAnalyzers(cls):
    
    for analyzer_name, analyzer_class in iter(cls._analyzer_classes.items()):
      yield analyzer_name, analyzer_class
709215
def _getSuitableClasses(self, data):
        """"""
        classes = None
        if data[EI.CLASS] == ELFCLASS.BITS_32:
            if data[EI.DATA] == ELFDATA.LSB:
                classes = LSB_32
            elif data[EI.DATA] == ELFDATA.MSB:
                classes = MSB_32

        elif data[EI.CLASS] == ELFCLASS.BITS_64:
            if data[EI.DATA] == ELFDATA.LSB:
                classes = LSB_64
            elif data[EI.DATA] == ELFDATA.MSB:
                classes = MSB_64

        return classes
1205844
def classes(
            self,
            name=None,
            function=None,
            header_dir=None,
            header_file=None,
            recursive=None,
            allow_empty=None):
        """"""
        return (
            self._find_multiple(
                self._impl_matchers[scopedef_t.class_],
                name=name,
                function=function,
                decl_type=self._impl_decl_types[
                    scopedef_t.class_],
                header_dir=header_dir,
                header_file=header_file,
                recursive=recursive,
                allow_empty=allow_empty)
        )
921083
protected void maybeLoadMethods ()
    {
        if (_methodMap == null) {
            _methodMap = new HashMap<String,List<Member>>();
            Method[] methods = _clazz.getMethods();

            for (int i = 0; i < methods.length; ++i) {
                Method m = methods[i];
                String methodName = m.getName();
                Class<?>[] paramTypes = m.getParameterTypes();

                List<Member> list = _methodMap.get(methodName);
                if (list == null) {
                    list = new ArrayList<Member>();
                    _methodMap.put(methodName, list);
                }

                if (!ClassUtil.classIsAccessible(_clazz)) {
                    m = ClassUtil.getAccessibleMethodFrom(_clazz, methodName, paramTypes );
                }

                if (m != null) {
                    list.add(m);
                    _paramMap.put(m, paramTypes);
                }
            }
        }
    }
1103376
def analyze
      @analyze ||= begin
        debug { "Analyzing spec and lock:" }

        if same?
          debug { "  Same!" }
          return lock.manifests
        end

        debug { "  Removed:" } ; removed_dependency_names.each { |name| debug { "    #{name}" } }
        debug { "  ExplicitRemoved:" } ; explicit_removed_dependency_names.each { |name| debug { "    #{name}" } }
        debug { "  Added:" } ; added_dependency_names.each { |name| debug { "    #{name}" } }
        debug { "  NonMatchingAdded:" } ; nonmatching_added_dependency_names.each { |name| debug { "    #{name}" } }
        debug { "  Changed:" } ; changed_dependency_names.each { |name| debug { "    #{name}" } }
        debug { "  DeepKeep:" } ; deep_keep_manifest_names.each { |name| debug { "    #{name}" } }
        debug { "  ShallowStrip:" } ; shallow_strip_manifest_names.each { |name| debug { "    #{name}" } }

        manifests = ManifestSet.new(lock_manifests)
        manifests.deep_keep!(deep_keep_manifest_names)
        manifests.shallow_strip!(shallow_strip_manifest_names)
        manifests.to_a
      end
    end
199550
def _class(self):
        """"""
        try:
            self._project_name()
        except ValueError:
            return MalformedReq
        if self._is_satisfied():
            return SatisfiedReq
        if not self._expected_hashes():
            return MissingReq
        if self._actual_hash() not in self._expected_hashes():
            return MismatchedReq
        return InstallableReq
983041
void analyze(final MethodResult methodResult) {
        lock.lock();
        try {
            buildPackagePrefix(methodResult.getParentResource().getOriginalClass());

            final List<Instruction> visitedInstructions = interpretRelevantInstructions(methodResult.getInstructions());

            // find project defined methods in invoke occurrences
            final Set<ProjectMethod> projectMethods = findProjectMethods(visitedInstructions);

            // add project methods to global method pool
            projectMethods.forEach(MethodPool.getInstance()::addProjectMethod);

            Element returnedElement = new MethodSimulator().simulate(visitedInstructions);
            final String returnType = methodResult.getOriginalMethodSignature().getReturnType();

            // void resource methods are interpreted later; stop analyzing on error
            if (Types.PRIMITIVE_VOID.equals(returnType)) {
                return;
            }

            if (returnedElement == null) {
                // happens for abstract methods or if there is no return
                return;
            }

            final Set<Object> possibleObjects = returnedElement.getPossibleValues().stream().filter(o -> !(o instanceof HttpResponse))
                    .collect(Collectors.toSet());

            // for non-Response methods add a default if there are non-Response objects or none objects at all
            if (!Types.RESPONSE.equals(returnType)) {
                final HttpResponse defaultResponse = new HttpResponse();

                if (Types.OBJECT.equals(returnType))
                    defaultResponse.getEntityTypes().addAll(returnedElement.getTypes());
                else
                    defaultResponse.getEntityTypes().add(returnType);

                possibleObjects.stream().filter(o -> o instanceof JsonValue).map(o -> (JsonValue) o).forEach(defaultResponse.getInlineEntities()::add);

                defaultResponse.getContentTypes().addAll(methodResult.getResponseMediaTypes());

                methodResult.getResponses().add(defaultResponse);
            }

            // add Response results as well
            returnedElement.getPossibleValues().stream().filter(o -> o instanceof HttpResponse).map(o -> (HttpResponse) o).forEach(methodResult.getResponses()::add);
        } finally {
            lock.unlock();
        }
    }
26369
def find_class(self):
        """"""
        if self.value <= 1:
            return InstructionsProperty
        elif self.value <= 3:
            return NextTablesProperty
        elif self.value <= 7:
            return ActionsProperty

        return OxmProperty
295087
static AnalysisResult analyse(
      Class<?> klass, Constructor<?> constructor) throws IOException {
    Class<?>[] parameterTypes = constructor.getParameterTypes();
    InputStream in = klass.getResourceAsStream("/" + klass.getName().replace('.', '/') + ".class");
    if (in == null) {
      throw new IllegalArgumentException(format("can not find bytecode for %s", klass));
    }
    return analyse(in, klass.getName().replace('.', '/'),
        klass.getSuperclass().getName().replace('.', '/'),
        parameterTypes);
  }