当前位置: 首页>>代码示例>>PHP>>正文


PHP Kernel::stripComments方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpKernel\Kernel::stripComments方法的典型用法代码示例。如果您正苦于以下问题:PHP Kernel::stripComments方法的具体用法?PHP Kernel::stripComments怎么用?PHP Kernel::stripComments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpKernel\Kernel的用法示例。


在下文中一共展示了Kernel::stripComments方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: compile

 public function compile()
 {
     if (file_exists('symfony.phar')) {
         unlink('symfony.phar');
     }
     $phar = new \Phar('symfony.phar', 0, 'Symfony');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     // Files
     foreach ($this->getFiles() as $file) {
         $path = str_replace(__DIR__ . '/', '', $file);
         if (false !== strpos($file, '.php')) {
             $content = Kernel::stripComments(file_get_contents($file));
         } else {
             $content = file_get_contents($file);
         }
         $phar->addFromString($path, $content);
     }
     // Stubs
     $phar['_cli_stub.php'] = $this->getCliStub();
     $phar['_web_stub.php'] = $this->getWebStub();
     $phar->setDefaultStub('_cli_stub.php', '_web_stub.php');
     $phar->stopBuffering();
     //$phar->compressFiles(\Phar::GZ);
     unset($phar);
 }
开发者ID:kawahara,项目名称:symfony-bootstrapper,代码行数:26,代码来源:Compiler.php

示例2: stripComments

 private static function stripComments($content)
 {
     if (class_exists(Kernel::class)) {
         $content = Kernel::stripComments($content);
     }
     return $content;
 }
开发者ID:issei-m,项目名称:symfony-dic-demo,代码行数:7,代码来源:ContainerFactory.php

示例3: addFile

 protected function addFile($phar, $file, $strip = true)
 {
     $path = str_replace(realpath(__DIR__ . '/../..') . '/', '', $file->getRealPath());
     $content = file_get_contents($file);
     if ($strip) {
         $content = Kernel::stripComments(file_get_contents($file));
     }
     $phar->addFromString($path, $content);
 }
开发者ID:romainneutron,项目名称:SilexServiceProviders,代码行数:9,代码来源:DoctrineMongoDBCompiler.php

示例4: addFile

 protected function addFile($phar, $file, $strip = true)
 {
     $path = str_replace(dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR, '', $file->getRealPath());
     $content = file_get_contents($file);
     if ($strip) {
         $content = Kernel::stripComments($content);
     }
     $phar->addFromString($path, $content);
 }
开发者ID:romainneutron,项目名称:SilexServiceProviders,代码行数:9,代码来源:DoctrineCompiler.php

示例5: compile

 public function compile($pharFile = 'silex.phar')
 {
     if (file_exists($pharFile)) {
         unlink($pharFile);
     }
     $phar = new \Phar($pharFile, 0, 'Silex');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $finder = new Finder();
     $finder->files()->name('*.php')->exclude('tests')->in(__DIR__ . '/..');
     foreach ($finder as $file) {
         $path = str_replace(realpath(__DIR__ . '/../..') . '/', '', realpath($file));
         $content = Kernel::stripComments(file_get_contents($file));
         $phar->addFromString($path, $content);
     }
     // Stubs
     $phar['_cli_stub.php'] = $this->getStub();
     $phar['_web_stub.php'] = $this->getStub();
     $phar->setDefaultStub('_cli_stub.php', '_web_stub.php');
     $phar->stopBuffering();
     // $phar->compressFiles(\Phar::GZ);
     unset($phar);
 }
开发者ID:radek-baczynski,项目名称:Silex,代码行数:23,代码来源:Compiler.php

示例6: testStripComments

    public function testStripComments()
    {
        $source = <<<'EOF'
<?php

$string = 'string should not be   modified';

$string = 'string should not be

modified';


$heredoc = <<<HD


Heredoc should not be   modified {$a[1+$b]}


HD;

$nowdoc = <<<'ND'


Nowdoc should not be   modified


ND;

/**
 * some class comments to strip
 */
class TestClass
{
    /**
     * some method comments to strip
     */
    public function doStuff()
    {
        // inline comment
    }
}
EOF;
        $expected = <<<'EOF'
<?php
$string = 'string should not be   modified';
$string = 'string should not be

modified';
$heredoc = <<<HD


Heredoc should not be   modified {$a[1+$b]}


HD;
$nowdoc = <<<'ND'


Nowdoc should not be   modified


ND;
class TestClass
{
    public function doStuff()
    {
        }
}
EOF;
        $output = Kernel::stripComments($source);
        // Heredocs are preserved, making the output mixing Unix and Windows line
        // endings, switching to "\n" everywhere on Windows to avoid failure.
        if ('\\' === DIRECTORY_SEPARATOR) {
            $expected = str_replace("\r\n", "\n", $expected);
            $output = str_replace("\r\n", "\n", $output);
        }
        $this->assertEquals($expected, $output);
    }
