當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。