Writes the definition of a class in a file

@param IntercessionClass $class
@param $file

@throws \Exception
968664
public function createClassDefinitionFile(IntercessionClass $class, $file)
    {
        $dir = dirname($file);

        if (!file_exists($dir)) {
            set_error_handler(function() use ($dir) {
                throw new NotWritableException($dir);
            });
            mkdir($dir);
            restore_error_handler();
        }

        if (!is_writable($dir)) {
            throw new NotWritableException($dir);
        }

        touch($file);

        file_put_contents($file, $this->renderClass($class));
    }
924185
protected function createDefinition(string $class): Definition
    {
        $path = $this->basePath . DIRECTORY_SEPARATOR . str_replace('\\', '.', $class) . '.yml';

        if (! is_file($path)) {
            throw new DefinitionNotFoundException($class);
        }

        $config = $this->readConfig($path);
        $definition = new Definition($class);

        foreach ($this->processors as $processor)
        {
            $processor->process($config, $definition);
        }

        return $definition;
    }
196818
function register_node_class( $s, $class ){
		if( ! class_exists($class) ){
			$s = $this->token_name( $s );
			throw new Exception( "If you want to register class `$class' for symbol `$s' you should include it first" );
		}
		$this->node_classes[$s] = $class;
	}
761076
private void writeObject(ObjectOutputStream outStream) throws IOException {
        if (classLoaderToPropagate == SYSTEM_CLASS_LOADER)
            classLoaderIdentifier = "";
        else if (classLoaderToPropagate != null) {
            classLoaderIdentifier = classLoaderContextProvider.getClassLoaderIdentifier(classLoaderToPropagate);
            if (classLoaderIdentifier == null)
                throw new NotSerializableException(classLoaderToPropagate.getClass().getName());
        }
        PutField fields = outStream.putFields();
        fields.put(CLASS_LOADER_IDENTIFIER, classLoaderIdentifier);
        outStream.writeFields();
    }
423654
protected function write($messages, $file)
    {
        $f = @fopen($file, 'a');
        if ($f === false)
        {
            throw new \Exception("Logfile $file is not writeable!");
        }

        foreach($messages as $msg)
        {
            fwrite($f, $msg);
        }

        fclose($f);
    }
1104711
@Override
    public void write(DataOutput out) throws IOException
    {
        addSignatureIfNeed();
        out.writeInt(magic);
        out.writeShort(minor_version);
        out.writeShort(major_version);
        out.writeShort(constant_pool.size()+1);
        for (ConstantInfo ci : constant_pool)
        {
            ci.write(out);
        }
        int modifier = ClassFlags.getModifier(getModifiers());
        modifier |= ClassFlags.ACC_SYNTHETIC | ClassFlags.ACC_PUBLIC | ClassFlags.ACC_SUPER;
        out.writeShort(modifier);
        out.writeShort(this_class);
        out.writeShort(super_class);
        out.writeShort(interfaces.size());
        for (int ii : interfaces)
        {
            out.writeShort(ii);
        }
        out.writeShort(fields.size());
        for (FieldInfo fi : fields)
        {
            fi.write(out);
        }
        out.writeShort(methods.size());
        for (MethodInfo mi : methods)
        {
            mi.write(out);
        }
        out.writeShort(attributes.size());
        for (AttributeInfo ai : attributes)
        {
            ai.write(out);
        }

    }
1216698
public function setIteratorClass($class)
    {
        if (strpos($class, '\\') !== 0)
            $class = sprintf('%s%s', '\\', $class);

        if (class_exists($class, true))
        {
            $this->iteratorClass = $class;
            return;
        }

        throw new \InvalidArgumentException(vsprintf(
            '%s::setIteratorClass - Class "%s" is not defined.',
            array(
                get_class($this),
                $class))
        );
    }
457061
protected function defineUploadedFileTrait(ClassDefinition $class)
    {
        $class->property($this->uploadStatus)->asInt();
        $class->property($this->clientMimeType)->nullable()->asString();
    }
423544
protected void writeClassToDisk(File targetDir, ClassWriter classWriter, String className) throws IOException {
        if (targetDir != null) {

            String fileName = className.replace('.', '/') + ".class";
            File targetFile = new File(targetDir, fileName);
            targetFile.getParentFile().mkdirs();

            try (OutputStream outputStream = Files.newOutputStream(targetFile.toPath())) {
                writeClassToDisk(outputStream, classWriter);
            }
        }
    }
1188945
public function addClassDefinition(CompilerFileAnonymous $file, ClassDefinition $classDefinition)
    {
        $this->definitions[$classDefinition->getCompleteName()] = $classDefinition;
        $this->anonymousFiles[$classDefinition->getCompleteName()] = $file;
    }
414427
protected function applyImplementsInterfaceWithSameNameAndSuffix(ClassNode $class)
    {
        $expectedInterfaceName = sprintf('%sInterface', $class->getImage());

        /** @var \PHPMD\Node\InterfaceNode $interface */
        foreach ($class->getInterfaces() as $interface) {
            if ($interface->getName() === $expectedInterfaceName) {
                return;
            }
        }

        $this->addViolation(
            $class,
            [
                sprintf(
                    'The class %s does not implement an interface %s which violates rule: "' . static::RULE . '"',
                    $class->getFullQualifiedName(),
                    $expectedInterfaceName
                ),
            ]
        );
    }
1135253
public static void writeConfigFile(File configFile, Class<?>[] classes) throws SQLException, IOException {
		writeConfigFile(configFile, classes, false);
	}
886444
private function writeManifest($file, ResourcesInterface $resources)
    {
        $mask = 0775 & ~umask();
        if (!is_dir($dir = dirname($file))) {
            if (false === mkdir($dir, $mask, true)) {
                throw new RuntimeException('Creating manifest for router cache failed.');
            }
        } elseif (false === @chmod($dir, $mask)) {
            throw new RuntimeException('Cannot apply permissions on cache directory.');
        }

        file_put_contents($file, serialize($resources), LOCK_EX);
    }
1124194
public void writeClass(String className)
    throws IOException
  {
    ConstantPool pool =  _javaClass.getConstantPool();
    ClassConstant classConst = pool.getClass(className);

    if (classConst != null)
      writeShort(classConst.getIndex());
    else
      writeShort(0);
  }
538737
public function invoke($node, NodeInterface $parent): void
    {
        if ($this->config->hasInterfaceParsing()) {
            if (! $node instanceof Node\Stmt\Interface_ || ! $parent instanceof PhpFileModelInterface) {
                throw new Exception('InterfaceNodeParser is made to parse an interface node');
            }

            $interface = new InterfaceModel();
            $interface->setParentNode($parent);
            $interface->setName(ClassLikeNameHelper::getName($node));
            $parent->addConcreteUse($parent->getFullNameFor($interface->getName()), $interface->getName());

            if (($documentation = $node->getDocComment()) !== null) {
                $this->documentationNodeParser->invoke($documentation, $interface);
            }

            $this->parseSubNodes($node->stmts, $interface);

            $parent->addInterface($interface);
        }
    }
863249
protected function define(ClassDefinition $class)
    {
        $class->property($this->object)->asObject();

        $class->property($this->data)->nullable()->asObject();
    }
182955
private function saveClassToFile(PhpClass $class)
    {
        if ($this->isValidClass($class)) {
            $file = new PhpFile($class->getIdentifier());

            $namespace = $this->config->get('namespaceName');
            if (!empty($namespace)) {
                $file->addNamespace($namespace);
            }

            $file->addClass($class);
            $file->save($this->dir);
        }
    }