Skip to content

Commit

Permalink
implements key-word for class declaration, full syntax is now : Class…
Browse files Browse the repository at this point in the history
…Name:ExtendedClass <<< ImplementInterface1, ImplementInterface2
  • Loading branch information
Bastien committed Mar 16, 2014
1 parent c446c43 commit 88e2b76
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/sbp/sbp.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,19 @@ static public function isSbp($file)

static public function parseClass($match)
{
if(in_array(substr($match[0], 0, 1), str_split(',(+-/*&|'))
|| in_array($match[2], array('else', 'try', 'default:', 'echo', 'print', 'exit', 'continue', 'break', 'return', 'do')))
list($all, $start, $class, $extend, $implement, $end) = $match;
$class = trim($class);
if(in_array(substr($all, 0, 1), str_split(',(+-/*&|'))
|| in_array($class, array('else', 'try', 'default:', 'echo', 'print', 'exit', 'continue', 'break', 'return', 'do')))
{
return $match[0];
return $all;
}
$className = preg_replace('#^(?:'.self::ABSTRACT_SHORTCUTS.')\s+#', '', trim($match[2]), -1, $isAbstract);
$codeLine = $match[1].($isAbstract ? 'abstract ' : '').'class '.$className.(empty($match[3]) ? '' : ' extends '.trim($match[3])).' '.trim($match[4]);
return $codeLine.str_repeat("\n", substr_count($match[0], "\n") - substr_count($codeLine, "\n"));
$className = preg_replace('#^(?:'.self::ABSTRACT_SHORTCUTS.')\s+#', '', $class, -1, $isAbstract);
$codeLine = $start.($isAbstract ? 'abstract ' : '').'class '.$className.
(empty($extend) ? '' : ' extends '.trim($extend)).
(empty($implement) ? '' : ' implements '.trim($implement)).
' '.trim($end);
return $codeLine.str_repeat("\n", substr_count($all, "\n") - substr_count($codeLine, "\n"));
}

static private function findLastBlock(&$line, $block = array())
Expand Down Expand Up @@ -307,6 +312,18 @@ static public function parse($content)
(?:\\\\'.self::VALIDNAME.')*
)
)?
(?:
(?:<<<|\s+<<<\s+)
(
'.self::VALIDNAME.'
(?:\\\\'.self::VALIDNAME.')*
(?:
\s*,\s*
'.self::VALIDNAME.'
(?:\\\\'.self::VALIDNAME.')*
)*
)
)?
(
\s*
(?:{(?:.*})?)?
Expand Down

0 comments on commit 88e2b76

Please sign in to comment.