Last active
October 1, 2015 15:22
-
-
Save jakebathman/1cff4d11d8eaeb8651e1 to your computer and use it in GitHub Desktop.
Flient.filter.php update
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ | |
| /** | |
| * Filter Fluent: Create fluent style for multi-level object access. | |
| * | |
| * PHP version 5 | |
| * | |
| * LICENSE: This source file is subject to version 3.0 of the PHP license | |
| * that is available through the world-wide-web at the following URI: | |
| * http://www.php.net/license/3_0.txt. If you did not receive a copy of | |
| * the PHP License and are unable to obtain it through the web, please | |
| * send a note to license@php.net so we can mail you a copy immediately. | |
| * | |
| * @category PHP | |
| * @package PHP_Beautifier | |
| * @subpackage Filter | |
| * @author Jesús Espino <jespinog@gmail.com> | |
| * @copyright 2010 Jesús Espino | |
| * @license http://www.php.net/license/3_0.txt PHP License 3.0 | |
| * @version CVS: $Id:$ | |
| * @link http://pear.php.net/package/PHP_Beautifier | |
| * @link http://beautifyphp.sourceforge.net | |
| */ | |
| /** | |
| * Filter Fluent: Create fluent style for multi-level object access. | |
| * Ex. | |
| * <CODE> | |
| * $this | |
| * ->addFile("a.txt") | |
| * ->addFile("b.txt") | |
| * ->addFile("c.txt"); | |
| * $this->addFile("d.txt"); | |
| * </CODE> | |
| * | |
| * @category PHP | |
| * @package PHP_Beautifier | |
| * @subpackage Filter | |
| * @author Jesús Espino <jespinog@gmail.com> | |
| * @copyright 2010 Jesús Espino | |
| * @license http://www.php.net/license/3_0.txt PHP License 3.0 | |
| * @version Release: @package_version@ | |
| * @link http://pear.php.net/package/PHP_Beautifier | |
| * @link http://beautifyphp.sourceforge.net | |
| */ | |
| class PHP_Beautifier_Filter_Fluent extends PHP_Beautifier_Filter | |
| { | |
| /** | |
| * t_object_operator | |
| * | |
| * @param mixed $sTag The tag to be processed | |
| * | |
| * @access public | |
| * @return void | |
| */ | |
| public function t_object_operator($sTag) | |
| { | |
| $counter = 1; | |
| $next = $this->oBeaut->getToken($this->oBeaut->iCount + $counter); | |
| $current = $this->oBeaut->getToken($this->oBeaut->iCount + 1); | |
| while (($next[0] != T_OBJECT_OPERATOR) && ($next != ";")) { | |
| $counter++; | |
| $next = $this->oBeaut->getToken($this->oBeaut->iCount + $counter); | |
| } | |
| $counter = 1; | |
| $prev = $this->oBeaut->getToken($this->oBeaut->iCount - $counter); | |
| $prevFour = $this->oBeaut->getToken($this->oBeaut->iCount - $counter - 3); | |
| while (($prev[0] != T_OBJECT_OPERATOR) && ($prev[0] != T_VARIABLE)) { | |
| $prevFour = $this->oBeaut->getToken($this->oBeaut->iCount - $counter - 2); | |
| $counter++; | |
| $prev = $this->oBeaut->getToken($this->oBeaut->iCount - $counter); | |
| } | |
| $methods = array('avg','count','decrement','delete','distinct','first','get','groupBy','having','increment','insert','insertGetId','join','leftJoin','lists','log','max','min','on','orderBy','orWhere','pluck','raw','remember','select','skip','sum','table','take','truncate','union','update','where','whereBetween','whereExists','whereIn','whereNotBetween','whereNotIn','whereNull','whereRaw'); | |
| if (($prev[0] == T_VARIABLE) && (!in_array($current[1], $methods))) { | |
| $this->oBeaut->add($sTag); | |
| return false; | |
| } | |
| $this->oBeaut->removeWhiteSpace(); | |
| if ($next[0] == T_OBJECT_OPERATOR || $prev[0] == T_OBJECT_OPERATOR || $next == ";") { | |
| if (!in_array($current[1], $methods) && ($counter <= 2)) { | |
| $this->oBeaut->removeWhiteSpace(); | |
| } | |
| elseif (($prev[1] == '$this') || ($prev[1] == '$job') || ($current[1] == 'db') || ($prevFour[1] == '$this')) { | |
| $this->oBeaut->removeWhiteSpace(); | |
| } | |
| else { | |
| $this->oBeaut->addNewLineIndent(); | |
| for ($x = 0;$x < $this->oBeaut->getIndentNumber();$x++) { | |
| $this->oBeaut->add($this->oBeaut->getIndentChar()); | |
| } | |
| } | |
| } | |
| $this->oBeaut->add($sTag); | |
| } | |
| } | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ | |
| /** | |
| * Filter Fluent: Create fluent style for multi-level object access. | |
| * | |
| * PHP version 5 | |
| * | |
| * LICENSE: This source file is subject to version 3.0 of the PHP license | |
| * that is available through the world-wide-web at the following URI: | |
| * http://www.php.net/license/3_0.txt. If you did not receive a copy of | |
| * the PHP License and are unable to obtain it through the web, please | |
| * send a note to license@php.net so we can mail you a copy immediately. | |
| * | |
| * @category PHP | |
| * @package PHP_Beautifier | |
| * @subpackage Filter | |
| * @author Jesús Espino <jespinog@gmail.com> | |
| * @copyright 2010 Jesús Espino | |
| * @license http://www.php.net/license/3_0.txt PHP License 3.0 | |
| * @version CVS: $Id:$ | |
| * @link http://pear.php.net/package/PHP_Beautifier | |
| * @link http://beautifyphp.sourceforge.net | |
| */ | |
| /** | |
| * Filter Fluent: Create fluent style for multi-level object access. | |
| * Ex. | |
| * <CODE> | |
| * $this | |
| * ->addFile("a.txt") | |
| * ->addFile("b.txt") | |
| * ->addFile("c.txt"); | |
| * $this->addFile("d.txt"); | |
| * </CODE> | |
| * | |
| * @category PHP | |
| * @package PHP_Beautifier | |
| * @subpackage Filter | |
| * @author Jesús Espino <jespinog@gmail.com> | |
| * @copyright 2010 Jesús Espino | |
| * @license http://www.php.net/license/3_0.txt PHP License 3.0 | |
| * @version Release: @package_version@ | |
| * @link http://pear.php.net/package/PHP_Beautifier | |
| * @link http://beautifyphp.sourceforge.net | |
| */ | |
| class PHP_Beautifier_Filter_Fluent extends PHP_Beautifier_Filter | |
| { | |
| /** | |
| * t_object_operator | |
| * | |
| * @param mixed $sTag The tag to be processed | |
| * | |
| * @access public | |
| * @return void | |
| */ | |
| public function t_object_operator($sTag) | |
| { | |
| $counter = 1; | |
| $next = $this->oBeaut->getToken($this->oBeaut->iCount + $counter); | |
| while (($next[0] != T_OBJECT_OPERATOR) && ($next != ";")) | |
| { | |
| $counter++; | |
| $next = $this->oBeaut->getToken($this->oBeaut->iCount + $counter); | |
| } | |
| $counter = 1; | |
| $prev = $this->oBeaut->getToken($this->oBeaut->iCount - $counter); | |
| while (($prev[0] != T_OBJECT_OPERATOR) && ($prev[0] != T_VARIABLE)) | |
| { | |
| $counter++; | |
| $prev = $this->oBeaut->getToken($this->oBeaut->iCount - $counter); | |
| } | |
| $this->oBeaut->removeWhiteSpace(); | |
| if ($next[0] == T_OBJECT_OPERATOR || $prev[0] == T_OBJECT_OPERATOR) | |
| { | |
| $this->oBeaut->addNewLineIndent(); | |
| for ($x = 0; $x < $this->oBeaut->getIndentNumber(); $x++) | |
| { | |
| $this->oBeaut->add($this->oBeaut->getIndentChar()); | |
| } | |
| } | |
| $this->oBeaut->add($sTag); | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment