Fix niggles with code that is generated by gossi/php-code-generator

@param string                      $generated

@param PostProcessorInterface|null $postProcessor

@return string
541922
public function postProcessGeneratedCode(string $generated, ?PostProcessorInterface $postProcessor = null): string
    {

        $generated = $this->fixSuppressWarningsTags($generated);
        $generated = $this->breakImplementsAndExtendsOntoLines($generated);
        $generated = $this->makeConstsPublic($generated);
        $generated = $this->constArraysOnMultipleLines($generated);
        $generated = $this->phpcsIgnoreUseSection($generated);
        $generated = $this->declareStrictFirstLine($generated);
        if (null !== $postProcessor) {
            $generated = $postProcessor($generated);
        }

        return $generated;
    }
327998
public function sqlStatement(CompilerInterface $compiler = null): string
    {
        if (empty($compiler)) {
            $compiler = clone $this->compiler;
        }

        if (!$compiler instanceof PostgresCompiler) {
            throw new BuilderException('Postgres InsertQuery can be used only with Postgres driver and compiler');
        }

        /**
         * @var PostgresDriver   $driver
         * @var PostgresCompiler $compiler
         */
        return $compiler->compileInsert(
            $this->table,
            $this->columns,
            $this->rowsets,
            $this->getPrimaryKey($this->compiler->getPrefix(), $this->table)
        );
    }
1288520
def gen_post_status():
    

    if not app.config["DEBUG"]:
        post_status = and_(Post.status == PostStatus.PUBLISH)
    else:
        post_status = or_(Post.status == PostStatus.PUBLISH,
                          Post.status == PostStatus.DRAFT)
    return post_status
265077
public function get_custom_post_type( $post_type ) {
		if ( ! $this->is_valid_custom_post_type( $post_type ) ) {
			return null;
		}

		$custom_posts = $this->get_custom_posts();

		return $custom_posts[ $post_type ];
	}
207599
public function postProcess($result)
    {
        // determine whether there is anything to process
        if (    is_null($result)
            ||  is_a($result, Collection::class) && $result->isEmpty()
        ) {
            return $result;
        }

        // check if there is anything to do process it through
        if ($this->postProcessors->isEmpty()) return $result;


        // for each Model, instantiate and apply the processors
        if (is_a($result, Collection::class)) {

            $result->transform(function ($model) {
                return $this->applyPostProcessorsToModel($model);
            });

        } elseif (is_a($result, AbstractPaginator::class)) {
            // result is paginate() result
            // do not apply postprocessing for now (how would we even do it?)
            return $result;

        } else {
            // result is a model
            $result = $this->applyPostProcessorsToModel($result);
        }

        return $result;
    }
411801
def gen_postinits(self, cls: ClassDefinition) -> str:
        
        post_inits = []
        if not cls.abstract:
            pkeys = self.primary_keys_for(cls)
            for pkey in pkeys:
                post_inits.append(self.gen_postinit(cls, pkey))
        for slotname in cls.slots:
            slot = self.schema.slots[slotname]
            if not (slot.primary_key or slot.identifier):
                post_inits.append(self.gen_postinit(cls, slotname))
        post_inits_line = '\n\t\t'.join([p for p in post_inits if p])
        return (f'''
    def _fix_elements(self):
        super()._fix_elements()
        {post_inits_line}''' + '\n') if post_inits_line else ''
165636
public function actionGenerate()
    {
        $access = mb_strtolower(StringHelper::randomString(32));

        $this->line($access, Console::FG_GREEN);

        return ExitCode::OK;
    }
646070
public function postfix(string $value, string $postfix): string
    {
        if (substr($value, strlen($value) - strlen($postfix)) === $postfix) {
            return $value;
        }

        return $value . $postfix;
    }
356593
public function generate(Rendering $rendering)
	{
		// Compile the templates to PHP
		$compiledTemplates = array_map([$this, 'compileTemplate'], $rendering->getTemplates());

		// Start the code right after the class name, we'll prepend the header when we're done
		$php = [];
		$php[] = ' extends \\s9e\\TextFormatter\\Renderers\\PHP';
		$php[] = '{';
		$php[] = '	protected $params=' . self::export($rendering->getAllParameters()) . ';';
		$php[] = '	protected function renderNode(\\DOMNode $node)';
		$php[] = '	{';
		$php[] = '		' . SwitchStatement::generate('$node->nodeName', $compiledTemplates, '$this->at($node);');
		$php[] = '	}';

		// Append the Quick renderer if applicable
		if ($this->enableQuickRenderer)
		{
			$php[] = Quick::getSource($compiledTemplates);
		}

		// Close the class definition
		$php[] = '}';

		// Assemble the source
		$php = implode("\n", $php);

		// Finally, optimize the control structures
		if (isset($this->controlStructuresOptimizer))
		{
			$php = $this->controlStructuresOptimizer->optimize($php);
		}

		// Generate a name for that class if necessary, and save it
		$className = (isset($this->className))
		           ? $this->className
		           : $this->defaultClassPrefix . sha1($php);
		$this->lastClassName = $className;

		// Prepare the header
		$header = "\n"
		        . "/**\n"
		        . "* @package   s9e\TextFormatter\n"
		        . "* @copyright Copyright (c) 2010-2019 The s9e Authors\n"
		        . "* @license   http://www.opensource.org/licenses/mit-license.php The MIT License\n"
		        . "*/\n";

		// Declare the namespace and class name
		$pos = strrpos($className, '\\');
		if ($pos !== false)
		{
			$header .= 'namespace ' . substr($className, 0, $pos) . ";\n\n";
			$className = substr($className, 1 + $pos);
		}

		// Prepend the header and the class name
		$php = $header . 'class ' . $className . $php;

		return $php;
	}
8686
private static String getBundlePostProcessorsName(ChainedResourceBundlePostProcessor processor) {

		String bundlePostProcessor = "";
		if (processor != null) {
			bundlePostProcessor = processor.getId();
		}

		return bundlePostProcessor;
	}
302354
public static IPostProcessor unwrap(final IPostProcessor postProcessor) {
        if (postProcessor == null) {
            return null;
        }
        if (postProcessor instanceof PostProcessorWrapper) {
            return ((PostProcessorWrapper) postProcessor).unwrap();
        }
        return postProcessor;
    }
100555
public function getOobConfirmationCode(IdentityToolkit_Relyingparty $postBody, $optParams = array())
  {
    $params = array('postBody' => $postBody);
    $params = array_merge($params, $optParams);
    return $this->call('getOobConfirmationCode', array($params), "IdentityToolkit_GetOobConfirmationCodeResponse");
  }
551394
public function postDispatch() {
        parent::postDispatch();
        if (!empty($this->_postModifyMethods)) {
            $response = Zend_Json::decode($this->view->response, Zend_Json::TYPE_ARRAY);
            $modifiedResponse = array();
            /**
             * Check if this was a batch request. In that case the array is a plain array of
             * arrays. If not, there will be a 'jsonrpc' key in the root of the array.
             */
            $batch = !array_key_exists('jsonrpc', $response);
            if (!$batch) {
                $response = array($response);
            }
            /**
             * Post modify methods are recorded from $this:preDispatch()
             */
            foreach ($this->_postModifyMethods as $i => $postMethod) {
                if (!empty($response[$i]) && !empty($this->_originalRequests[$i])) {
                    $modifyMethod = '_modifyAfter' . ucfirst($postMethod);
                    $response[$i] = $this->{$modifyMethod}(
                        $response[$i],
                        $this->_originalRequests[$i]
                    );
                }
            }
            if ($batch) {
                $this->view->response = Zend_Json::encode($response);
            } else {
                $this->view->response = Zend_Json::encode($response[0]);
            }
        }
        $this->_toggleCache(true);
    }