开发者ID:mat33470,项目名称:PFA,代码行数:78,代码来源:KernelTest.php

示例7: addProxyClasses

 /**
  * Generates code for the proxies to be attached after the container class.
  *
  * @return string
  */
 private function addProxyClasses()
 {
     /* @var $definitions Definition[] */
     $definitions = array_filter($this->container->getDefinitions(), array($this->getProxyDumper(), 'isProxyCandidate'));
     $code = '';
     $strip = '' === $this->docStar && method_exists('Symfony\\Component\\HttpKernel\\Kernel', 'stripComments');
     foreach ($definitions as $definition) {
         $proxyCode = "\n" . $this->getProxyDumper()->getProxyCode($definition);
         if ($strip) {
             $proxyCode = "<?php\n" . $proxyCode;
             $proxyCode = substr(Kernel::stripComments($proxyCode), 5);
         }
         $code .= $proxyCode;
     }
     return $code;
 }
开发者ID:alekitto,项目名称:symfony,代码行数:21,代码来源:PhpDumper.php

示例8: testStripComments

    public function testStripComments()
    {
        if (!function_exists('token_get_all')) {
            $this->markTestSkipped('The function token_get_all() is not available.');
            return;
        }
        $source = <<<'EOF'
<?php

$string = 'string should not be   modified';

$string = 'string should not be

modified';


$heredoc = <<<HD


Heredoc should not be   modified


HD;

$nowdoc = <<<'ND'


Nowdoc should not be   modified


ND;

/**
 * some class comments to strip
 */
class TestClass
{
    /**
     * some method comments to strip
     */
    public function doStuff()
    {
        // inline comment
    }
}
EOF;
        $expected = <<<'EOF'
<?php
$string = 'string should not be   modified';
$string = 'string should not be

modified';
$heredoc = <<<HD


Heredoc should not be   modified


HD;
$nowdoc = <<<'ND'


Nowdoc should not be   modified


ND;
class TestClass
{
    public function doStuff()
    {
        }
}
EOF;
        $output = Kernel::stripComments($source);
        // Heredocs are preserved, making the output mixing Unix and Windows line
        // endings, switching to "\n" everywhere on Windows to avoid failure.
        if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
            $expected = str_replace("\r\n", "\n", $expected);
            $output = str_replace("\r\n", "\n", $output);
        }
        $this->assertEquals($expected, $output);
    }
开发者ID:vomasmic,项目名称:symfony,代码行数:82,代码来源:KernelTest.php

示例9: testStripComments

    public function testStripComments()
    {
        if (!function_exists('token_get_all')) {
            $this->markTestSkipped();
            return;
        }
        $source = <<<EOF
<?php

/**
 * some class comments to strip
 */
class TestClass
{
    /**
     * some method comments to strip
     */
    public function doStuff()
    {
        // inline comment
    }
}
EOF;
        $expected = <<<EOF
<?php
class TestClass
{
    public function doStuff()
    {
            }
}
EOF;
        $this->assertEquals($expected, Kernel::stripComments($source));
    }
开发者ID:hellovic,项目名称:symfony,代码行数:34,代码来源:KernelTest.php

示例10: dumpContainer

 /**
  * Dumps the service container to PHP code in the cache.
  *
  * @param ConfigCache $cache     The config cache
  * @param ContainerBuilder $container The service container
  * @param string $class     The name of the class to generate
  * @param string $baseClass The name of the container's base class
  */
 protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass)
 {
     // cache the container
     $dumper = new PhpDumper($container);
     $content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass));
     if (!$this->debug) {
         $content = SymfonyKernel::stripComments($content);
     }
     $cache->write($content, $container->getResources());
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:18,代码来源:Kernel.php

示例11: testStripComments

    public function testStripComments()
    {
        if (!function_exists('token_get_all')) {
            $this->markTestSkipped('The function token_get_all() is not available.');
            return;
        }
        $source = <<<'EOF'
<?php

$string = 'string should not be   modified';


$heredoc = <<<HD


Heredoc should not be   modified


HD;

$nowdoc = <<<'ND'


Nowdoc should not be   modified


ND;

/**
 * some class comments to strip
 */
class TestClass
{
    /**
     * some method comments to strip
     */
    public function doStuff()
    {
        // inline comment
    }
}
EOF;
        $expected = <<<'EOF'
<?php
$string = 'string should not be   modified';
$heredoc =
<<<HD


Heredoc should not be   modified


HD;
$nowdoc =
<<<'ND'


Nowdoc should not be   modified


ND;
class TestClass
{
    public function doStuff()
    {
            }
}
EOF;
        $this->assertEquals($expected, Kernel::stripComments($source));
    }
开发者ID:ronaldlunaramos,项目名称:webstore,代码行数:70,代码来源:KernelTest.php


注:本文中的Symfony\Component\HttpKernel\Kernel::stripComments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。