├── .gitignore ├── LICENSE ├── README.md ├── app ├── Abstracts │ ├── TranspilePhase.php │ └── Transpiler.php ├── CLI.php ├── CLIUtils │ ├── CLIBox.php │ └── CLIStr.php ├── Directory │ └── Extractor.php ├── Exception │ └── TranspilerError.php ├── TranspilePhases │ ├── BladeExpr.php │ ├── Cleanance.php │ ├── Comments.php │ ├── Keywords.php │ └── PhpTags.php └── Transpiler.php ├── bin └── php2blade ├── composer.json ├── composer.lock ├── img ├── 1.png ├── 2.png └── 3.png ├── php2blade ├── phpunit.xml └── tests ├── ConvertUnit ├── Clean.php ├── Comments.php ├── ConversionTest.php ├── Expression.php ├── Keywords.php └── PhpTag.php ├── MainTestCase.php └── bootstrap.php /.gitignore: -------------------------------------------------------------------------------- 1 | ./idea 2 | ./vendor 3 | !./vendor/autoload.php 4 | !./vendor/composer 5 | composer.lock -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Smarteist 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PHP To Blade Transpiler 2 | 3 | PHP2Blade is a php transpiler for converting ordinary php view files to laravel blade template engine files. 4 | 5 | ### Installation 6 | 7 | ```bash 8 | git clone https://github.com/smarteist/PHP2Blade.git 9 | ``` 10 | Then run: 11 | ```bash 12 | composer install 13 | ``` 14 | 15 | ### Usage 16 | By default you only need to pass directory of your files to the transpiler, 17 | your output files will be saved in ```/out``` directory in the same project. 18 | ```bash 19 | php php2blade 20 | ``` 21 | To remove comments we can add ```--removecomments``` switch 22 | ```bash 23 | php php2blade --removecomments 24 | ``` 25 | To prevent comments conversion add ```--keepcomments``` 26 | ```bash 27 | php php2blade --keepcomments <-optional- output directory> 28 | ``` 29 | ### Output Examples 30 | Some production ready outputs converted by PHP2Blade: 31 | 32 | ![Conversion one](https://raw.githubusercontent.com/smarteist/PHP2Blade/master/img/1.png) 33 | 34 | ![Conversion two](https://raw.githubusercontent.com/smarteist/PHP2Blade/master/img/2.png) 35 | 36 | ![Conversion three](https://raw.githubusercontent.com/smarteist/PHP2Blade/master/img/3.png) 37 | 38 | 39 | #### Contributing 40 | Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. 41 | 42 | Please make sure to update tests as appropriate. 43 | 44 | #### License 45 | [MIT](https://choosealicense.com/licenses/mit/) 46 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 47 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 48 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 49 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 50 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 51 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 52 | SOFTWARE. 53 | -------------------------------------------------------------------------------- /app/Abstracts/TranspilePhase.php: -------------------------------------------------------------------------------- 1 | subject = $input; 12 | } 13 | 14 | public function getPhpTags() 15 | { 16 | $regex = '/@php(\s*[\w\W]*?\s*)@endphp/m'; 17 | preg_match_all($regex, $this->subject, $matches, PREG_SET_ORDER); 18 | return $matches ?: []; 19 | } 20 | 21 | public function __toString() 22 | { 23 | return $this->getOutput(); 24 | } 25 | 26 | public function getOutput(): string 27 | { 28 | $this->doTrans(); 29 | return $this->subject; 30 | } 31 | 32 | public abstract function doTrans(); 33 | } -------------------------------------------------------------------------------- /app/Abstracts/Transpiler.php: -------------------------------------------------------------------------------- 1 | setupOptions($options); 31 | $this->setupSwitches($switches); 32 | 33 | if (sizeof($commands) < 2) { 34 | $this->showError( 35 | "Please specify directory of your source code!\n" . 36 | "Try 'php php2blade --help' for more information.", 37 | 'Not enough argument:' 38 | ); 39 | return; 40 | } else { 41 | if (sizeof($commands) === 2 && is_dir($commands[1])) { 42 | $baseDir = $commands[1]; 43 | } elseif (sizeof($commands) === 3 && is_dir($commands[1]) && is_dir($commands[2])) { 44 | $baseDir = $commands[1]; 45 | $destDir = $commands[2]; 46 | } else { 47 | $this->showError("Directory is not accessable!", "Invalid directory!"); 48 | //its not a valid directory 49 | return; 50 | } 51 | 52 | $files = Extractor::scan($baseDir); 53 | 54 | foreach ($files as $file) { 55 | 56 | $outputFile = Extractor::makeOutputFileDirectory($file, $baseDir, $destDir); 57 | echo "\t" . CLIStr::create("Converting : {$file} ") 58 | ->setColors('black', 'yellow') . PHP_EOL; 59 | $this->convert($file); 60 | Extractor::createBladeFile($outputFile, $this->getConvertedOutput()); 61 | echo "\t" . CLIStr::create("Saved in : {$outputFile}") 62 | ->bold() 63 | ->setColors('white', 'green') . PHP_EOL . PHP_EOL; 64 | } 65 | } 66 | 67 | echo CLIStr::create(PHP_EOL . "All Files Converted successfully!" . PHP_EOL . PHP_EOL . PHP_EOL)->setColors("green"); 68 | } 69 | 70 | /** 71 | * Applies conversion jobs on given source and saves in {$this->outputContent} 72 | * @param $source string file directory or php content of file. 73 | */ 74 | public function convert(string $source) 75 | { 76 | if (is_file($source)) { 77 | $this->outputContent = file_get_contents($source); 78 | } else { 79 | $this->outputContent = $source; 80 | } 81 | 82 | $transpiler = new Transpiler($this->outputContent); 83 | try { 84 | // The order of the phases is very important 85 | $transpiler->apply(PhpTags::class) 86 | ->apply(Comments::class) 87 | ->apply(Keywords::class) 88 | ->apply(BladeExpr::class) 89 | ->apply(Cleanance::class); 90 | 91 | } catch (Exception\TranspilerError $e) { 92 | $this->showError('Message: ' . $e->getMessage(), "Exception"); 93 | die(); 94 | } 95 | $this->outputContent = $transpiler->get(); 96 | 97 | } 98 | 99 | /** 100 | * @return string of current output content 101 | */ 102 | public function getConvertedOutput(): string 103 | { 104 | return $this->outputContent; 105 | } 106 | 107 | private function showHelp() 108 | { 109 | $helpContent = [ 110 | CLIStr::tableRow(['BASIC USAGE', 'DESCRIPTION',], [ 111 | "30", 112 | "50" 113 | ])->bold() 114 | ->setColors('red'), 115 | CLIStr::create(), 116 | CLIStr::tableRow([ 117 | 'php2blade ', 118 | 'Takes 2 directories and transpiles files from source directory ' 119 | ], [ 120 | "30", 121 | "50" 122 | ]), 123 | CLIStr::tableRow([ 124 | '', 125 | 'and saves it in the given destinaton .' 126 | ], [ 127 | "30", 128 | "50" 129 | ]), 130 | CLIStr::create(), 131 | CLIStr::create(), 132 | CLIStr::tableRow([ 133 | 'OPTIONS', 134 | 'DESCRIPTION' 135 | ], [ 136 | "30", 137 | "50" 138 | ])->bold()->setColors('red'), 139 | CLIStr::create(), 140 | CLIStr::tableRow([ 141 | '--removecomments', 142 | 'Ignores and deletes all comments.' 143 | ], [ 144 | "30", 145 | "50" 146 | ]), 147 | CLIStr::tableRow([ 148 | '--keepcomments', 149 | 'Prevents to convert comments to the blade.' 150 | ], [ 151 | "30", 152 | "50" 153 | ]), 154 | CLIStr::tableRow([ 155 | '--version', 156 | 'Retrieves current version.' 157 | ], [ 158 | "30", 159 | "50" 160 | ]) 161 | ]; 162 | 163 | echo (new CLIBox([ 164 | 'tableColor' => 'green', 165 | 'titleColor' => 'white', 166 | 'contentColor' => 'cyan', 167 | 'padding' => 1, 168 | 'margin' => 2, 169 | 'align' => 'left', 170 | ]))->getBox( 171 | $helpContent, 172 | CLIStr::create(' Help! ')->setColors('white'), 173 | CLIStr::create(' PHP2Blade ' . InstalledVersions::getRootPackage()['pretty_version'] . ' ')->setColors('green') 174 | ); 175 | exit(); 176 | 177 | 178 | } 179 | 180 | private function showError($message, $title = "Error!") 181 | { 182 | echo (new CLIBox([ 183 | 'tableColor' => 'red', 184 | 'titleColor' => 'white', 185 | 'contentColor' => 'cyan', 186 | 'padding' => 1, 187 | 'margin' => 2, 188 | 'align' => 'left', 189 | ]))->getBox( 190 | $message, 191 | CLIStr::create(" $title ")->setColors('white'), 192 | CLIStr::create(' PHP2Blade ' . InstalledVersions::getRootPackage()['pretty_version'] . ' ')->setColors('green') 193 | ); 194 | } 195 | 196 | private function setupSwitches($switches) 197 | { 198 | if (in_array('--help', $switches)) { 199 | $this->showHelp(); 200 | exit(); 201 | } 202 | 203 | if (in_array('--version', $switches)) { 204 | echo "PHP2Blade version: " . InstalledVersions::getRootPackage()['pretty_version'] . PHP_EOL; 205 | exit(); 206 | } 207 | 208 | if (in_array('--removecomments', $switches)) { 209 | define('REMOVE_COMMENTS', true); 210 | } 211 | 212 | if (in_array('--keepcomments', $switches)) { 213 | define('KEEP_COMMENTS', true); 214 | } 215 | } 216 | 217 | private function setupOptions($options) 218 | { 219 | if (in_array('-v', $options)) { 220 | echo "PHP2Blade version: " . InstalledVersions::getRootPackage()['pretty_version'] . PHP_EOL; 221 | exit(); 222 | } 223 | } 224 | 225 | } 226 | -------------------------------------------------------------------------------- /app/CLIUtils/CLIBox.php: -------------------------------------------------------------------------------- 1 | style = array_merge( 25 | [ 26 | 'padding' => 2, 27 | 'margin' => 4, 28 | 'align' => 'center', 29 | 'theme' => 1, 30 | 'tableColor' => '' 31 | ], 32 | $style 33 | ); 34 | } 35 | 36 | public function getBox($content, $title = null, $footer = null) 37 | { 38 | $themes = [ 39 | 1 => [ 40 | 'tr' => '╗', 41 | 'tl' => '╔', 42 | 'br' => '╝', 43 | 'bl' => '╚', 44 | 'h' => '═', 45 | 'v' => '║', 46 | ], 47 | 2 => [ 48 | 'tr' => '┐', 49 | 'tl' => '┌', 50 | 'br' => '┘', 51 | 'bl' => '└', 52 | 'h' => '─', 53 | 'v' => '│', 54 | ], 55 | 3 => [ 56 | 'tr' => '╮', 57 | 'tl' => '╭', 58 | 'br' => '╯', 59 | 'bl' => '╰', 60 | 'h' => '─', 61 | 'v' => '│', 62 | ], 63 | 4 => [ 64 | 'tr' => '+', 65 | 'tl' => '+', 66 | 'br' => '+', 67 | 'bl' => '+', 68 | 'h' => '-', 69 | 'v' => '|', 70 | ], 71 | ]; 72 | if (!is_array($this->style['theme'])) { 73 | $this->style['theme'] = $themes[$this->style['theme']] ?: $themes[1]; 74 | } 75 | if (!is_a($title, CLIStr::class)) { 76 | $title = CLIStr::create(""); 77 | } 78 | if (!is_a($footer, CLIStr::class)) { 79 | $footer = CLIStr::create(""); 80 | } 81 | $this->content = is_array($content) ? $content : explode(PHP_EOL, $content); 82 | for ($i = 0; $i < count($this->content); $i++) { 83 | if (!is_a($this->content[$i], CLIStr::class)) { 84 | $this->content[$i] = CLIStr::create($this->content[$i]); 85 | } 86 | } 87 | $this->boxWidth = $this->getBoxWidth($this->content, $title, $footer); 88 | 89 | $box = ''; 90 | // BOX HEAD 91 | $box .= $this->drawBoxHead($title); 92 | // BOX CONTENT 93 | $box .= $this->drawBoxContent(); 94 | // BOX FOOTER 95 | $box .= $this->drawBoxFoot($footer); 96 | return $box; 97 | } 98 | 99 | private function getBoxWidth($content, $title, $footer) 100 | { 101 | $boxWidth = max($title->length(), $footer->length()) + (2 * $this->style['padding']) + 2; 102 | foreach ($content as $str) { 103 | $length = $str->length() + (2 * $this->style['padding']) + 2; 104 | if ($length > $boxWidth) { 105 | $boxWidth = $length; 106 | } 107 | } 108 | return $boxWidth; 109 | } 110 | 111 | private function drawBoxMargin() 112 | { 113 | $margin = CLIStr::create(""); 114 | for ($i = 0; $i < $this->style['margin']; $i++) { 115 | $margin->append( 116 | CLIStr::create("") 117 | ->append(CLIStr::strRepeat(' ', $this->style['margin'])) 118 | ->append(CLIStr::strRepeat(' ', $this->boxWidth)) 119 | ->append(CLIStr::strRepeat(' ', $this->style['margin'])) 120 | ->setColors($this->style['tableColor']) . PHP_EOL 121 | ); 122 | } 123 | return $margin; 124 | } 125 | 126 | private function drawBoxHead($title) 127 | { 128 | $theme = $this->style['theme']; 129 | // BOX HEAD 130 | $head1 = CLIStr::create(CLIStr::strRepeat(' ', $this->style['margin'])) 131 | ->append(CLIStr::strRepeat($theme['tl'])) 132 | ->append(CLIStr::strRepeat($theme['h'])) 133 | ->setColors($this->style['tableColor']); 134 | 135 | $head2 = CLIStr::create(CLIStr::strRepeat($theme['h'], $this->boxWidth - $title->length() - 3)) 136 | ->append(CLIStr::strRepeat($theme['tr'])) 137 | ->append(CLIStr::strRepeat(' ', $this->style['margin'])) 138 | ->setColors($this->style['tableColor']); 139 | 140 | return $this->drawBoxMargin() . $head1 . $title . $head2 . PHP_EOL; 141 | } 142 | 143 | private function drawBoxContent() 144 | { 145 | $boxContent = CLIStr::create($this->drawBoxContentPadding()); 146 | foreach ($this->content as $str) { 147 | $boxContent->append($this->drawBoxContentAlignment($str)); 148 | } 149 | return $boxContent->append($this->drawBoxContentPadding()); 150 | } 151 | 152 | private function drawBoxContentAlignment($content) 153 | { 154 | $theme = $this->style['theme']; 155 | $align = $this->style['align']; 156 | $boxLeft = CLIStr::create(CLIStr::strRepeat(' ', $this->style['margin'])) 157 | ->append(CLIStr::strRepeat($theme['v'])) 158 | ->append(CLIStr::strRepeat(' ', $this->style['padding'])) 159 | ->setColors($this->style['tableColor']); 160 | 161 | $boxContent = CLIStr::create(); 162 | if ($align === 'right') { 163 | $boxContent->append(CLIStr::strRepeat(' ', $this->boxWidth - (2 * $this->style['padding']) - $content->length() - 2)) 164 | ->append($content); 165 | } else if ($align === 'center') { 166 | $space = $this->boxWidth - (2 * $this->style['padding']) - $content->length() - 2; 167 | $start = intval($space / 2); 168 | $boxContent->append(CLIStr::strRepeat(' ', $start)) 169 | ->append($content) 170 | ->append(CLIStr::strRepeat(' ', $space - $start)); 171 | } else { 172 | $boxContent->append($content) 173 | ->append(CLIStr::strRepeat(' ', $this->boxWidth - (2 * $this->style['padding']) - $content->length() - 2)); 174 | } 175 | 176 | $boxRight = CLIStr::create(CLIStr::strRepeat(' ', $this->style['padding'])) 177 | ->append(CLIStr::strRepeat($theme['v'])) 178 | ->append(CLIStr::strRepeat(' ', $this->style['margin'])) 179 | ->setColors($this->style['tableColor']); 180 | 181 | return $boxLeft . $boxContent . $boxRight . PHP_EOL; 182 | 183 | } 184 | 185 | private function drawBoxContentPadding() 186 | { 187 | $theme = $this->style['theme']; 188 | $boxPadding = CLIStr::create(); 189 | for ($i = 0; $i < $this->style['padding']; $i++) { 190 | $boxPadding->append( 191 | CLIStr::create(CLIStr::strRepeat(' ', $this->style['margin'])) 192 | ->append(CLIStr::strRepeat($theme['v'])) 193 | ->append(CLIStr::strRepeat(' ', $this->boxWidth - 2)) 194 | ->append(CLIStr::strRepeat($theme['v'])) 195 | ->append(CLIStr::strRepeat(' ', $this->style['margin'])) 196 | ->setColors($this->style['tableColor']) . PHP_EOL 197 | ); 198 | } 199 | return $boxPadding; 200 | 201 | } 202 | 203 | private function drawBoxFoot($footer) 204 | { 205 | $theme = $this->style['theme']; 206 | // BOX FOOTER 207 | $footer1 = CLIStr::create(CLIStr::strRepeat(' ', $this->style['margin'])) 208 | ->append(CLIStr::strRepeat($theme['bl'])) 209 | ->append(CLIStr::strRepeat($theme['h'])) 210 | ->setColors($this->style['tableColor']); 211 | 212 | $footer2 = CLIStr::create(CLIStr::strRepeat($theme['h'], $this->boxWidth - $footer->length() - 3)) 213 | ->append(CLIStr::strRepeat($theme['br'])) 214 | ->append(CLIStr::strRepeat(' ', $this->style['margin'])) 215 | ->setColors($this->style['tableColor']); 216 | 217 | return $footer1 . $footer . $footer2 . PHP_EOL . $this->drawBoxMargin(); 218 | 219 | } 220 | 221 | } 222 | -------------------------------------------------------------------------------- /app/CLIUtils/CLIStr.php: -------------------------------------------------------------------------------- 1 | [ 11 | 'reset_all' => '0', 12 | 'bold' => '1', 13 | 'dim' => '2', 14 | 'italic' => '3', 15 | 'underlined' => '4', 16 | 'blink' => '5', 17 | 'invert' => '7', 18 | 'hidden' => '8', 19 | 'strikethrough' => '9', 20 | 'reset_bold' => '21', 21 | 'reset_dim' => '22', 22 | 'reset_italic' => '23', 23 | 'reset_underlined' => '24', 24 | 'reset_blink' => '25', 25 | 'reset_invert' => '27', 26 | 'reset_hidden' => '28', 27 | 'reset_strikethrough' => '29', 28 | ], 29 | 'fg' => [ 30 | 'black' => '30', 31 | 'red' => '31', 32 | 'green' => '32', 33 | 'yellow' => '33', 34 | 'blue' => '34', 35 | 'purple' => '35', 36 | 'cyan' => '36', 37 | 'light_gray' => '37', 38 | 'default' => '39', 39 | 'dark_gray' => '90', 40 | 'light_red' => '91', 41 | 'light_green' => '92', 42 | 'light_yellow' => '93', 43 | 'light_blue' => '94', 44 | 'light_purple' => '95', 45 | 'light_cyan' => '96', 46 | 'white' => '97' 47 | ], 48 | 'bg' => [ 49 | 'black' => '40', 50 | 'red' => '41', 51 | 'green' => '42', 52 | 'yellow' => '43', 53 | 'blue' => '44', 54 | 'purple' => '45', 55 | 'cyan' => '46', 56 | 'light_gray' => '47', 57 | 'default' => '49', 58 | 'dark_gray' => '100', 59 | 'light_red' => '101', 60 | 'light_green' => '102', 61 | 'light_yellow' => '103', 62 | 'light_blue' => '104', 63 | 'light_purple' => '105', 64 | 'light_cyan' => '106', 65 | 'white' => '107', 66 | ] 67 | ]; 68 | 69 | private $value; 70 | 71 | private $textStyle = "0"; 72 | 73 | private $foreground = "39"; 74 | 75 | private $background = "49"; 76 | 77 | /** 78 | * CLIString constructor. 79 | * @param $value 80 | */ 81 | public function __construct($value) 82 | { 83 | $this->value = strval($value); 84 | } 85 | 86 | public static function strRepeat($string, $times = 1) 87 | { 88 | $output = ''; 89 | for ($i = 0; $i < $times; $i++) { 90 | $output .= $string; 91 | } 92 | return $output; 93 | } 94 | 95 | public static function consoleWrite($string, $removePrev = false) 96 | { 97 | global $consolePrevLines; 98 | if ($removePrev) { 99 | if (is_int($consolePrevLines)) 100 | self::clearLines($consolePrevLines); 101 | $consolePrevLines = sizeof(explode(PHP_EOL, $string)); 102 | } 103 | echo $string.PHP_EOL; 104 | } 105 | 106 | public static function clearLines($n = 1) 107 | { 108 | // move up and clear 109 | echo self::strRepeat("\033[1A" . "\x1b[2K", $n); 110 | } 111 | 112 | public static function tableRow($cols = [], $colsWidth = [], $separator = '') 113 | { 114 | if (empty($cols)) { 115 | return ''; 116 | } 117 | $mask = $separator; 118 | if (sizeof($cols) === sizeof($colsWidth)) { 119 | for ($i = sizeof($cols) - 1; $i >= 0; $i--) { 120 | $size = intval($colsWidth[$i]); 121 | $mask = $separator . "%-{$size}s " . $mask; 122 | } 123 | } else { 124 | $colWidth = intval(100 / count($cols)); 125 | for ($i = 1; $i <= count($cols); $i++) { 126 | $mask = $separator . "%-{$colWidth}s " . $mask; 127 | } 128 | } 129 | return CLIStr::create(vsprintf($mask, $cols)); 130 | } 131 | 132 | public static function create($value = null) 133 | { 134 | return new self($value); 135 | } 136 | 137 | public function length() 138 | { 139 | return strlen($this->value); 140 | } 141 | 142 | public function __toString() 143 | { 144 | return "\x1b[{$this->textStyle};{$this->foreground};{$this->background}m{$this->value}\x1b[0m"; 145 | } 146 | 147 | // Returns colored string 148 | public function setColors($foregroundColor = null, $backgroundColor = null) 149 | { 150 | // Check if given foreground color found 151 | if (isset($this->consoleStyle['fg'][$foregroundColor])) { 152 | $this->foreground = $this->consoleStyle['fg'][$foregroundColor]; 153 | } 154 | // Check if given background color found 155 | if (isset($this->consoleStyle['bg'][$backgroundColor])) { 156 | $this->background = $this->consoleStyle['bg'][$backgroundColor]; 157 | } 158 | return $this; 159 | } 160 | 161 | public function append($string) 162 | { 163 | $this->value .= $string; 164 | return $this; 165 | } 166 | 167 | public function prepend($string) 168 | { 169 | $this->value = $string . $this->value; 170 | return $this; 171 | } 172 | 173 | public function bold() 174 | { 175 | $this->textStyle = $this->consoleStyle['ts']['bold']; 176 | return $this; 177 | } 178 | 179 | public function dim() 180 | { 181 | $this->textStyle = $this->consoleStyle['ts']['dim']; 182 | return $this; 183 | } 184 | 185 | public function italic() 186 | { 187 | $this->textStyle = $this->consoleStyle['ts']['italic']; 188 | return $this; 189 | } 190 | 191 | public function underlined() 192 | { 193 | $this->textStyle = $this->consoleStyle['ts']['underlined']; 194 | return $this; 195 | } 196 | 197 | public function blink() 198 | { 199 | $this->textStyle = $this->consoleStyle['ts']['blink']; 200 | return $this; 201 | } 202 | 203 | public function invert() 204 | { 205 | $this->textStyle = $this->consoleStyle['ts']['invert']; 206 | return $this; 207 | } 208 | 209 | public function hidden() 210 | { 211 | $this->textStyle = $this->consoleStyle['ts']['hidden']; 212 | return $this; 213 | } 214 | 215 | public function strikethrough() 216 | { 217 | $this->textStyle = $this->consoleStyle['ts']['strikethrough']; 218 | return $this; 219 | } 220 | 221 | } 222 | -------------------------------------------------------------------------------- /app/Directory/Extractor.php: -------------------------------------------------------------------------------- 1 | subject = preg_replace($regex, "{!! $1 !!}", $this->subject); 14 | } 15 | 16 | 17 | } -------------------------------------------------------------------------------- /app/TranspilePhases/Cleanance.php: -------------------------------------------------------------------------------- 1 | getPhpTags() as $php) { 13 | $tag = $php[0]; 14 | $tag = preg_replace('/@php[\s;]*@endphp/m', '', $tag); 15 | $tag = preg_replace('/\s*@php\s+/m', "@php ", $tag); 16 | $tag = preg_replace('/\s+@endphp\s*/m', " @endphp", $tag); 17 | $this->subject = str_replace($php[0], $tag, $this->subject); 18 | } 19 | } 20 | 21 | 22 | } -------------------------------------------------------------------------------- /app/TranspilePhases/Comments.php: -------------------------------------------------------------------------------- 1 | getPhpTags() as $php) { 15 | $tag = $php[0]; 16 | $singleLineCommentsRegex = '/\/\/([^\n\r]*?)[\n\r]/'; 17 | $multiLineCommentsRegex = '/\/\*+([\w\W]*?)\*+\//m'; 18 | preg_match_all($singleLineCommentsRegex, $tag, $matchesSingle, PREG_SET_ORDER, 0); 19 | preg_match_all($multiLineCommentsRegex, $tag, $matchesMultiline, PREG_SET_ORDER, 0); 20 | $matchesSingle = $matchesSingle ?: []; 21 | $matchesMultiline = $matchesMultiline ?: []; 22 | foreach (array_merge($matchesSingle, $matchesMultiline) as $comment) { 23 | if (defined('REMOVE_COMMENTS')) { 24 | $tag = preg_replace([$singleLineCommentsRegex, $multiLineCommentsRegex], '', $tag); 25 | } else { 26 | $tag = "{{-- $comment[1] --}}" . PHP_EOL . preg_replace([$singleLineCommentsRegex, $multiLineCommentsRegex], '', $tag); 27 | } 28 | } 29 | $this->subject = str_replace($php[0], $tag, $this->subject); 30 | } 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /app/TranspilePhases/Keywords.php: -------------------------------------------------------------------------------- 1 | parametricKeywordsToBlade($this->subject, $keyword); 45 | } 46 | foreach ($this::nonParametricKeywords as $keyword) { 47 | $this->nonParametricKeywordsToBlade($this->subject, $keyword); 48 | } 49 | } 50 | 51 | 52 | /** 53 | * @param string $context of raw source code, as pointer 54 | * @param string $keyword the parametric keyword to be converted 55 | */ 56 | public function parametricKeywordsToBlade(string &$context, string $keyword) 57 | { 58 | if ($keyword === 'case') { 59 | $regex = "/\b{$keyword}\s*\(?([\w\W]+?)\)?\s*:/m"; 60 | } else { 61 | $regex = "/\b{$keyword}\s*\(((?:[^()]|\((?1)\))*+)\)\s*:/m"; 62 | } 63 | $replacement = " @endphp " . PHP_EOL . " @{$keyword} ($1) " . PHP_EOL . " @php "; 64 | 65 | $context = preg_replace($regex, $replacement, $context); 66 | 67 | } 68 | 69 | /** 70 | * @param string $context of raw source code, as pointer 71 | * @param string $keyword the non parametric keyword to be converted 72 | */ 73 | public function nonParametricKeywordsToBlade(string &$context, string $keyword) 74 | { 75 | $replacement = " @endphp " . PHP_EOL . " @{$keyword} " . PHP_EOL . " @php "; 76 | $context = preg_replace( 77 | "/\b((?|\Z)/m'; 13 | $replacement = "@php" . PHP_EOL . "$1" . PHP_EOL . "@endphp"; 14 | $this->subject = preg_replace($regex, $replacement, $this->subject); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /app/Transpiler.php: -------------------------------------------------------------------------------- 1 | subject = $input; 15 | } 16 | 17 | /** 18 | * @param string $phase 19 | * @return Transpiler 20 | * @throws TranspilerError 21 | */ 22 | public function apply(string $phase): Transpiler 23 | { 24 | if (class_exists($phase)) { 25 | $this->subject = new $phase($this->subject); 26 | } else { 27 | throw new TranspilerError("Unknown conversion phase: , class " . $phase . " not found!"); 28 | } 29 | return $this; 30 | } 31 | 32 | public function get(): string 33 | { 34 | return strval($this->subject); 35 | } 36 | } -------------------------------------------------------------------------------- /bin/php2blade: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # Get the absolute path of this executable 3 | ORIGDIR="$(pwd)" 4 | SELF_PATH="$(cd -P -- "$(dirname -- "$0")" && pwd -P)" && SELF_PATH="$SELF_PATH/$(basename -- "$0")" 5 | 6 | # Resolve symlinks - this is the equivalent of "readlink -f", but also works with non-standard OS X readlink. 7 | while [ -h "$SELF_PATH" ]; do 8 | # 1) cd to directory of the symlink 9 | # 2) cd to the directory of where the symlink points 10 | # 3) Get the pwd 11 | # 4) Append the basename 12 | DIR="$(dirname -- "$SELF_PATH")" 13 | SYM="$(readlink "$SELF_PATH")" 14 | SELF_PATH="$(cd "$DIR" && cd "$(dirname -- "$SYM")" && pwd)/$(basename -- "$SYM")" 15 | done 16 | cd "$ORIGDIR" || exit 17 | 18 | if [ ! -z "$CLI_APP_PHP" ] ; then 19 | # Use the CLI_APP_PHP environment variable if it is available. 20 | php="$CLI_APP_PHP" 21 | else 22 | # Default to using the php that we find on the PATH. 23 | # Note that we need the full path to php here for Dreamhost, which behaves oddly. See https://www.drupal.org/node/662926 24 | php="$(command -v php)" 25 | fi 26 | 27 | # Build the path to the root PHP file 28 | SCRIPT_PATH="$(dirname "$(dirname "$SELF_PATH")")/php2blade" 29 | case $("$php" -r "echo PHP_OS;") in 30 | WINNT*) 31 | SCRIPT_PATH="$(cygpath -w -a -- "$SCRIPT_PATH")" ;; 32 | esac 33 | 34 | # Pass in the path to php so that cli knows which one 35 | # to use if it re-launches itself to run other commands. 36 | export CLI_APP_PHP_USED="$php" 37 | 38 | # shellcheck disable=SC2086 39 | exec "$php" $CLI_APP_PHP_ARGS "$SCRIPT_PATH" "$@" 40 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ali/php2blade", 3 | "version": "1.0.0", 4 | "description": "It is a converter that converts PHP files to Blade syntax", 5 | "type": "library", 6 | "license": "apache", 7 | "scripts": { 8 | "test": "phpunit" 9 | }, 10 | "authors": [ 11 | { 12 | "name": "Ali Hn", 13 | "email": "ali.hosseini.sr@gmail.com" 14 | } 15 | ], 16 | "autoload": { 17 | "psr-4": { 18 | "App\\": "app" 19 | } 20 | }, 21 | "require-dev": { 22 | "phpunit/phpunit": "^8.5" 23 | }, 24 | "autoload-dev": { 25 | "psr-4": { 26 | "Tests\\": "tests" 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "33662b18d8f77cb9e45d6030cb3d4a37", 8 | "packages": [], 9 | "packages-dev": [ 10 | { 11 | "name": "doctrine/instantiator", 12 | "version": "1.4.1", 13 | "source": { 14 | "type": "git", 15 | "url": "https://github.com/doctrine/instantiator.git", 16 | "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc" 17 | }, 18 | "dist": { 19 | "type": "zip", 20 | "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc", 21 | "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc", 22 | "shasum": "" 23 | }, 24 | "require": { 25 | "php": "^7.1 || ^8.0" 26 | }, 27 | "require-dev": { 28 | "doctrine/coding-standard": "^9", 29 | "ext-pdo": "*", 30 | "ext-phar": "*", 31 | "phpbench/phpbench": "^0.16 || ^1", 32 | "phpstan/phpstan": "^1.4", 33 | "phpstan/phpstan-phpunit": "^1", 34 | "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", 35 | "vimeo/psalm": "^4.22" 36 | }, 37 | "type": "library", 38 | "autoload": { 39 | "psr-4": { 40 | "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" 41 | } 42 | }, 43 | "notification-url": "https://packagist.org/downloads/", 44 | "license": [ 45 | "MIT" 46 | ], 47 | "authors": [ 48 | { 49 | "name": "Marco Pivetta", 50 | "email": "ocramius@gmail.com", 51 | "homepage": "https://ocramius.github.io/" 52 | } 53 | ], 54 | "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", 55 | "homepage": "https://www.doctrine-project.org/projects/instantiator.html", 56 | "keywords": [ 57 | "constructor", 58 | "instantiate" 59 | ], 60 | "support": { 61 | "issues": "https://github.com/doctrine/instantiator/issues", 62 | "source": "https://github.com/doctrine/instantiator/tree/1.4.1" 63 | }, 64 | "funding": [ 65 | { 66 | "url": "https://www.doctrine-project.org/sponsorship.html", 67 | "type": "custom" 68 | }, 69 | { 70 | "url": "https://www.patreon.com/phpdoctrine", 71 | "type": "patreon" 72 | }, 73 | { 74 | "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", 75 | "type": "tidelift" 76 | } 77 | ], 78 | "time": "2022-03-03T08:28:38+00:00" 79 | }, 80 | { 81 | "name": "myclabs/deep-copy", 82 | "version": "1.11.0", 83 | "source": { 84 | "type": "git", 85 | "url": "https://github.com/myclabs/DeepCopy.git", 86 | "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" 87 | }, 88 | "dist": { 89 | "type": "zip", 90 | "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", 91 | "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", 92 | "shasum": "" 93 | }, 94 | "require": { 95 | "php": "^7.1 || ^8.0" 96 | }, 97 | "conflict": { 98 | "doctrine/collections": "<1.6.8", 99 | "doctrine/common": "<2.13.3 || >=3,<3.2.2" 100 | }, 101 | "require-dev": { 102 | "doctrine/collections": "^1.6.8", 103 | "doctrine/common": "^2.13.3 || ^3.2.2", 104 | "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" 105 | }, 106 | "type": "library", 107 | "autoload": { 108 | "files": [ 109 | "src/DeepCopy/deep_copy.php" 110 | ], 111 | "psr-4": { 112 | "DeepCopy\\": "src/DeepCopy/" 113 | } 114 | }, 115 | "notification-url": "https://packagist.org/downloads/", 116 | "license": [ 117 | "MIT" 118 | ], 119 | "description": "Create deep copies (clones) of your objects", 120 | "keywords": [ 121 | "clone", 122 | "copy", 123 | "duplicate", 124 | "object", 125 | "object graph" 126 | ], 127 | "support": { 128 | "issues": "https://github.com/myclabs/DeepCopy/issues", 129 | "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" 130 | }, 131 | "funding": [ 132 | { 133 | "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", 134 | "type": "tidelift" 135 | } 136 | ], 137 | "time": "2022-03-03T13:19:32+00:00" 138 | }, 139 | { 140 | "name": "phar-io/manifest", 141 | "version": "2.0.3", 142 | "source": { 143 | "type": "git", 144 | "url": "https://github.com/phar-io/manifest.git", 145 | "reference": "97803eca37d319dfa7826cc2437fc020857acb53" 146 | }, 147 | "dist": { 148 | "type": "zip", 149 | "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", 150 | "reference": "97803eca37d319dfa7826cc2437fc020857acb53", 151 | "shasum": "" 152 | }, 153 | "require": { 154 | "ext-dom": "*", 155 | "ext-phar": "*", 156 | "ext-xmlwriter": "*", 157 | "phar-io/version": "^3.0.1", 158 | "php": "^7.2 || ^8.0" 159 | }, 160 | "type": "library", 161 | "extra": { 162 | "branch-alias": { 163 | "dev-master": "2.0.x-dev" 164 | } 165 | }, 166 | "autoload": { 167 | "classmap": [ 168 | "src/" 169 | ] 170 | }, 171 | "notification-url": "https://packagist.org/downloads/", 172 | "license": [ 173 | "BSD-3-Clause" 174 | ], 175 | "authors": [ 176 | { 177 | "name": "Arne Blankerts", 178 | "email": "arne@blankerts.de", 179 | "role": "Developer" 180 | }, 181 | { 182 | "name": "Sebastian Heuer", 183 | "email": "sebastian@phpeople.de", 184 | "role": "Developer" 185 | }, 186 | { 187 | "name": "Sebastian Bergmann", 188 | "email": "sebastian@phpunit.de", 189 | "role": "Developer" 190 | } 191 | ], 192 | "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", 193 | "support": { 194 | "issues": "https://github.com/phar-io/manifest/issues", 195 | "source": "https://github.com/phar-io/manifest/tree/2.0.3" 196 | }, 197 | "time": "2021-07-20T11:28:43+00:00" 198 | }, 199 | { 200 | "name": "phar-io/version", 201 | "version": "3.2.1", 202 | "source": { 203 | "type": "git", 204 | "url": "https://github.com/phar-io/version.git", 205 | "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" 206 | }, 207 | "dist": { 208 | "type": "zip", 209 | "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", 210 | "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", 211 | "shasum": "" 212 | }, 213 | "require": { 214 | "php": "^7.2 || ^8.0" 215 | }, 216 | "type": "library", 217 | "autoload": { 218 | "classmap": [ 219 | "src/" 220 | ] 221 | }, 222 | "notification-url": "https://packagist.org/downloads/", 223 | "license": [ 224 | "BSD-3-Clause" 225 | ], 226 | "authors": [ 227 | { 228 | "name": "Arne Blankerts", 229 | "email": "arne@blankerts.de", 230 | "role": "Developer" 231 | }, 232 | { 233 | "name": "Sebastian Heuer", 234 | "email": "sebastian@phpeople.de", 235 | "role": "Developer" 236 | }, 237 | { 238 | "name": "Sebastian Bergmann", 239 | "email": "sebastian@phpunit.de", 240 | "role": "Developer" 241 | } 242 | ], 243 | "description": "Library for handling version information and constraints", 244 | "support": { 245 | "issues": "https://github.com/phar-io/version/issues", 246 | "source": "https://github.com/phar-io/version/tree/3.2.1" 247 | }, 248 | "time": "2022-02-21T01:04:05+00:00" 249 | }, 250 | { 251 | "name": "phpdocumentor/reflection-common", 252 | "version": "2.2.0", 253 | "source": { 254 | "type": "git", 255 | "url": "https://github.com/phpDocumentor/ReflectionCommon.git", 256 | "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" 257 | }, 258 | "dist": { 259 | "type": "zip", 260 | "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", 261 | "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", 262 | "shasum": "" 263 | }, 264 | "require": { 265 | "php": "^7.2 || ^8.0" 266 | }, 267 | "type": "library", 268 | "extra": { 269 | "branch-alias": { 270 | "dev-2.x": "2.x-dev" 271 | } 272 | }, 273 | "autoload": { 274 | "psr-4": { 275 | "phpDocumentor\\Reflection\\": "src/" 276 | } 277 | }, 278 | "notification-url": "https://packagist.org/downloads/", 279 | "license": [ 280 | "MIT" 281 | ], 282 | "authors": [ 283 | { 284 | "name": "Jaap van Otterdijk", 285 | "email": "opensource@ijaap.nl" 286 | } 287 | ], 288 | "description": "Common reflection classes used by phpdocumentor to reflect the code structure", 289 | "homepage": "http://www.phpdoc.org", 290 | "keywords": [ 291 | "FQSEN", 292 | "phpDocumentor", 293 | "phpdoc", 294 | "reflection", 295 | "static analysis" 296 | ], 297 | "support": { 298 | "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", 299 | "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" 300 | }, 301 | "time": "2020-06-27T09:03:43+00:00" 302 | }, 303 | { 304 | "name": "phpdocumentor/reflection-docblock", 305 | "version": "5.3.0", 306 | "source": { 307 | "type": "git", 308 | "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", 309 | "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" 310 | }, 311 | "dist": { 312 | "type": "zip", 313 | "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", 314 | "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", 315 | "shasum": "" 316 | }, 317 | "require": { 318 | "ext-filter": "*", 319 | "php": "^7.2 || ^8.0", 320 | "phpdocumentor/reflection-common": "^2.2", 321 | "phpdocumentor/type-resolver": "^1.3", 322 | "webmozart/assert": "^1.9.1" 323 | }, 324 | "require-dev": { 325 | "mockery/mockery": "~1.3.2", 326 | "psalm/phar": "^4.8" 327 | }, 328 | "type": "library", 329 | "extra": { 330 | "branch-alias": { 331 | "dev-master": "5.x-dev" 332 | } 333 | }, 334 | "autoload": { 335 | "psr-4": { 336 | "phpDocumentor\\Reflection\\": "src" 337 | } 338 | }, 339 | "notification-url": "https://packagist.org/downloads/", 340 | "license": [ 341 | "MIT" 342 | ], 343 | "authors": [ 344 | { 345 | "name": "Mike van Riel", 346 | "email": "me@mikevanriel.com" 347 | }, 348 | { 349 | "name": "Jaap van Otterdijk", 350 | "email": "account@ijaap.nl" 351 | } 352 | ], 353 | "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", 354 | "support": { 355 | "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", 356 | "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" 357 | }, 358 | "time": "2021-10-19T17:43:47+00:00" 359 | }, 360 | { 361 | "name": "phpdocumentor/type-resolver", 362 | "version": "1.6.1", 363 | "source": { 364 | "type": "git", 365 | "url": "https://github.com/phpDocumentor/TypeResolver.git", 366 | "reference": "77a32518733312af16a44300404e945338981de3" 367 | }, 368 | "dist": { 369 | "type": "zip", 370 | "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/77a32518733312af16a44300404e945338981de3", 371 | "reference": "77a32518733312af16a44300404e945338981de3", 372 | "shasum": "" 373 | }, 374 | "require": { 375 | "php": "^7.2 || ^8.0", 376 | "phpdocumentor/reflection-common": "^2.0" 377 | }, 378 | "require-dev": { 379 | "ext-tokenizer": "*", 380 | "psalm/phar": "^4.8" 381 | }, 382 | "type": "library", 383 | "extra": { 384 | "branch-alias": { 385 | "dev-1.x": "1.x-dev" 386 | } 387 | }, 388 | "autoload": { 389 | "psr-4": { 390 | "phpDocumentor\\Reflection\\": "src" 391 | } 392 | }, 393 | "notification-url": "https://packagist.org/downloads/", 394 | "license": [ 395 | "MIT" 396 | ], 397 | "authors": [ 398 | { 399 | "name": "Mike van Riel", 400 | "email": "me@mikevanriel.com" 401 | } 402 | ], 403 | "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", 404 | "support": { 405 | "issues": "https://github.com/phpDocumentor/TypeResolver/issues", 406 | "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.1" 407 | }, 408 | "time": "2022-03-15T21:29:03+00:00" 409 | }, 410 | { 411 | "name": "phpspec/prophecy", 412 | "version": "v1.15.0", 413 | "source": { 414 | "type": "git", 415 | "url": "https://github.com/phpspec/prophecy.git", 416 | "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13" 417 | }, 418 | "dist": { 419 | "type": "zip", 420 | "url": "https://api.github.com/repos/phpspec/prophecy/zipball/bbcd7380b0ebf3961ee21409db7b38bc31d69a13", 421 | "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13", 422 | "shasum": "" 423 | }, 424 | "require": { 425 | "doctrine/instantiator": "^1.2", 426 | "php": "^7.2 || ~8.0, <8.2", 427 | "phpdocumentor/reflection-docblock": "^5.2", 428 | "sebastian/comparator": "^3.0 || ^4.0", 429 | "sebastian/recursion-context": "^3.0 || ^4.0" 430 | }, 431 | "require-dev": { 432 | "phpspec/phpspec": "^6.0 || ^7.0", 433 | "phpunit/phpunit": "^8.0 || ^9.0" 434 | }, 435 | "type": "library", 436 | "extra": { 437 | "branch-alias": { 438 | "dev-master": "1.x-dev" 439 | } 440 | }, 441 | "autoload": { 442 | "psr-4": { 443 | "Prophecy\\": "src/Prophecy" 444 | } 445 | }, 446 | "notification-url": "https://packagist.org/downloads/", 447 | "license": [ 448 | "MIT" 449 | ], 450 | "authors": [ 451 | { 452 | "name": "Konstantin Kudryashov", 453 | "email": "ever.zet@gmail.com", 454 | "homepage": "http://everzet.com" 455 | }, 456 | { 457 | "name": "Marcello Duarte", 458 | "email": "marcello.duarte@gmail.com" 459 | } 460 | ], 461 | "description": "Highly opinionated mocking framework for PHP 5.3+", 462 | "homepage": "https://github.com/phpspec/prophecy", 463 | "keywords": [ 464 | "Double", 465 | "Dummy", 466 | "fake", 467 | "mock", 468 | "spy", 469 | "stub" 470 | ], 471 | "support": { 472 | "issues": "https://github.com/phpspec/prophecy/issues", 473 | "source": "https://github.com/phpspec/prophecy/tree/v1.15.0" 474 | }, 475 | "time": "2021-12-08T12:19:24+00:00" 476 | }, 477 | { 478 | "name": "phpunit/php-code-coverage", 479 | "version": "7.0.15", 480 | "source": { 481 | "type": "git", 482 | "url": "https://github.com/sebastianbergmann/php-code-coverage.git", 483 | "reference": "819f92bba8b001d4363065928088de22f25a3a48" 484 | }, 485 | "dist": { 486 | "type": "zip", 487 | "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/819f92bba8b001d4363065928088de22f25a3a48", 488 | "reference": "819f92bba8b001d4363065928088de22f25a3a48", 489 | "shasum": "" 490 | }, 491 | "require": { 492 | "ext-dom": "*", 493 | "ext-xmlwriter": "*", 494 | "php": ">=7.2", 495 | "phpunit/php-file-iterator": "^2.0.2", 496 | "phpunit/php-text-template": "^1.2.1", 497 | "phpunit/php-token-stream": "^3.1.3 || ^4.0", 498 | "sebastian/code-unit-reverse-lookup": "^1.0.1", 499 | "sebastian/environment": "^4.2.2", 500 | "sebastian/version": "^2.0.1", 501 | "theseer/tokenizer": "^1.1.3" 502 | }, 503 | "require-dev": { 504 | "phpunit/phpunit": "^8.2.2" 505 | }, 506 | "suggest": { 507 | "ext-xdebug": "^2.7.2" 508 | }, 509 | "type": "library", 510 | "extra": { 511 | "branch-alias": { 512 | "dev-master": "7.0-dev" 513 | } 514 | }, 515 | "autoload": { 516 | "classmap": [ 517 | "src/" 518 | ] 519 | }, 520 | "notification-url": "https://packagist.org/downloads/", 521 | "license": [ 522 | "BSD-3-Clause" 523 | ], 524 | "authors": [ 525 | { 526 | "name": "Sebastian Bergmann", 527 | "email": "sebastian@phpunit.de", 528 | "role": "lead" 529 | } 530 | ], 531 | "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", 532 | "homepage": "https://github.com/sebastianbergmann/php-code-coverage", 533 | "keywords": [ 534 | "coverage", 535 | "testing", 536 | "xunit" 537 | ], 538 | "support": { 539 | "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", 540 | "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/7.0.15" 541 | }, 542 | "funding": [ 543 | { 544 | "url": "https://github.com/sebastianbergmann", 545 | "type": "github" 546 | } 547 | ], 548 | "time": "2021-07-26T12:20:09+00:00" 549 | }, 550 | { 551 | "name": "phpunit/php-file-iterator", 552 | "version": "2.0.5", 553 | "source": { 554 | "type": "git", 555 | "url": "https://github.com/sebastianbergmann/php-file-iterator.git", 556 | "reference": "42c5ba5220e6904cbfe8b1a1bda7c0cfdc8c12f5" 557 | }, 558 | "dist": { 559 | "type": "zip", 560 | "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/42c5ba5220e6904cbfe8b1a1bda7c0cfdc8c12f5", 561 | "reference": "42c5ba5220e6904cbfe8b1a1bda7c0cfdc8c12f5", 562 | "shasum": "" 563 | }, 564 | "require": { 565 | "php": ">=7.1" 566 | }, 567 | "require-dev": { 568 | "phpunit/phpunit": "^8.5" 569 | }, 570 | "type": "library", 571 | "extra": { 572 | "branch-alias": { 573 | "dev-master": "2.0.x-dev" 574 | } 575 | }, 576 | "autoload": { 577 | "classmap": [ 578 | "src/" 579 | ] 580 | }, 581 | "notification-url": "https://packagist.org/downloads/", 582 | "license": [ 583 | "BSD-3-Clause" 584 | ], 585 | "authors": [ 586 | { 587 | "name": "Sebastian Bergmann", 588 | "email": "sebastian@phpunit.de", 589 | "role": "lead" 590 | } 591 | ], 592 | "description": "FilterIterator implementation that filters files based on a list of suffixes.", 593 | "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", 594 | "keywords": [ 595 | "filesystem", 596 | "iterator" 597 | ], 598 | "support": { 599 | "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", 600 | "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/2.0.5" 601 | }, 602 | "funding": [ 603 | { 604 | "url": "https://github.com/sebastianbergmann", 605 | "type": "github" 606 | } 607 | ], 608 | "time": "2021-12-02T12:42:26+00:00" 609 | }, 610 | { 611 | "name": "phpunit/php-text-template", 612 | "version": "1.2.1", 613 | "source": { 614 | "type": "git", 615 | "url": "https://github.com/sebastianbergmann/php-text-template.git", 616 | "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" 617 | }, 618 | "dist": { 619 | "type": "zip", 620 | "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", 621 | "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", 622 | "shasum": "" 623 | }, 624 | "require": { 625 | "php": ">=5.3.3" 626 | }, 627 | "type": "library", 628 | "autoload": { 629 | "classmap": [ 630 | "src/" 631 | ] 632 | }, 633 | "notification-url": "https://packagist.org/downloads/", 634 | "license": [ 635 | "BSD-3-Clause" 636 | ], 637 | "authors": [ 638 | { 639 | "name": "Sebastian Bergmann", 640 | "email": "sebastian@phpunit.de", 641 | "role": "lead" 642 | } 643 | ], 644 | "description": "Simple template engine.", 645 | "homepage": "https://github.com/sebastianbergmann/php-text-template/", 646 | "keywords": [ 647 | "template" 648 | ], 649 | "support": { 650 | "issues": "https://github.com/sebastianbergmann/php-text-template/issues", 651 | "source": "https://github.com/sebastianbergmann/php-text-template/tree/1.2.1" 652 | }, 653 | "time": "2015-06-21T13:50:34+00:00" 654 | }, 655 | { 656 | "name": "phpunit/php-timer", 657 | "version": "2.1.3", 658 | "source": { 659 | "type": "git", 660 | "url": "https://github.com/sebastianbergmann/php-timer.git", 661 | "reference": "2454ae1765516d20c4ffe103d85a58a9a3bd5662" 662 | }, 663 | "dist": { 664 | "type": "zip", 665 | "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/2454ae1765516d20c4ffe103d85a58a9a3bd5662", 666 | "reference": "2454ae1765516d20c4ffe103d85a58a9a3bd5662", 667 | "shasum": "" 668 | }, 669 | "require": { 670 | "php": ">=7.1" 671 | }, 672 | "require-dev": { 673 | "phpunit/phpunit": "^8.5" 674 | }, 675 | "type": "library", 676 | "extra": { 677 | "branch-alias": { 678 | "dev-master": "2.1-dev" 679 | } 680 | }, 681 | "autoload": { 682 | "classmap": [ 683 | "src/" 684 | ] 685 | }, 686 | "notification-url": "https://packagist.org/downloads/", 687 | "license": [ 688 | "BSD-3-Clause" 689 | ], 690 | "authors": [ 691 | { 692 | "name": "Sebastian Bergmann", 693 | "email": "sebastian@phpunit.de", 694 | "role": "lead" 695 | } 696 | ], 697 | "description": "Utility class for timing", 698 | "homepage": "https://github.com/sebastianbergmann/php-timer/", 699 | "keywords": [ 700 | "timer" 701 | ], 702 | "support": { 703 | "issues": "https://github.com/sebastianbergmann/php-timer/issues", 704 | "source": "https://github.com/sebastianbergmann/php-timer/tree/2.1.3" 705 | }, 706 | "funding": [ 707 | { 708 | "url": "https://github.com/sebastianbergmann", 709 | "type": "github" 710 | } 711 | ], 712 | "time": "2020-11-30T08:20:02+00:00" 713 | }, 714 | { 715 | "name": "phpunit/php-token-stream", 716 | "version": "4.0.4", 717 | "source": { 718 | "type": "git", 719 | "url": "https://github.com/sebastianbergmann/php-token-stream.git", 720 | "reference": "a853a0e183b9db7eed023d7933a858fa1c8d25a3" 721 | }, 722 | "dist": { 723 | "type": "zip", 724 | "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/a853a0e183b9db7eed023d7933a858fa1c8d25a3", 725 | "reference": "a853a0e183b9db7eed023d7933a858fa1c8d25a3", 726 | "shasum": "" 727 | }, 728 | "require": { 729 | "ext-tokenizer": "*", 730 | "php": "^7.3 || ^8.0" 731 | }, 732 | "require-dev": { 733 | "phpunit/phpunit": "^9.0" 734 | }, 735 | "type": "library", 736 | "extra": { 737 | "branch-alias": { 738 | "dev-master": "4.0-dev" 739 | } 740 | }, 741 | "autoload": { 742 | "classmap": [ 743 | "src/" 744 | ] 745 | }, 746 | "notification-url": "https://packagist.org/downloads/", 747 | "license": [ 748 | "BSD-3-Clause" 749 | ], 750 | "authors": [ 751 | { 752 | "name": "Sebastian Bergmann", 753 | "email": "sebastian@phpunit.de" 754 | } 755 | ], 756 | "description": "Wrapper around PHP's tokenizer extension.", 757 | "homepage": "https://github.com/sebastianbergmann/php-token-stream/", 758 | "keywords": [ 759 | "tokenizer" 760 | ], 761 | "support": { 762 | "issues": "https://github.com/sebastianbergmann/php-token-stream/issues", 763 | "source": "https://github.com/sebastianbergmann/php-token-stream/tree/master" 764 | }, 765 | "funding": [ 766 | { 767 | "url": "https://github.com/sebastianbergmann", 768 | "type": "github" 769 | } 770 | ], 771 | "abandoned": true, 772 | "time": "2020-08-04T08:28:15+00:00" 773 | }, 774 | { 775 | "name": "phpunit/phpunit", 776 | "version": "8.5.27", 777 | "source": { 778 | "type": "git", 779 | "url": "https://github.com/sebastianbergmann/phpunit.git", 780 | "reference": "df70070f2711b8fe8dcca0797c1239ede8c94be6" 781 | }, 782 | "dist": { 783 | "type": "zip", 784 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/df70070f2711b8fe8dcca0797c1239ede8c94be6", 785 | "reference": "df70070f2711b8fe8dcca0797c1239ede8c94be6", 786 | "shasum": "" 787 | }, 788 | "require": { 789 | "doctrine/instantiator": "^1.3.1", 790 | "ext-dom": "*", 791 | "ext-json": "*", 792 | "ext-libxml": "*", 793 | "ext-mbstring": "*", 794 | "ext-xml": "*", 795 | "ext-xmlwriter": "*", 796 | "myclabs/deep-copy": "^1.10.0", 797 | "phar-io/manifest": "^2.0.3", 798 | "phar-io/version": "^3.0.2", 799 | "php": ">=7.2", 800 | "phpspec/prophecy": "^1.10.3", 801 | "phpunit/php-code-coverage": "^7.0.12", 802 | "phpunit/php-file-iterator": "^2.0.4", 803 | "phpunit/php-text-template": "^1.2.1", 804 | "phpunit/php-timer": "^2.1.2", 805 | "sebastian/comparator": "^3.0.2", 806 | "sebastian/diff": "^3.0.2", 807 | "sebastian/environment": "^4.2.3", 808 | "sebastian/exporter": "^3.1.2", 809 | "sebastian/global-state": "^3.0.0", 810 | "sebastian/object-enumerator": "^3.0.3", 811 | "sebastian/resource-operations": "^2.0.1", 812 | "sebastian/type": "^1.1.3", 813 | "sebastian/version": "^2.0.1" 814 | }, 815 | "suggest": { 816 | "ext-soap": "*", 817 | "ext-xdebug": "*", 818 | "phpunit/php-invoker": "^2.0.0" 819 | }, 820 | "bin": [ 821 | "phpunit" 822 | ], 823 | "type": "library", 824 | "extra": { 825 | "branch-alias": { 826 | "dev-master": "8.5-dev" 827 | } 828 | }, 829 | "autoload": { 830 | "classmap": [ 831 | "src/" 832 | ] 833 | }, 834 | "notification-url": "https://packagist.org/downloads/", 835 | "license": [ 836 | "BSD-3-Clause" 837 | ], 838 | "authors": [ 839 | { 840 | "name": "Sebastian Bergmann", 841 | "email": "sebastian@phpunit.de", 842 | "role": "lead" 843 | } 844 | ], 845 | "description": "The PHP Unit Testing framework.", 846 | "homepage": "https://phpunit.de/", 847 | "keywords": [ 848 | "phpunit", 849 | "testing", 850 | "xunit" 851 | ], 852 | "support": { 853 | "issues": "https://github.com/sebastianbergmann/phpunit/issues", 854 | "source": "https://github.com/sebastianbergmann/phpunit/tree/8.5.27" 855 | }, 856 | "funding": [ 857 | { 858 | "url": "https://phpunit.de/sponsors.html", 859 | "type": "custom" 860 | }, 861 | { 862 | "url": "https://github.com/sebastianbergmann", 863 | "type": "github" 864 | } 865 | ], 866 | "time": "2022-06-19T12:11:16+00:00" 867 | }, 868 | { 869 | "name": "sebastian/code-unit-reverse-lookup", 870 | "version": "1.0.2", 871 | "source": { 872 | "type": "git", 873 | "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", 874 | "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619" 875 | }, 876 | "dist": { 877 | "type": "zip", 878 | "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/1de8cd5c010cb153fcd68b8d0f64606f523f7619", 879 | "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619", 880 | "shasum": "" 881 | }, 882 | "require": { 883 | "php": ">=5.6" 884 | }, 885 | "require-dev": { 886 | "phpunit/phpunit": "^8.5" 887 | }, 888 | "type": "library", 889 | "extra": { 890 | "branch-alias": { 891 | "dev-master": "1.0.x-dev" 892 | } 893 | }, 894 | "autoload": { 895 | "classmap": [ 896 | "src/" 897 | ] 898 | }, 899 | "notification-url": "https://packagist.org/downloads/", 900 | "license": [ 901 | "BSD-3-Clause" 902 | ], 903 | "authors": [ 904 | { 905 | "name": "Sebastian Bergmann", 906 | "email": "sebastian@phpunit.de" 907 | } 908 | ], 909 | "description": "Looks up which function or method a line of code belongs to", 910 | "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", 911 | "support": { 912 | "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", 913 | "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/1.0.2" 914 | }, 915 | "funding": [ 916 | { 917 | "url": "https://github.com/sebastianbergmann", 918 | "type": "github" 919 | } 920 | ], 921 | "time": "2020-11-30T08:15:22+00:00" 922 | }, 923 | { 924 | "name": "sebastian/comparator", 925 | "version": "3.0.3", 926 | "source": { 927 | "type": "git", 928 | "url": "https://github.com/sebastianbergmann/comparator.git", 929 | "reference": "1071dfcef776a57013124ff35e1fc41ccd294758" 930 | }, 931 | "dist": { 932 | "type": "zip", 933 | "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1071dfcef776a57013124ff35e1fc41ccd294758", 934 | "reference": "1071dfcef776a57013124ff35e1fc41ccd294758", 935 | "shasum": "" 936 | }, 937 | "require": { 938 | "php": ">=7.1", 939 | "sebastian/diff": "^3.0", 940 | "sebastian/exporter": "^3.1" 941 | }, 942 | "require-dev": { 943 | "phpunit/phpunit": "^8.5" 944 | }, 945 | "type": "library", 946 | "extra": { 947 | "branch-alias": { 948 | "dev-master": "3.0-dev" 949 | } 950 | }, 951 | "autoload": { 952 | "classmap": [ 953 | "src/" 954 | ] 955 | }, 956 | "notification-url": "https://packagist.org/downloads/", 957 | "license": [ 958 | "BSD-3-Clause" 959 | ], 960 | "authors": [ 961 | { 962 | "name": "Sebastian Bergmann", 963 | "email": "sebastian@phpunit.de" 964 | }, 965 | { 966 | "name": "Jeff Welch", 967 | "email": "whatthejeff@gmail.com" 968 | }, 969 | { 970 | "name": "Volker Dusch", 971 | "email": "github@wallbash.com" 972 | }, 973 | { 974 | "name": "Bernhard Schussek", 975 | "email": "bschussek@2bepublished.at" 976 | } 977 | ], 978 | "description": "Provides the functionality to compare PHP values for equality", 979 | "homepage": "https://github.com/sebastianbergmann/comparator", 980 | "keywords": [ 981 | "comparator", 982 | "compare", 983 | "equality" 984 | ], 985 | "support": { 986 | "issues": "https://github.com/sebastianbergmann/comparator/issues", 987 | "source": "https://github.com/sebastianbergmann/comparator/tree/3.0.3" 988 | }, 989 | "funding": [ 990 | { 991 | "url": "https://github.com/sebastianbergmann", 992 | "type": "github" 993 | } 994 | ], 995 | "time": "2020-11-30T08:04:30+00:00" 996 | }, 997 | { 998 | "name": "sebastian/diff", 999 | "version": "3.0.3", 1000 | "source": { 1001 | "type": "git", 1002 | "url": "https://github.com/sebastianbergmann/diff.git", 1003 | "reference": "14f72dd46eaf2f2293cbe79c93cc0bc43161a211" 1004 | }, 1005 | "dist": { 1006 | "type": "zip", 1007 | "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/14f72dd46eaf2f2293cbe79c93cc0bc43161a211", 1008 | "reference": "14f72dd46eaf2f2293cbe79c93cc0bc43161a211", 1009 | "shasum": "" 1010 | }, 1011 | "require": { 1012 | "php": ">=7.1" 1013 | }, 1014 | "require-dev": { 1015 | "phpunit/phpunit": "^7.5 || ^8.0", 1016 | "symfony/process": "^2 || ^3.3 || ^4" 1017 | }, 1018 | "type": "library", 1019 | "extra": { 1020 | "branch-alias": { 1021 | "dev-master": "3.0-dev" 1022 | } 1023 | }, 1024 | "autoload": { 1025 | "classmap": [ 1026 | "src/" 1027 | ] 1028 | }, 1029 | "notification-url": "https://packagist.org/downloads/", 1030 | "license": [ 1031 | "BSD-3-Clause" 1032 | ], 1033 | "authors": [ 1034 | { 1035 | "name": "Sebastian Bergmann", 1036 | "email": "sebastian@phpunit.de" 1037 | }, 1038 | { 1039 | "name": "Kore Nordmann", 1040 | "email": "mail@kore-nordmann.de" 1041 | } 1042 | ], 1043 | "description": "Diff implementation", 1044 | "homepage": "https://github.com/sebastianbergmann/diff", 1045 | "keywords": [ 1046 | "diff", 1047 | "udiff", 1048 | "unidiff", 1049 | "unified diff" 1050 | ], 1051 | "support": { 1052 | "issues": "https://github.com/sebastianbergmann/diff/issues", 1053 | "source": "https://github.com/sebastianbergmann/diff/tree/3.0.3" 1054 | }, 1055 | "funding": [ 1056 | { 1057 | "url": "https://github.com/sebastianbergmann", 1058 | "type": "github" 1059 | } 1060 | ], 1061 | "time": "2020-11-30T07:59:04+00:00" 1062 | }, 1063 | { 1064 | "name": "sebastian/environment", 1065 | "version": "4.2.4", 1066 | "source": { 1067 | "type": "git", 1068 | "url": "https://github.com/sebastianbergmann/environment.git", 1069 | "reference": "d47bbbad83711771f167c72d4e3f25f7fcc1f8b0" 1070 | }, 1071 | "dist": { 1072 | "type": "zip", 1073 | "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/d47bbbad83711771f167c72d4e3f25f7fcc1f8b0", 1074 | "reference": "d47bbbad83711771f167c72d4e3f25f7fcc1f8b0", 1075 | "shasum": "" 1076 | }, 1077 | "require": { 1078 | "php": ">=7.1" 1079 | }, 1080 | "require-dev": { 1081 | "phpunit/phpunit": "^7.5" 1082 | }, 1083 | "suggest": { 1084 | "ext-posix": "*" 1085 | }, 1086 | "type": "library", 1087 | "extra": { 1088 | "branch-alias": { 1089 | "dev-master": "4.2-dev" 1090 | } 1091 | }, 1092 | "autoload": { 1093 | "classmap": [ 1094 | "src/" 1095 | ] 1096 | }, 1097 | "notification-url": "https://packagist.org/downloads/", 1098 | "license": [ 1099 | "BSD-3-Clause" 1100 | ], 1101 | "authors": [ 1102 | { 1103 | "name": "Sebastian Bergmann", 1104 | "email": "sebastian@phpunit.de" 1105 | } 1106 | ], 1107 | "description": "Provides functionality to handle HHVM/PHP environments", 1108 | "homepage": "http://www.github.com/sebastianbergmann/environment", 1109 | "keywords": [ 1110 | "Xdebug", 1111 | "environment", 1112 | "hhvm" 1113 | ], 1114 | "support": { 1115 | "issues": "https://github.com/sebastianbergmann/environment/issues", 1116 | "source": "https://github.com/sebastianbergmann/environment/tree/4.2.4" 1117 | }, 1118 | "funding": [ 1119 | { 1120 | "url": "https://github.com/sebastianbergmann", 1121 | "type": "github" 1122 | } 1123 | ], 1124 | "time": "2020-11-30T07:53:42+00:00" 1125 | }, 1126 | { 1127 | "name": "sebastian/exporter", 1128 | "version": "3.1.4", 1129 | "source": { 1130 | "type": "git", 1131 | "url": "https://github.com/sebastianbergmann/exporter.git", 1132 | "reference": "0c32ea2e40dbf59de29f3b49bf375176ce7dd8db" 1133 | }, 1134 | "dist": { 1135 | "type": "zip", 1136 | "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/0c32ea2e40dbf59de29f3b49bf375176ce7dd8db", 1137 | "reference": "0c32ea2e40dbf59de29f3b49bf375176ce7dd8db", 1138 | "shasum": "" 1139 | }, 1140 | "require": { 1141 | "php": ">=7.0", 1142 | "sebastian/recursion-context": "^3.0" 1143 | }, 1144 | "require-dev": { 1145 | "ext-mbstring": "*", 1146 | "phpunit/phpunit": "^8.5" 1147 | }, 1148 | "type": "library", 1149 | "extra": { 1150 | "branch-alias": { 1151 | "dev-master": "3.1.x-dev" 1152 | } 1153 | }, 1154 | "autoload": { 1155 | "classmap": [ 1156 | "src/" 1157 | ] 1158 | }, 1159 | "notification-url": "https://packagist.org/downloads/", 1160 | "license": [ 1161 | "BSD-3-Clause" 1162 | ], 1163 | "authors": [ 1164 | { 1165 | "name": "Sebastian Bergmann", 1166 | "email": "sebastian@phpunit.de" 1167 | }, 1168 | { 1169 | "name": "Jeff Welch", 1170 | "email": "whatthejeff@gmail.com" 1171 | }, 1172 | { 1173 | "name": "Volker Dusch", 1174 | "email": "github@wallbash.com" 1175 | }, 1176 | { 1177 | "name": "Adam Harvey", 1178 | "email": "aharvey@php.net" 1179 | }, 1180 | { 1181 | "name": "Bernhard Schussek", 1182 | "email": "bschussek@gmail.com" 1183 | } 1184 | ], 1185 | "description": "Provides the functionality to export PHP variables for visualization", 1186 | "homepage": "http://www.github.com/sebastianbergmann/exporter", 1187 | "keywords": [ 1188 | "export", 1189 | "exporter" 1190 | ], 1191 | "support": { 1192 | "issues": "https://github.com/sebastianbergmann/exporter/issues", 1193 | "source": "https://github.com/sebastianbergmann/exporter/tree/3.1.4" 1194 | }, 1195 | "funding": [ 1196 | { 1197 | "url": "https://github.com/sebastianbergmann", 1198 | "type": "github" 1199 | } 1200 | ], 1201 | "time": "2021-11-11T13:51:24+00:00" 1202 | }, 1203 | { 1204 | "name": "sebastian/global-state", 1205 | "version": "3.0.2", 1206 | "source": { 1207 | "type": "git", 1208 | "url": "https://github.com/sebastianbergmann/global-state.git", 1209 | "reference": "de036ec91d55d2a9e0db2ba975b512cdb1c23921" 1210 | }, 1211 | "dist": { 1212 | "type": "zip", 1213 | "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/de036ec91d55d2a9e0db2ba975b512cdb1c23921", 1214 | "reference": "de036ec91d55d2a9e0db2ba975b512cdb1c23921", 1215 | "shasum": "" 1216 | }, 1217 | "require": { 1218 | "php": ">=7.2", 1219 | "sebastian/object-reflector": "^1.1.1", 1220 | "sebastian/recursion-context": "^3.0" 1221 | }, 1222 | "require-dev": { 1223 | "ext-dom": "*", 1224 | "phpunit/phpunit": "^8.0" 1225 | }, 1226 | "suggest": { 1227 | "ext-uopz": "*" 1228 | }, 1229 | "type": "library", 1230 | "extra": { 1231 | "branch-alias": { 1232 | "dev-master": "3.0-dev" 1233 | } 1234 | }, 1235 | "autoload": { 1236 | "classmap": [ 1237 | "src/" 1238 | ] 1239 | }, 1240 | "notification-url": "https://packagist.org/downloads/", 1241 | "license": [ 1242 | "BSD-3-Clause" 1243 | ], 1244 | "authors": [ 1245 | { 1246 | "name": "Sebastian Bergmann", 1247 | "email": "sebastian@phpunit.de" 1248 | } 1249 | ], 1250 | "description": "Snapshotting of global state", 1251 | "homepage": "http://www.github.com/sebastianbergmann/global-state", 1252 | "keywords": [ 1253 | "global state" 1254 | ], 1255 | "support": { 1256 | "issues": "https://github.com/sebastianbergmann/global-state/issues", 1257 | "source": "https://github.com/sebastianbergmann/global-state/tree/3.0.2" 1258 | }, 1259 | "funding": [ 1260 | { 1261 | "url": "https://github.com/sebastianbergmann", 1262 | "type": "github" 1263 | } 1264 | ], 1265 | "time": "2022-02-10T06:55:38+00:00" 1266 | }, 1267 | { 1268 | "name": "sebastian/object-enumerator", 1269 | "version": "3.0.4", 1270 | "source": { 1271 | "type": "git", 1272 | "url": "https://github.com/sebastianbergmann/object-enumerator.git", 1273 | "reference": "e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2" 1274 | }, 1275 | "dist": { 1276 | "type": "zip", 1277 | "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2", 1278 | "reference": "e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2", 1279 | "shasum": "" 1280 | }, 1281 | "require": { 1282 | "php": ">=7.0", 1283 | "sebastian/object-reflector": "^1.1.1", 1284 | "sebastian/recursion-context": "^3.0" 1285 | }, 1286 | "require-dev": { 1287 | "phpunit/phpunit": "^6.0" 1288 | }, 1289 | "type": "library", 1290 | "extra": { 1291 | "branch-alias": { 1292 | "dev-master": "3.0.x-dev" 1293 | } 1294 | }, 1295 | "autoload": { 1296 | "classmap": [ 1297 | "src/" 1298 | ] 1299 | }, 1300 | "notification-url": "https://packagist.org/downloads/", 1301 | "license": [ 1302 | "BSD-3-Clause" 1303 | ], 1304 | "authors": [ 1305 | { 1306 | "name": "Sebastian Bergmann", 1307 | "email": "sebastian@phpunit.de" 1308 | } 1309 | ], 1310 | "description": "Traverses array structures and object graphs to enumerate all referenced objects", 1311 | "homepage": "https://github.com/sebastianbergmann/object-enumerator/", 1312 | "support": { 1313 | "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", 1314 | "source": "https://github.com/sebastianbergmann/object-enumerator/tree/3.0.4" 1315 | }, 1316 | "funding": [ 1317 | { 1318 | "url": "https://github.com/sebastianbergmann", 1319 | "type": "github" 1320 | } 1321 | ], 1322 | "time": "2020-11-30T07:40:27+00:00" 1323 | }, 1324 | { 1325 | "name": "sebastian/object-reflector", 1326 | "version": "1.1.2", 1327 | "source": { 1328 | "type": "git", 1329 | "url": "https://github.com/sebastianbergmann/object-reflector.git", 1330 | "reference": "9b8772b9cbd456ab45d4a598d2dd1a1bced6363d" 1331 | }, 1332 | "dist": { 1333 | "type": "zip", 1334 | "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/9b8772b9cbd456ab45d4a598d2dd1a1bced6363d", 1335 | "reference": "9b8772b9cbd456ab45d4a598d2dd1a1bced6363d", 1336 | "shasum": "" 1337 | }, 1338 | "require": { 1339 | "php": ">=7.0" 1340 | }, 1341 | "require-dev": { 1342 | "phpunit/phpunit": "^6.0" 1343 | }, 1344 | "type": "library", 1345 | "extra": { 1346 | "branch-alias": { 1347 | "dev-master": "1.1-dev" 1348 | } 1349 | }, 1350 | "autoload": { 1351 | "classmap": [ 1352 | "src/" 1353 | ] 1354 | }, 1355 | "notification-url": "https://packagist.org/downloads/", 1356 | "license": [ 1357 | "BSD-3-Clause" 1358 | ], 1359 | "authors": [ 1360 | { 1361 | "name": "Sebastian Bergmann", 1362 | "email": "sebastian@phpunit.de" 1363 | } 1364 | ], 1365 | "description": "Allows reflection of object attributes, including inherited and non-public ones", 1366 | "homepage": "https://github.com/sebastianbergmann/object-reflector/", 1367 | "support": { 1368 | "issues": "https://github.com/sebastianbergmann/object-reflector/issues", 1369 | "source": "https://github.com/sebastianbergmann/object-reflector/tree/1.1.2" 1370 | }, 1371 | "funding": [ 1372 | { 1373 | "url": "https://github.com/sebastianbergmann", 1374 | "type": "github" 1375 | } 1376 | ], 1377 | "time": "2020-11-30T07:37:18+00:00" 1378 | }, 1379 | { 1380 | "name": "sebastian/recursion-context", 1381 | "version": "3.0.1", 1382 | "source": { 1383 | "type": "git", 1384 | "url": "https://github.com/sebastianbergmann/recursion-context.git", 1385 | "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb" 1386 | }, 1387 | "dist": { 1388 | "type": "zip", 1389 | "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/367dcba38d6e1977be014dc4b22f47a484dac7fb", 1390 | "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb", 1391 | "shasum": "" 1392 | }, 1393 | "require": { 1394 | "php": ">=7.0" 1395 | }, 1396 | "require-dev": { 1397 | "phpunit/phpunit": "^6.0" 1398 | }, 1399 | "type": "library", 1400 | "extra": { 1401 | "branch-alias": { 1402 | "dev-master": "3.0.x-dev" 1403 | } 1404 | }, 1405 | "autoload": { 1406 | "classmap": [ 1407 | "src/" 1408 | ] 1409 | }, 1410 | "notification-url": "https://packagist.org/downloads/", 1411 | "license": [ 1412 | "BSD-3-Clause" 1413 | ], 1414 | "authors": [ 1415 | { 1416 | "name": "Sebastian Bergmann", 1417 | "email": "sebastian@phpunit.de" 1418 | }, 1419 | { 1420 | "name": "Jeff Welch", 1421 | "email": "whatthejeff@gmail.com" 1422 | }, 1423 | { 1424 | "name": "Adam Harvey", 1425 | "email": "aharvey@php.net" 1426 | } 1427 | ], 1428 | "description": "Provides functionality to recursively process PHP variables", 1429 | "homepage": "http://www.github.com/sebastianbergmann/recursion-context", 1430 | "support": { 1431 | "issues": "https://github.com/sebastianbergmann/recursion-context/issues", 1432 | "source": "https://github.com/sebastianbergmann/recursion-context/tree/3.0.1" 1433 | }, 1434 | "funding": [ 1435 | { 1436 | "url": "https://github.com/sebastianbergmann", 1437 | "type": "github" 1438 | } 1439 | ], 1440 | "time": "2020-11-30T07:34:24+00:00" 1441 | }, 1442 | { 1443 | "name": "sebastian/resource-operations", 1444 | "version": "2.0.2", 1445 | "source": { 1446 | "type": "git", 1447 | "url": "https://github.com/sebastianbergmann/resource-operations.git", 1448 | "reference": "31d35ca87926450c44eae7e2611d45a7a65ea8b3" 1449 | }, 1450 | "dist": { 1451 | "type": "zip", 1452 | "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/31d35ca87926450c44eae7e2611d45a7a65ea8b3", 1453 | "reference": "31d35ca87926450c44eae7e2611d45a7a65ea8b3", 1454 | "shasum": "" 1455 | }, 1456 | "require": { 1457 | "php": ">=7.1" 1458 | }, 1459 | "type": "library", 1460 | "extra": { 1461 | "branch-alias": { 1462 | "dev-master": "2.0-dev" 1463 | } 1464 | }, 1465 | "autoload": { 1466 | "classmap": [ 1467 | "src/" 1468 | ] 1469 | }, 1470 | "notification-url": "https://packagist.org/downloads/", 1471 | "license": [ 1472 | "BSD-3-Clause" 1473 | ], 1474 | "authors": [ 1475 | { 1476 | "name": "Sebastian Bergmann", 1477 | "email": "sebastian@phpunit.de" 1478 | } 1479 | ], 1480 | "description": "Provides a list of PHP built-in functions that operate on resources", 1481 | "homepage": "https://www.github.com/sebastianbergmann/resource-operations", 1482 | "support": { 1483 | "issues": "https://github.com/sebastianbergmann/resource-operations/issues", 1484 | "source": "https://github.com/sebastianbergmann/resource-operations/tree/2.0.2" 1485 | }, 1486 | "funding": [ 1487 | { 1488 | "url": "https://github.com/sebastianbergmann", 1489 | "type": "github" 1490 | } 1491 | ], 1492 | "time": "2020-11-30T07:30:19+00:00" 1493 | }, 1494 | { 1495 | "name": "sebastian/type", 1496 | "version": "1.1.4", 1497 | "source": { 1498 | "type": "git", 1499 | "url": "https://github.com/sebastianbergmann/type.git", 1500 | "reference": "0150cfbc4495ed2df3872fb31b26781e4e077eb4" 1501 | }, 1502 | "dist": { 1503 | "type": "zip", 1504 | "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/0150cfbc4495ed2df3872fb31b26781e4e077eb4", 1505 | "reference": "0150cfbc4495ed2df3872fb31b26781e4e077eb4", 1506 | "shasum": "" 1507 | }, 1508 | "require": { 1509 | "php": ">=7.2" 1510 | }, 1511 | "require-dev": { 1512 | "phpunit/phpunit": "^8.2" 1513 | }, 1514 | "type": "library", 1515 | "extra": { 1516 | "branch-alias": { 1517 | "dev-master": "1.1-dev" 1518 | } 1519 | }, 1520 | "autoload": { 1521 | "classmap": [ 1522 | "src/" 1523 | ] 1524 | }, 1525 | "notification-url": "https://packagist.org/downloads/", 1526 | "license": [ 1527 | "BSD-3-Clause" 1528 | ], 1529 | "authors": [ 1530 | { 1531 | "name": "Sebastian Bergmann", 1532 | "email": "sebastian@phpunit.de", 1533 | "role": "lead" 1534 | } 1535 | ], 1536 | "description": "Collection of value objects that represent the types of the PHP type system", 1537 | "homepage": "https://github.com/sebastianbergmann/type", 1538 | "support": { 1539 | "issues": "https://github.com/sebastianbergmann/type/issues", 1540 | "source": "https://github.com/sebastianbergmann/type/tree/1.1.4" 1541 | }, 1542 | "funding": [ 1543 | { 1544 | "url": "https://github.com/sebastianbergmann", 1545 | "type": "github" 1546 | } 1547 | ], 1548 | "time": "2020-11-30T07:25:11+00:00" 1549 | }, 1550 | { 1551 | "name": "sebastian/version", 1552 | "version": "2.0.1", 1553 | "source": { 1554 | "type": "git", 1555 | "url": "https://github.com/sebastianbergmann/version.git", 1556 | "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" 1557 | }, 1558 | "dist": { 1559 | "type": "zip", 1560 | "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", 1561 | "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", 1562 | "shasum": "" 1563 | }, 1564 | "require": { 1565 | "php": ">=5.6" 1566 | }, 1567 | "type": "library", 1568 | "extra": { 1569 | "branch-alias": { 1570 | "dev-master": "2.0.x-dev" 1571 | } 1572 | }, 1573 | "autoload": { 1574 | "classmap": [ 1575 | "src/" 1576 | ] 1577 | }, 1578 | "notification-url": "https://packagist.org/downloads/", 1579 | "license": [ 1580 | "BSD-3-Clause" 1581 | ], 1582 | "authors": [ 1583 | { 1584 | "name": "Sebastian Bergmann", 1585 | "email": "sebastian@phpunit.de", 1586 | "role": "lead" 1587 | } 1588 | ], 1589 | "description": "Library that helps with managing the version number of Git-hosted PHP projects", 1590 | "homepage": "https://github.com/sebastianbergmann/version", 1591 | "support": { 1592 | "issues": "https://github.com/sebastianbergmann/version/issues", 1593 | "source": "https://github.com/sebastianbergmann/version/tree/master" 1594 | }, 1595 | "time": "2016-10-03T07:35:21+00:00" 1596 | }, 1597 | { 1598 | "name": "theseer/tokenizer", 1599 | "version": "1.2.1", 1600 | "source": { 1601 | "type": "git", 1602 | "url": "https://github.com/theseer/tokenizer.git", 1603 | "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" 1604 | }, 1605 | "dist": { 1606 | "type": "zip", 1607 | "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", 1608 | "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", 1609 | "shasum": "" 1610 | }, 1611 | "require": { 1612 | "ext-dom": "*", 1613 | "ext-tokenizer": "*", 1614 | "ext-xmlwriter": "*", 1615 | "php": "^7.2 || ^8.0" 1616 | }, 1617 | "type": "library", 1618 | "autoload": { 1619 | "classmap": [ 1620 | "src/" 1621 | ] 1622 | }, 1623 | "notification-url": "https://packagist.org/downloads/", 1624 | "license": [ 1625 | "BSD-3-Clause" 1626 | ], 1627 | "authors": [ 1628 | { 1629 | "name": "Arne Blankerts", 1630 | "email": "arne@blankerts.de", 1631 | "role": "Developer" 1632 | } 1633 | ], 1634 | "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", 1635 | "support": { 1636 | "issues": "https://github.com/theseer/tokenizer/issues", 1637 | "source": "https://github.com/theseer/tokenizer/tree/1.2.1" 1638 | }, 1639 | "funding": [ 1640 | { 1641 | "url": "https://github.com/theseer", 1642 | "type": "github" 1643 | } 1644 | ], 1645 | "time": "2021-07-28T10:34:58+00:00" 1646 | }, 1647 | { 1648 | "name": "webmozart/assert", 1649 | "version": "1.11.0", 1650 | "source": { 1651 | "type": "git", 1652 | "url": "https://github.com/webmozarts/assert.git", 1653 | "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991" 1654 | }, 1655 | "dist": { 1656 | "type": "zip", 1657 | "url": "https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991", 1658 | "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991", 1659 | "shasum": "" 1660 | }, 1661 | "require": { 1662 | "ext-ctype": "*", 1663 | "php": "^7.2 || ^8.0" 1664 | }, 1665 | "conflict": { 1666 | "phpstan/phpstan": "<0.12.20", 1667 | "vimeo/psalm": "<4.6.1 || 4.6.2" 1668 | }, 1669 | "require-dev": { 1670 | "phpunit/phpunit": "^8.5.13" 1671 | }, 1672 | "type": "library", 1673 | "extra": { 1674 | "branch-alias": { 1675 | "dev-master": "1.10-dev" 1676 | } 1677 | }, 1678 | "autoload": { 1679 | "psr-4": { 1680 | "Webmozart\\Assert\\": "src/" 1681 | } 1682 | }, 1683 | "notification-url": "https://packagist.org/downloads/", 1684 | "license": [ 1685 | "MIT" 1686 | ], 1687 | "authors": [ 1688 | { 1689 | "name": "Bernhard Schussek", 1690 | "email": "bschussek@gmail.com" 1691 | } 1692 | ], 1693 | "description": "Assertions to validate method input/output with nice error messages.", 1694 | "keywords": [ 1695 | "assert", 1696 | "check", 1697 | "validate" 1698 | ], 1699 | "support": { 1700 | "issues": "https://github.com/webmozarts/assert/issues", 1701 | "source": "https://github.com/webmozarts/assert/tree/1.11.0" 1702 | }, 1703 | "time": "2022-06-03T18:03:27+00:00" 1704 | } 1705 | ], 1706 | "aliases": [], 1707 | "minimum-stability": "stable", 1708 | "stability-flags": [], 1709 | "prefer-stable": false, 1710 | "prefer-lowest": false, 1711 | "platform": [], 1712 | "platform-dev": [], 1713 | "plugin-api-version": "2.3.0" 1714 | } 1715 | -------------------------------------------------------------------------------- /img/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarteist/PHP2Blade/132bc85e8a77339043173ff2a9a60ef3d2085ee8/img/1.png -------------------------------------------------------------------------------- /img/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarteist/PHP2Blade/132bc85e8a77339043173ff2a9a60ef3d2085ee8/img/2.png -------------------------------------------------------------------------------- /img/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarteist/PHP2Blade/132bc85e8a77339043173ff2a9a60ef3d2085ee8/img/3.png -------------------------------------------------------------------------------- /php2blade: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | command 12 | $commands = preg_grep('/(^[^-].*)/', $argv); 13 | // matches args in form of => -option:value or -option 14 | $options = preg_grep('/^-(\w+)(:(\w+))?/', $argv); 15 | // matches args in form of => --option 16 | $switches = preg_grep('/^--(\w+)/', $argv); 17 | 18 | (new CLI())->boot($commands, $options, $switches); -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | tests/ConvertUnit 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/ConvertUnit/Clean.php: -------------------------------------------------------------------------------- 1 | phase = new \App\TranspilePhases\Cleanance(''); 15 | } 16 | 17 | public function testClean() 18 | { 19 | $case = "@php ; ; ; ; ; @endphp @php @endphp @php \n @endphp"; 20 | $this->phase->__construct($case); 21 | $this->phase->doTrans(); 22 | $this->assertStringNotContainsString('@php', $this->phase->getOutput()); 23 | $this->assertStringNotContainsString('@endphp', $this->phase->getOutput()); 24 | $this->assertStringNotContainsString(';', $this->phase->getOutput()); 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /tests/ConvertUnit/Comments.php: -------------------------------------------------------------------------------- 1 | phase = new \App\TranspilePhases\Comments(''); 15 | } 16 | 17 | public function testSingleLineComment() 18 | { 19 | $case = "@php //Comment" . PHP_EOL . "echo 'yes!';@endphp"; 20 | $this->phase->__construct($case); 21 | $this->phase->doTrans(); 22 | $this->assertStringContainsString('echo', $this->phase->getOutput()); 23 | $this->assertStringContainsString('yes!', $this->phase->getOutput()); 24 | $this->assertStringContainsString(';', $this->phase->getOutput()); 25 | $this->assertStringContainsString('{{-- Comment --}}', $this->phase->getOutput()); 26 | 27 | } 28 | 29 | public function testMultiLineComment() 30 | { 31 | $case = "@php /*Comment*/" . PHP_EOL . "echo 'yes!';@endphp"; 32 | $this->phase->__construct($case); 33 | $this->phase->doTrans(); 34 | $this->assertStringContainsString('echo', $this->phase->getOutput()); 35 | $this->assertStringContainsString('yes!', $this->phase->getOutput()); 36 | $this->assertStringContainsString(';', $this->phase->getOutput()); 37 | $this->assertStringContainsString('{{-- Comment --}}', $this->phase->getOutput()); 38 | 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /tests/ConvertUnit/ConversionTest.php: -------------------------------------------------------------------------------- 1 | converter = new CLI(); 18 | parent::setUp(); 19 | } 20 | 21 | 22 | public function testClosingTag() 23 | { 24 | $this->converter->convert(""); 25 | $out = $this->converter->getConvertedOutput(); 26 | $this->assertStringContainsString("@php", $out); 27 | $this->assertStringContainsString("@endphp", $out); 28 | } 29 | 30 | 31 | public function testNonClosingTag() 32 | { 33 | $this->converter->convert("converter->getConvertedOutput(); 35 | $this->assertStringContainsString("@php", $out); 36 | $this->assertStringContainsString("@endphp", $out); 37 | } 38 | 39 | 40 | public function testBladeExpression() 41 | { 42 | $this->converter->convert("converter->getConvertedOutput(); 44 | $this->assertEquals("{!! 'test' !!}", $out); 45 | } 46 | 47 | 48 | public function testBladeExpressionInHtml() 49 | { 50 | $this->converter->convert("