1105417
static function generatePHPCode( $useComments, $php, $tpl, &$node, &$resourceData )
    {
        $parameters = array();
        $currentParameters = array( 'spacing' => 0 );
        $nodeType = $node[0];
        if ( $nodeType == eZTemplate::NODE_ROOT )
        {
            $children = $node[1];
            if ( $children )
            {
                eZTemplateCompiler::generatePHPCodeChildren( $useComments, $php, $tpl, $children, $resourceData, $parameters, $currentParameters );
            }
        }
        else
            $tpl->error( 'generatePHPCode', "Unknown root type $nodeType, should be " . eZTemplate::NODE_ROOT );
        $php->addSpace();
    }
543433
public function trackingCodeGenerator()
    {
        Piwik::checkUserHasSomeViewAccess();
        
        $view = new View('@CoreAdminHome/trackingCodeGenerator');
        $this->setBasicVariablesView($view);
        $view->topMenu  = MenuTop::getInstance()->getMenu();

        $viewableIdSites = APISitesManager::getInstance()->getSitesIdWithAtLeastViewAccess();

        $defaultIdSite = reset($viewableIdSites);
        $view->idSite = $this->idSite ?: $defaultIdSite;

        if ($view->idSite) {
            try {
                $view->siteName = Site::getNameFor($view->idSite);
            } catch (Exception $e) {
                // ignore if site no longer exists
            }
        }

        $view->defaultReportSiteName = Site::getNameFor($view->idSite);
        $view->defaultSiteRevenue = Site::getCurrencySymbolFor($view->idSite);
        $view->maxCustomVariables = CustomVariables::getNumUsableCustomVariables();

        $view->defaultSite = array('id' => $view->idSite, 'name' => $view->defaultReportSiteName);

        $allUrls = APISitesManager::getInstance()->getSiteUrlsFromId($view->idSite);
        if (isset($allUrls[1])) {
            $aliasUrl = $allUrls[1];
        } else {
            $aliasUrl = 'x.domain.com';
        }
        $view->defaultReportSiteAlias = $aliasUrl;

        $mainUrl = Site::getMainUrlFor($view->idSite);
        $view->defaultReportSiteDomain = @parse_url($mainUrl, PHP_URL_HOST);

        $dntChecker = new DoNotTrackHeaderChecker();
        $view->serverSideDoNotTrackEnabled = $dntChecker->isActive();

        return $view->render();
    }
499621
public function genIR(Compiler $compiler)
    {
        $normalizedPath = $this->filesystem->normalizePath($this->filePath);

        // TODO: JS => JSON
        $compilePath = "{$normalizedPath}.js";
        $zepRealPath = realpath($this->filePath);

        if ($this->filesystem->exists($compilePath)) {
            $modificationTime = $this->filesystem->modificationTime($compilePath);
            if ($modificationTime < filemtime($zepRealPath)) {
                $this->filesystem->delete($compilePath);
                if (false != $this->filesystem->exists($compilePath.'.php')) {
                    $this->filesystem->delete($compilePath.'.php');
                }
            }
        }

        $ir = null;
        if (false == $this->filesystem->exists($compilePath)) {
            $parser = $compiler->getParserManager()->getParser();
            $ir = $parser->parse($zepRealPath);
            $this->filesystem->write($compilePath, json_encode($ir, JSON_PRETTY_PRINT));
        }

        if (false == $this->filesystem->exists($compilePath.'.php')) {
            if (empty($ir)) {
                $ir = json_decode($this->filesystem->read($compilePath), true);
            }

            $data = '<?php return '.var_export($ir, true).';';
            $this->filesystem->write($compilePath.'.php', $data);
        }

        $contents = $this->filesystem->requireFile($compilePath.'.php');

        if (false == \is_array($contents)) {
            throw new IllegalStateException(
                sprintf(
                    'Generating the intermediate representation for the file "%s" was failed.',
                    realpath($this->filePath)
                )
            );
        }

        return $contents;
    }
732993
@SuppressWarnings("unchecked")
    public void setWriterPostProcessor(String writerPostProcessor) {
        if (writePostProcessors == null) {
            writePostProcessors = new LinkedList<>();
        }
        try {
            writePostProcessors.add((Class<IPostProcessor>) Class.forName(writerPostProcessor));
        } catch (Exception e) {
            log.debug("Write post process implementation: {} was not found", writerPostProcessor);
        }
    }