Skip to content

Commit

Permalink
big name refacturing
Browse files Browse the repository at this point in the history
  • Loading branch information
elmar-hinz committed Jun 13, 2016
1 parent 5f8a2be commit acafd93
Show file tree
Hide file tree
Showing 24 changed files with 113 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace ElmarHinz\TypoScriptParser;
namespace ElmarHinz\TypoScriptParser\Formatters;

use \ElmarHinz\TypoScriptParser\AbstractTypoScriptParser as AP;
use ElmarHinz\TypoScriptParser\Parsers\AbstractTypoScriptParser as AP;
use ElmarHinz\TypoScriptParser\Interfaces\TypoScriptFormatterInterface;

/**
* TypoScript syntax formatter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace ElmarHinz\TypoScriptParser;
namespace ElmarHinz\TypoScriptParser\Interfaces;

/**
* Interface of TypoScript formatters
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace ElmarHinz\TypoScriptParser;
namespace ElmarHinz\TypoScriptParser\Interfaces;

/**
* Tracker of the exceptions while parsing a TypoScript Template.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace ElmarHinz\TypoScriptParser;
namespace ElmarHinz\TypoScriptParser\Interfaces;

use \ElmarHinz\TypoScriptParser\Exceptions\TypoScriptParsetimeException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace ElmarHinz\TypoScriptParser;
namespace ElmarHinz\TypoScriptParser\Interfaces;

/**
* Pull the tokens from parsing a TypoScript template.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace ElmarHinz\TypoScriptParser;
namespace ElmarHinz\TypoScriptParser\Interfaces;

use \ElmarHinz\TypoScriptParser\Tokens\AbstractTypoScriptToken;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

namespace ElmarHinz\TypoScriptParser;
namespace ElmarHinz\TypoScriptParser\Interfaces;

interface ValueModifierInterface
interface TypoScriptValueModifierInterface
{

/**
* Modify the input string by the given operation.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
<?php

namespace ElmarHinz\TypoScriptParser;
namespace ElmarHinz\TypoScriptParser\Main;

use \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser as CoreParser;
use \ElmarHinz\TypoScriptParser\TypoScriptProductionParser as ProductionParser;
use \ElmarHinz\TypoScriptParser\TypoScriptConditionsProcessor as ConditionsProcessor;
use \ElmarHinz\TypoScriptParser\TypoScriptSyntaxParser as SyntaxParser;
use \ElmarHinz\TypoScriptParser\TypoScriptFormatter as Formatter;
use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser
as CoreParser;
use ElmarHinz\TypoScriptParser\Parsers\TypoScriptProductionParser
as ProductionParser;
use ElmarHinz\TypoScriptParser\Parsers\TypoScriptConditionsProcessor
as ConditionsProcessor;
use ElmarHinz\TypoScriptParser\Parsers\TypoScriptSyntaxParser
as SyntaxParser;
use ElmarHinz\TypoScriptParser\TypoScriptFormatter
as Formatter;
use ElmarHinz\TypoScriptParser\Interfaces\TypoScriptValueModifierInterface;

class CoreTypoScriptParserAdapter extends CoreParser implements ValueModifierInterface
class CoreTypoScriptParserAdapter extends CoreParser
implements TypoScriptValueModifierInterface
{

public function parse($string, $matchObj = '')
Expand All @@ -26,9 +33,10 @@ public function parse($string, $matchObj = '')
public function modifyValue($value, $operation)
{
$pattern = '/^([[:alpha:]]+)\\s*\\((.*)\\).*/';
if(preg_match($pattern, $operation, $matches)) {
if (preg_match($pattern, $operation, $matches)) {
list(,$modifier, $argument) = $matches;
return (string)$this->executeValueModifier($modifier, $argument, $value);
return (string)$this->executeValueModifier(
$modifier, $argument, $value);
} else {
// Error handling: not well formatted modifier
}
Expand All @@ -41,10 +49,12 @@ public function modifyValue($value, $operation)
* @param array The first entry is the line number offset.
* @param bool Toggle blockmode.
*/
public function doSyntaxHighlight($template, $numbers = null, $blockmode = false)
public function doSyntaxHighlight($template, $numbers = null,
$blockmode = false)
{
$formatter = new Formatter();
if(is_array($numbers) && count($numbers) > 0 && is_int($numbers[0])) {
if (is_array($numbers) && count($numbers) > 0
&& is_int($numbers[0])) {
$formatter->setNumberOfBaseLine($numbers[0]);
} else {
$formatter->hideLineNumbers();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace ElmarHinz\TypoScriptParser;
namespace ElmarHinz\TypoScriptParser\Parsers;

abstract class AbstractTypoScriptParser
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace ElmarHinz\TypoScriptParser;
namespace ElmarHinz\TypoScriptParser\Parsers;

use ElmarHinz\TypoScriptParser\TypoScriptTokenTrackerPushInterface
use ElmarHinz\TypoScriptParser\Interfaces\TypoScriptTokenTrackerPushInterface
as TokenTracker;
use ElmarHinz\TypoScriptParser\TypoScriptPasetimeExceptionTrackerPushInterface
use ElmarHinz\TypoScriptParser\Interfaces\TypoScriptPasetimeExceptionTrackerPushInterface
as ExceptionTracker;

abstract class AbstractTypoScriptSyntaxParser extends AbstractTypoScriptParser
Expand Down Expand Up @@ -34,5 +34,17 @@ public function injectTokenTracker(TokenTracker $tracker)
$this->tokenTracker = $tracker;
}

/**
* Push a line or finale exception to the exception tracker.
*
* @param mixed $lineNumberOrFalse False for final tempalte exceptions.
* @param class $class Full qualified or defined alias.
*/
protected function pushException($lineNumberOrFalse, $class)
{
$exception = new $class($lineNumber);
$this->exceptionTracker->push($exception);
}

}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace ElmarHinz\TypoScriptParser;
namespace ElmarHinz\TypoScriptParser\Parsers;

class TypoScriptConditionsProcessor extends AbstractTypoScriptParser
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace ElmarHinz\TypoScriptParser;
namespace ElmarHinz\TypoScriptParser\Parsers;

use ElmarHinz\TypoScriptParser\Parsers\AbstractTypoScriptParser;

class TypoScriptProductionParser extends AbstractTypoScriptParser
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace ElmarHinz\TypoScriptParser;
namespace ElmarHinz\TypoScriptParser\Parsers;

use ElmarHinz\TypoScriptParser\Exceptions\TypoScriptBraceInExcessException as BraceInExcessException;
use ElmarHinz\TypoScriptParser\Exceptions\TypoScriptKeysException as KeysException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php

namespace ElmarHinz\TypoScriptParser;
namespace ElmarHinz\TypoScriptParser\Trackers;

use \ElmarHinz\TypoScriptParser\Exceptions\TypoScriptParsetimeException;
use \ElmarHinz\TypoScriptParser\Interfaces
\TypoScriptParsetimeExceptionTrackerPushInterface;
use \ElmarHinz\TypoScriptParser\Interfaces
\TypoScriptParsetimeExceptionTrackerPullInterface;

class TypoScriptParsetimeExceptionTracker
implements TypoScriptParsetimeExceptionTrackerPushInterface,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php

namespace ElmarHinz\TypoScriptParser;
namespace ElmarHinz\TypoScriptParser\Trackers;

use \ElmarHinz\TypoScriptParser\Tokens\AbstractTypoScriptToken;
use \ElmarHinz\TypoScriptParser\Interfaces
\TypoScriptTokenTrackerPushInterface;
use \ElmarHinz\TypoScriptParser\Interfaces
\TypoScriptTokenTrackerPullInterface;

/**
* Tracker of the tokens while parsing a TypoScript Template.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace ElmarHinz\TypoScriptParser\Tests\Unit;
namespace ElmarHinz\TypoScriptParser\Tests\Unit\Formatters;

use \ElmarHinz\TypoScriptParser\TypoScriptFormatter as Formatter;
use \ElmarHinz\TypoScriptParser\AbstractTypoScriptParser as AP;
use ElmarHinz\TypoScriptParser\Formatters\TypoScriptFormatter as Formatter;
use ElmarHinz\TypoScriptParser\Parsers\AbstractTypoScriptParser as AP;

class TypoScriptFormatterTest extends \PHPUnit_Framework_TestCase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
<?php

namespace ElmarHinz\TypoScriptParser\Tests\Unit;
namespace ElmarHinz\TypoScriptParser\Tests\Unit\Main;

use \ElmarHinz\TypoScriptParser\Tests\Unit\Fixtures\TypoScriptExamples as Examples;
use \ElmarHinz\TypoScriptParser\CoreTypoScriptParserAdapter as Adapter;
use ElmarHinz\TypoScriptParser\Main\CoreTypoScriptParserAdapter
as Adapter;
use TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching
\ConditionMatcher as Matcher;
use ElmarHinz\TypoScriptParser\Tests\Unit\Fixtures\TypoScriptExamples
as Examples;

if(!defined("LF")) define("LF", "\n");
if(!defined("TAB")) define("TAB", "\t");
if (!defined("LF")) define("LF", "\n");
if (!defined("TAB")) define("TAB", "\t");

class CoreTypoScriptParserAdapterTest extends \PHPUnit_Framework_TestCase
{

public function setup()
{
$matchClass = '\\TYPO3\\CMS\\Backend\\Configuration\\TypoScript\\ConditionMatching\\ConditionMatcher';
$matcher = $this->getMockBuilder($matchClass)->getMock();
$matcher = $this->getMockBuilder(Matcher::class)->getMock();
$matcher->method('match')->will($this->returnCallback(
function($condition) { return $condition == '[TRUE]'; }));
$this->matcher = $matcher;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

namespace ElmarHinz\TypoScriptParser\Tests\Unit;
namespace ElmarHinz\TypoScriptParser\Tests\Unit\Parsers;

use ElmarHinz\TypoScriptParser\AbstractTypoScriptSyntaxParser
use ElmarHinz\TypoScriptParser\Parsers\AbstractTypoScriptSyntaxParser
as Parser;
use ElmarHinz\TypoScriptParser\TypoScriptTokenTrackerPushInterface
as TokenTracker;
use ElmarHinz\TypoScriptParser\TypoScriptPasetimeExceptionTrackerPushInterface
as ExceptionTracker;
use ElmarHinz\TypoScriptParser\Interfaces
\TypoScriptTokenTrackerPushInterface as TokenTracker;
use ElmarHinz\TypoScriptParser\Interfaces
\TypoScriptPasetimeExceptionTrackerPushInterface as ExceptionTracker;

class AbstractTypoScriptSyntaxParserTest extends \PHPUnit_Framework_TestCase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

namespace ElmarHinz\TypoScriptParser\Tests\Unit;
namespace ElmarHinz\TypoScriptParser\Tests\Unit\Parsers;

use \ElmarHinz\TypoScriptParser\Tests\Unit\Fixtures\TypoScriptExamples as Examples;
use ElmarHinz\TypoScriptParser\Tests\Unit\Fixtures\TypoScriptExamples
as Examples;
use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser as CoreParser;

if(!defined("LF")) define("LF", "\n");
if(!defined("TAB")) define("TAB", "\t");
Expand All @@ -11,7 +13,7 @@ class CoreTypoScriptParserTest extends \PHPUnit_Framework_TestCase
{
public function setup()
{
$this->parser = new \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
$this->parser = new CoreParser();
}

public function tsProvider()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace ElmarHinz\TypoScriptParser\Tests\Unit;
namespace ElmarHinz\TypoScriptParser\Tests\Unit\Parsers;

use \ElmarHinz\TypoScriptParser\TypoScriptConditionsProcessor;
use ElmarHinz\TypoScriptParser\Parsers\TypoScriptConditionsProcessor;

class TypoScriptConditionsProcessorTest extends \PHPUnit_Framework_TestCase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?php

namespace ElmarHinz\TypoScriptParser\Tests\Unit;
namespace ElmarHinz\TypoScriptParser\Tests\Unit\Parsers;

use ElmarHinz\TypoScriptParser\Parsers\TypoScriptProductionParser
as Parser;
use ElmarHinz\TypoScriptParser\Interfaces\TypoScriptValueModifierInterface
as ValueModifier;
use ElmarHinz\TypoScriptParser\Tests\Unit\Fixtures\TypoScriptExamples
as Examples;

use \ElmarHinz\TypoScriptParser\Tests\Unit\Fixtures\TypoScriptExamples as Examples;
use \ElmarHinz\TypoScriptParser\TypoScriptProductionParser as Parser;
use \ElmarHinz\TypoScriptParser\ValueModifierInterface as ValueModifier;
class TypoScriptProductionParserTest extends \PHPUnit_Framework_TestCase
{

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<?php

namespace ElmarHinz\TypoScriptParser\Tests\Unit;
namespace ElmarHinz\TypoScriptParser\Tests\Unit\Parsers;

use \ElmarHinz\TypoScriptParser\Tests\Unit\Fixtures\TypoScriptExamples as Examples;
use \ElmarHinz\TypoScriptParser\TypoScriptSyntaxParser as Parser;
use \ElmarHinz\TypoScriptParser\AbstractTypoScriptParser as AP;
use \ElmarHinz\TypoScriptParser\TypoScriptFormatterInterface as Formatter;
use ElmarHinz\TypoScriptParser\Tests\Unit\Fixtures\TypoScriptExamples
as Examples;
use ElmarHinz\TypoScriptParser\Parsers\TypoScriptSyntaxParser
as Parser;
use ElmarHinz\TypoScriptParser\Parsers\AbstractTypoScriptParser
as AP;
use ElmarHinz\TypoScriptParser\Interfaces\TypoScriptFormatterInterface
as Formatter;

class TypoScriptSyntaxParserTest extends \PHPUnit_Framework_TestCase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace ElmarHinz\TypoScriptParser\Tests\Unit;
namespace ElmarHinz\TypoScriptParser\Tests\Unit\Trackers;

use ElmarHinz\TypoScriptParser\TypoScriptParsetimeExceptionTracker as ExceptionTracker;
use ElmarHinz\TypoScriptParser\Trackers\TypoScriptParsetimeExceptionTracker
as ExceptionTracker;
use ElmarHinz\TypoScriptParser\Exceptions\TypoScriptParsetimeException;

class TypoScriptParsetimeExceptionTrackerTest extends \PHPUnit_Framework_TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace ElmarHinz\TypoScriptParser\Tests\Unit;
namespace ElmarHinz\TypoScriptParser\Tests\Unit\Trackers;

use \ElmarHinz\TypoScriptParser\TypoScriptTokenTracker as Tracker;
use \ElmarHinz\TypoScriptParser\Tokens\AbstractTypoScriptToken as Token;
use ElmarHinz\TypoScriptParser\Trackers\TypoScriptTokenTracker as Tracker;
use ElmarHinz\TypoScriptParser\Tokens\AbstractTypoScriptToken as Token;

class TypoScriptTokenTrackerTest extends \PHPUnit_Framework_TestCase
{
Expand Down

0 comments on commit acafd93

Please sign in to comment.