"); 51 | $out = $this->converter->getConvertedOutput(); 52 | $this->assertEquals("

", $out); 53 | } 54 | 55 | public function testWhileLoop() 56 | { 57 | $this->converter->convert(" "); 58 | $out = $this->converter->getConvertedOutput(); 59 | $this->assertStringContainsString("@endwhile", $out); 60 | $this->assertStringContainsString("@while", $out); 61 | } 62 | 63 | public function testForEachLoop() 64 | { 65 | $this->converter->convert(" "); 66 | $out = $this->converter->getConvertedOutput(); 67 | $this->assertStringContainsString("@endforeach", $out); 68 | $this->assertStringContainsString("@foreach", $out); 69 | } 70 | 71 | 72 | public function testIfStatements() 73 | { 74 | $this->converter->convert(" "); 75 | $out = $this->converter->getConvertedOutput(); 76 | $this->assertStringContainsString("@if", $out); 77 | $this->assertStringContainsString("@elseif", $out); 78 | $this->assertStringContainsString("@else", $out); 79 | $this->assertStringContainsString("@endif", $out); 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /tests/ConvertUnit/Expression.php: -------------------------------------------------------------------------------- 1 | phase = new \App\TranspilePhases\BladeExpr(''); 15 | } 16 | 17 | public function testExprWithoutSemicolon() 18 | { 19 | $case = "@php echo 'Hello Guys!' @endphp"; 20 | $this->phase->__construct($case); 21 | $this->phase->doTrans(); 22 | $this->assertStringNotContainsString('@php', $this->phase->getOutput()); 23 | $this->assertStringNotContainsString('@endphp', $this->phase->getOutput()); 24 | $this->assertStringNotContainsString('echo', $this->phase->getOutput()); 25 | $this->assertStringNotContainsString(';', $this->phase->getOutput()); 26 | $this->assertStringContainsString('{!! ', $this->phase->getOutput()); 27 | $this->assertStringContainsString(' !!}', $this->phase->getOutput()); 28 | $this->assertStringContainsString("'Hello Guys!'", $this->phase->getOutput()); 29 | } 30 | 31 | 32 | public function testExprFunction() 33 | { 34 | $case = "@php echo somefunc('arg'); @endphp"; 35 | $this->phase->__construct($case); 36 | $this->phase->doTrans(); 37 | $this->assertStringNotContainsString('@php', $this->phase->getOutput()); 38 | $this->assertStringNotContainsString('@endphp', $this->phase->getOutput()); 39 | $this->assertStringNotContainsString('echo', $this->phase->getOutput()); 40 | $this->assertStringNotContainsString(';', $this->phase->getOutput()); 41 | $this->assertStringContainsString('{!! ', $this->phase->getOutput()); 42 | $this->assertStringContainsString(' !!}', $this->phase->getOutput()); 43 | $this->assertStringContainsString("'arg'", $this->phase->getOutput()); 44 | $this->assertStringContainsString("somefunc", $this->phase->getOutput()); 45 | $this->assertStringContainsString("(", $this->phase->getOutput()); 46 | $this->assertStringContainsString(")", $this->phase->getOutput()); 47 | } 48 | 49 | public function testExpr() 50 | { 51 | $case = "@php echo 'Hello Guys! I have semicolon =>'; @endphp"; 52 | $this->phase->__construct($case); 53 | $this->phase->doTrans(); 54 | $this->assertStringNotContainsString('@php', $this->phase->getOutput()); 55 | $this->assertStringNotContainsString('@endphp', $this->phase->getOutput()); 56 | $this->assertStringNotContainsString('echo', $this->phase->getOutput()); 57 | $this->assertStringNotContainsString(';', $this->phase->getOutput()); 58 | $this->assertStringContainsString('{!! ', $this->phase->getOutput()); 59 | $this->assertStringContainsString(' !!}', $this->phase->getOutput()); 60 | $this->assertStringContainsString("'Hello Guys! I have semicolon =>'", $this->phase->getOutput()); 61 | } 62 | 63 | public function testExprWithConcatination() 64 | { 65 | $case = "@php echo 'Hello Guys!' . PHP_EOL . ' We're testing'; @endphp"; 66 | $this->phase->__construct($case); 67 | $this->phase->doTrans(); 68 | $this->assertStringNotContainsString('@php', $this->phase->getOutput()); 69 | $this->assertStringNotContainsString('@endphp', $this->phase->getOutput()); 70 | $this->assertStringNotContainsString('echo', $this->phase->getOutput()); 71 | $this->assertStringNotContainsString(';', $this->phase->getOutput()); 72 | $this->assertStringContainsString('{!! ', $this->phase->getOutput()); 73 | $this->assertStringContainsString(' !!}', $this->phase->getOutput()); 74 | $this->assertStringContainsString("' We're testing'", $this->phase->getOutput()); 75 | $this->assertStringContainsString("PHP_EOL", $this->phase->getOutput()); 76 | $this->assertStringContainsString("'Hello Guys!'", $this->phase->getOutput()); 77 | } 78 | } -------------------------------------------------------------------------------- /tests/ConvertUnit/Keywords.php: -------------------------------------------------------------------------------- 1 | phase = new \App\TranspilePhases\Keywords(''); 15 | } 16 | 17 | public function testParametrics() 18 | { 19 | $case = "@php if(true|false): @endphp
@php endif @endphp"; 20 | $this->phase->__construct($case); 21 | $this->phase->doTrans(); 22 | $this->assertStringContainsString('@if', $this->phase->getOutput()); 23 | $this->assertStringContainsString('@endif', $this->phase->getOutput()); 24 | $this->assertStringContainsString('true|false', $this->phase->getOutput()); 25 | 26 | $case = "@php while(true): @endphp
@php endwhile; @endphp"; 27 | $this->phase->__construct($case); 28 | $this->phase->doTrans(); 29 | $this->assertStringContainsString('@while', $this->phase->getOutput()); 30 | $this->assertStringContainsString('@endwhile', $this->phase->getOutput()); 31 | $this->assertStringContainsString('true', $this->phase->getOutput()); 32 | 33 | $case = "@php case \"test\": @endphp"; 34 | $this->phase->__construct($case); 35 | $this->phase->doTrans(); 36 | $this->assertStringContainsString('@case', $this->phase->getOutput()); 37 | $this->assertStringContainsString('"test"', $this->phase->getOutput()); 38 | } 39 | 40 | public function testNonParametrics() 41 | { 42 | $case = "@php break; @endphp"; 43 | $this->phase->__construct($case); 44 | $this->phase->doTrans(); 45 | $this->assertStringContainsString('@break', $this->phase->getOutput()); 46 | 47 | 48 | $case = "@php break @endphp"; 49 | $this->phase->__construct($case); 50 | $this->phase->doTrans(); 51 | $this->assertStringContainsString('@break', $this->phase->getOutput()); 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /tests/ConvertUnit/PhpTag.php: -------------------------------------------------------------------------------- 1 | phase = new \App\TranspilePhases\PhpTags(''); 15 | } 16 | 17 | public function testTags() 18 | { 19 | $case = "something else
phase->__construct($case); 21 | $this->phase->doTrans(); 22 | $this->assertStringContainsString('@php', $this->phase->getOutput()); 23 | $this->assertStringContainsString('@endphp', $this->phase->getOutput()); 24 | $this->assertStringContainsString('echo', $this->phase->getOutput()); 25 | $this->assertStringContainsString('yes!', $this->phase->getOutput()); 26 | $this->assertStringContainsString(';', $this->phase->getOutput()); 27 | $this->assertStringContainsString('die();', $this->phase->getOutput()); 28 | $this->assertStringEndsWith('@endphp', $this->phase->getOutput()); 29 | $this->assertEquals(2, substr_count($this->phase->getOutput(), '@php')); 30 | $this->assertEquals(2, substr_count($this->phase->getOutput(), '@endphp')); 31 | } 32 | 33 | 34 | public function testNonClosingTags() 35 | { 36 | $case = substr("\phase->__construct($case); 38 | $this->phase->doTrans(); 39 | $this->assertStringContainsString('@php', $this->phase->getOutput()); 40 | $this->assertStringContainsString('@endphp', $this->phase->getOutput()); 41 | $this->assertStringContainsString('echo', $this->phase->getOutput()); 42 | $this->assertStringContainsString("'yes!'", $this->phase->getOutput()); 43 | $this->assertStringContainsString('die()', $this->phase->getOutput()); 44 | $this->assertStringEndsWith('@endphp', $this->phase->getOutput()); 45 | $this->assertEquals(2, substr_count($this->phase->getOutput(), ';')); 46 | $this->assertEquals(1, substr_count($this->phase->getOutput(), '@php')); 47 | $this->assertEquals(1, substr_count($this->phase->getOutput(), '@endphp')); 48 | } 49 | 50 | } -------------------------------------------------------------------------------- /tests/MainTestCase.php: -------------------------------------------------------------------------------- 1 |