ScriptReorganizer
[ class tree: ScriptReorganizer ] [ index: ScriptReorganizer ] [ all elements ]

Source for file Quiet.php

Documentation is available at Quiet.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6.  * ScriptReorganizer Strategy :: Quiet
  7.  *
  8.  * PHP version 5
  9.  *
  10.  * LICENSE: This library is free software; you can redistribute it and/or modify it
  11.  * under the terms of the GNU Lesser General Public License as published by the Free
  12.  * Software Foundation; either version 2.1 of the License, or (at your option) any
  13.  * later version.
  14.  *
  15.  * @category   Tools
  16.  * @package    ScriptReorganizer
  17.  * @subpackage Strategy
  18.  * @author     Stefano F. Rausch <stefano@rausch-e.net>
  19.  * @copyright  2005 Stefano F. Rausch <stefano@rausch-e.net>
  20.  * @license    http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  21.  * @version    SVN: $Id: Quiet.php 21 2005-09-26 15:55:48Z stefanorausch $
  22.  * @link       http://pear.php.net/package/ScriptReorganizer
  23.  * @filesource
  24.  */
  25.  
  26. /**
  27.  * Implements <kbd>ScriptReorganizer_Strategy</kbd>
  28.  */
  29. require_once 'ScriptReorganizer/Strategy.php';
  30.  
  31. /**
  32.  * Uses <kbd>ScriptReorganizer_Strategy_Route</kbd>
  33.  */
  34. require_once 'ScriptReorganizer/Strategy/Route.php';
  35.  
  36. /**
  37.  * Standard strategy
  38.  *
  39.  * Reorganizes scripts by stripping off single and multiple line comments as well as
  40.  * by applying the {@link ScriptReorganizer_Strategy_Route Route} strategy.
  41.  *
  42.  * @category   Tools
  43.  * @package    ScriptReorganizer
  44.  * @subpackage Strategy
  45.  * @author     Stefano F. Rausch <stefano@rausch-e.net>
  46.  * @copyright  2005 Stefano F. Rausch <stefano@rausch-e.net>
  47.  * @license    http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  48.  * @version    Release: @package_version@
  49.  * @link       http://pear.php.net/package/ScriptReorganizer
  50.  */
  51. class ScriptReorganizer_Strategy_Quiet implements ScriptReorganizer_Strategy
  52. {
  53.     // {{{ public function __construct()
  54.     
  55.     /**
  56.      * Constructor
  57.      */
  58.     public function __construct()
  59.     {
  60.         $this->route = new ScriptReorganizer_Strategy_Route;
  61.     }
  62.     
  63.     // }}}
  64.     
  65.     // {{{ public function reformat( & $content, $eol )
  66.     
  67.     /**
  68.      * Performs the main reorganization of the script's content
  69.      *
  70.      * @param  string &$content a string representing the script's content
  71.      * @param  string $eol a string representing the EOL identifier to use
  72.      * @return string a string representing the reorganized content
  73.      */
  74.     public function reformat$content$eol )
  75.     {
  76.         $identifiers = array(
  77.             'multiLineComments' => '"[{};,' $eol ']([ \t]*/\*(.|[' $eol '])*?\*/)"',
  78.             'singleLineComments' => '"[{};,' $eol ']([ \t]*//[^' $eol ']*)"'
  79.         );
  80.         
  81.         foreach $identifiers as $identifier {
  82.             if preg_match_all$identifier$content$matches ) ) {
  83.                 foreach $matches[1as $comment {
  84.                     $content str_replace$comment''$content );
  85.                 }
  86.             }
  87.         }
  88.         
  89.         return $this->route->reformat$content$eol );
  90.     }
  91.     
  92.     // }}}
  93.     
  94.     // {{{ private properties
  95.     
  96.     /**
  97.      * Holds the helper strategy
  98.      *
  99.      * @var ScriptReorganizer_Strategy_Route 
  100.      */
  101.     private $route = null;
  102.     
  103.     // }}}
  104. }
  105.  
  106. /*
  107.  * Local variables:
  108.  * tab-width: 4
  109.  * c-basic-offset: 4
  110.  * c-hanging-comment-ender-p: nil
  111.  * End:
  112.  */
  113.  
  114. ?>

Documentation generated on Mon, 11 Mar 2019 14:10:30 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.