addPass example

public function getServiceReferenceGraph(): ServiceReferenceGraph
    {
        return $this->serviceReferenceGraph;
    }

    /** * @return void */
    public function addPass(CompilerPassInterface $pass, string $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0)
    {
        $this->passConfig->addPass($pass$type$priority);
    }

    /** * @final * * @return void */
    public function log(CompilerPassInterface $pass, string $message)
    {
        if (str_contains($message, "\n")) {
            $message = str_replace("\n", "\n".$pass::class.': ', trim($message));
        }
/** * @author Guilhem N <egetick@gmail.com> */
class PassConfigTest extends TestCase
{
    public function testPassOrdering()
    {
        $config = new PassConfig();
        $config->setBeforeOptimizationPasses([]);

        $pass1 = $this->createMock(CompilerPassInterface::class);
        $config->addPass($pass1, PassConfig::TYPE_BEFORE_OPTIMIZATION, 10);

        $pass2 = $this->createMock(CompilerPassInterface::class);
        $config->addPass($pass2, PassConfig::TYPE_BEFORE_OPTIMIZATION, 30);

        $passes = $config->getBeforeOptimizationPasses();
        $this->assertSame($pass2$passes[0]);
        $this->assertSame($pass1$passes[1]);
    }

    public function testPassOrderingWithoutPasses()
    {
        
/** * Adds a compiler pass. * * @param string $type The type of compiler pass * @param int $priority Used to sort the passes * * @return $this */
    public function addCompilerPass(CompilerPassInterface $pass, string $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0)static
    {
        $this->getCompiler()->addPass($pass$type$priority);

        $this->addObjectResource($pass);

        return $this;
    }

    /** * Returns the compiler pass config which can then be modified. */
    public function getCompilerPassConfig(): PassConfig
    {
        
public function getServiceReferenceGraph(): ServiceReferenceGraph
    {
        return $this->serviceReferenceGraph;
    }

    /** * @return void */
    public function addPass(CompilerPassInterface $pass, string $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0)
    {
        $this->passConfig->addPass($pass$type$priority);
    }

    /** * @final * * @return void */
    public function log(CompilerPassInterface $pass, string $message)
    {
        if (str_contains($message, "\n")) {
            $message = str_replace("\n", "\n".$pass::class.': ', trim($message));
        }
/** * Adds a compiler pass. * * @param string $type The type of compiler pass * @param int $priority Used to sort the passes * * @return $this */
    public function addCompilerPass(CompilerPassInterface $pass, string $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0)static
    {
        $this->getCompiler()->addPass($pass$type$priority);

        $this->addObjectResource($pass);

        return $this;
    }

    /** * Returns the compiler pass config which can then be modified. */
    public function getCompilerPassConfig(): PassConfig
    {
        
Home | Imprint | This part of the site doesn't use cookies.