Commit 9b855a9d authored by Marco Schmiedel's avatar Marco Schmiedel

fix beautifier class regex

parent fe26e9f0
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
| sidekick package. | sidekick package.
| |
| Author: Marco Schmiedel <marco.schmiedel@itmax.email> | Author: Marco Schmiedel <marco.schmiedel@itmax.email>
| Date: 2021-12-23 19:50:42 | Date: 2021-12-23 20:30:33
| |
*/ */
namespace Ceetrox\Commands\CodebeautifierCommand; namespace Ceetrox\Commands\CodebeautifierCommand;
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
|------------------------------------------------------------------------------------ |------------------------------------------------------------------------------------
| Drop error for a wrong file path. | Drop error for a wrong file path.
*/ */
$file = $this->error('Please enter a valid file path!'); $file = $this->error('Please enter a valid path to a php class!');
/* /*
|------------------------------------------------------------------------------------ |------------------------------------------------------------------------------------
......
...@@ -215,19 +215,19 @@ ...@@ -215,19 +215,19 @@
|---------------------------------------------------------------------------------------- |----------------------------------------------------------------------------------------
| start Pattern | start Pattern
*/ */
$OpenPattern = '/[^;{}$*"]+class[^a-z\\\[(=-][^{;()[\]]+/s'; $openPattern = '/[^A-Za-z]+[^(A-Za-z0-9);{}$*"]+class[^a-z\\\[(=-][^{;()[\]]+/s';
/* /*
|---------------------------------------------------------------------------------------- |----------------------------------------------------------------------------------------
| stop Pattern | stop Pattern
*/ */
$ClosePattern = '/([^;{$}>*$()"]+\s*class[^a-z\\[(=-])|[\s\t\n]+$/'; $closePattern = '/([^A-Za-z]+[^(A-Za-z0-9);{$}>*$()"]+\s*class[^a-z\\[(=-])|[\s\t\n]+$/';
/* /*
|---------------------------------------------------------------------------------------- |----------------------------------------------------------------------------------------
| extract inbetween | extract inbetween
*/ */
$classes = $this->matchBetweenTwoPatterns($this->content, $OpenPattern, $ClosePattern); $classes = $this->matchBetweenTwoPatterns($this->content, $openPattern, $closePattern);
/* /*
|---------------------------------------------------------------------------------------- |----------------------------------------------------------------------------------------
...@@ -318,16 +318,16 @@ ...@@ -318,16 +318,16 @@
$Classstart = strpos($Class['Body'] , '{')+1; $Classstart = strpos($Class['Body'] , '{')+1;
$Classstop = strrpos($Class['Body'] , '}'); $Classstop = strrpos($Class['Body'] , '}');
$ClassCount = strlen($Class['Body']); $ClassCount = strlen($Class['Body']);
$Prepared = substr($Class['Body'], $Classstart, ($ClassCount-$Classstart)-($ClassCount-$Classstop)) ; $prepared = substr($Class['Body'], $Classstart, ($ClassCount-$Classstart)-($ClassCount-$Classstop)) ;
/* /*
|------------------------------------------------------------------------------------ |------------------------------------------------------------------------------------
| Similar to extracting the classes, a start and stopPattern is defined for the | Similar to extracting the classes, a start and stopPattern is defined for the
| methods. The methods are extracted between these regular expressions. | methods. The methods are extracted between these regular expressions.
*/ */
$OpenPattern = '/([^;{}]+function[^a-z\\\[(][^{;()[\]]+)/'; $openPattern = '/([^;{}]+function[^a-z\\\[(][^{;()[\]]+)/';
$ClosePattern = '/([^;{$}>\'"*]+\s*function[^a-z\\[(])|[\s\t\n]+$/'; $closePattern = '/([^;{$}>\'"*]+\s*function[^a-z\\[(])|[\s\t\n]+$/';
$results = $this->matchBetweenTwoPatterns($Prepared, $OpenPattern, $ClosePattern); $results = $this->matchBetweenTwoPatterns($prepared, $openPattern, $closePattern);
/* /*
|------------------------------------------------------------------------------------ |------------------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment