Skip to content

Commit 5af6fea

Browse files
committed
removed traits
1 parent 039df38 commit 5af6fea

File tree

13 files changed

+57
-248
lines changed

13 files changed

+57
-248
lines changed

src/Language/LanguageAbstract.php

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,27 @@
1212

1313
namespace chillerlan\bbcode\Language;
1414

15-
use chillerlan\bbcode\Traits\ClassLoaderTrait;
16-
1715
/**
18-
* @method string parserExceptionCallback($override_language = null)
19-
* @method string parserExceptionMatchall($override_language = null)
16+
* @method string parserExceptionCallback(string $LanguageInterface = null)
17+
* @method string parserExceptionMatchall(string $LanguageInterface = null)
2018
*
21-
* @method string codeDisplayCSS($override_language = null)
22-
* @method string codeDisplayPHP($override_language = null)
23-
* @method string codeDisplaySQL($override_language = null)
24-
* @method string codeDisplayXML($override_language = null)
25-
* @method string codeDisplayHTML($override_language = null)
26-
* @method string codeDisplayJS($override_language = null)
27-
* @method string codeDisplayJSON($override_language = null)
28-
* @method string codeDisplayPRE($override_language = null)
29-
* @method string codeDisplayCODE($override_language = null)
30-
* @method string codeDisplayNSIS($override_language = null)
19+
* @method string codeDisplayCSS(string $LanguageInterface = null)
20+
* @method string codeDisplayPHP(string $LanguageInterface = null)
21+
* @method string codeDisplaySQL(string $LanguageInterface = null)
22+
* @method string codeDisplayXML(string $LanguageInterface = null)
23+
* @method string codeDisplayHTML(string $LanguageInterface = null)
24+
* @method string codeDisplayJS(string $LanguageInterface = null)
25+
* @method string codeDisplayJSON(string $LanguageInterface = null)
26+
* @method string codeDisplayPRE(string $LanguageInterface = null)
27+
* @method string codeDisplayCODE(string $LanguageInterface = null)
28+
* @method string codeDisplayNSIS(string $LanguageInterface = null)
3129
*
32-
* @method string expanderDisplayExpander($override_language = null)
33-
* @method string expanderDisplayQuote($override_language = null)
34-
* @method string expanderDisplaySpoiler($override_language = null)
35-
* @method string expanderDisplayTrigger($override_language = null)
30+
* @method string expanderDisplayExpander(string $LanguageInterface = null)
31+
* @method string expanderDisplayQuote(string $LanguageInterface = null)
32+
* @method string expanderDisplaySpoiler(string $LanguageInterface = null)
33+
* @method string expanderDisplayTrigger(string $LanguageInterface = null)
3634
*/
3735
abstract class LanguageAbstract implements LanguageInterface{
38-
use ClassLoaderTrait;
3936

4037
/**
4138
* It's magic.
@@ -53,15 +50,15 @@ public function __call(string $name, array $arguments){
5350
* Returns a language string for a given key and overrides the current language if desired.
5451
*
5552
* @param string $key
56-
* @param string $override_language (a LanguageInterface FQCN)
53+
* @param string $LanguageInterface (a LanguageInterface FQCN)
5754
*
58-
* @return mixed
55+
* @return string
5956
* @throws \chillerlan\bbcode\BBCodeException
6057
*/
61-
public function string(string $key, string $override_language = null){
58+
public function string(string $key, string $LanguageInterface = null):string{
6259

63-
if($override_language){
64-
return $this->__loadClass($override_language, LanguageInterface::class)->{$key}();
60+
if($LanguageInterface){
61+
return (new $LanguageInterface)->{$key}();
6562
}
6663

6764
return $this->{$key};

src/Language/LanguageInterface.php

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,24 @@
1313
namespace chillerlan\bbcode\Language;
1414

1515
/**
16-
* @method string parserExceptionCallback($override_language = null)
17-
* @method string parserExceptionMatchall($override_language = null)
16+
* @method string parserExceptionCallback(string $LanguageInterface = null)
17+
* @method string parserExceptionMatchall(string $LanguageInterface = null)
1818
*
19-
* @method string codeDisplayCSS($override_language = null)
20-
* @method string codeDisplayPHP($override_language = null)
21-
* @method string codeDisplaySQL($override_language = null)
22-
* @method string codeDisplayXML($override_language = null)
23-
* @method string codeDisplayHTML($override_language = null)
24-
* @method string codeDisplayJS($override_language = null)
25-
* @method string codeDisplayJSON($override_language = null)
26-
* @method string codeDisplayPRE($override_language = null)
27-
* @method string codeDisplayCODE($override_language = null)
28-
* @method string codeDisplayNSIS($override_language = null)
29-
*
30-
* @method string expanderDisplayExpander($override_language = null)
31-
* @method string expanderDisplayQuote($override_language = null)
32-
* @method string expanderDisplaySpoiler($override_language = null)
33-
* @method string expanderDisplayTrigger($override_language = null)
19+
* @method string codeDisplayCSS(string $LanguageInterface = null)
20+
* @method string codeDisplayPHP(string $LanguageInterface = null)
21+
* @method string codeDisplaySQL(string $LanguageInterface = null)
22+
* @method string codeDisplayXML(string $LanguageInterface = null)
23+
* @method string codeDisplayHTML(string $LanguageInterface = null)
24+
* @method string codeDisplayJS(string $LanguageInterface = null)
25+
* @method string codeDisplayJSON(string $LanguageInterface = null)
26+
* @method string codeDisplayPRE(string $LanguageInterface = null)
27+
* @method string codeDisplayCODE(string $LanguageInterface = null)
28+
* @method string codeDisplayNSIS(string $LanguageInterface = null)
3429
*
30+
* @method string expanderDisplayExpander(string $LanguageInterface = null)
31+
* @method string expanderDisplayQuote(string $LanguageInterface = null)
32+
* @method string expanderDisplaySpoiler(string $LanguageInterface = null)
33+
* @method string expanderDisplayTrigger(string $LanguageInterface = null)
3534
*/
3635
interface LanguageInterface{
3736

@@ -49,11 +48,11 @@ public function __call(string $name, array $arguments);
4948
* Returns a language string for a given key and overrides the current language if desired.
5049
*
5150
* @param string $key
52-
* @param string $override_language (a LanguageInterface FQCN)
51+
* @param string $LanguageInterface (a LanguageInterface FQCN)
5352
*
5453
* @return mixed
5554
* @throws \chillerlan\bbcode\BBCodeException
5655
*/
57-
public function string(string $key, string $override_language = null);
56+
public function string(string $key, string $LanguageInterface = null);
5857

5958
}

src/Modules/BaseModuleAbstract.php

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,6 @@ abstract class BaseModuleAbstract implements BaseModuleInterface{
106106
*/
107107
protected $languageInterface;
108108

109-
/**
110-
* Constructor
111-
*
112-
* calls self::setBBTemp() in case $bbtemp is set
113-
*
114-
* @param \chillerlan\bbcode\BBTemp $bbtemp
115-
*/
116-
public function __construct(BBTemp $bbtemp = null){
117-
if($bbtemp instanceof BBTemp){
118-
$this->setBBTemp($bbtemp);
119-
}
120-
}
121-
122109
/**
123110
* Sets self::$tag, self::$attributes, self::$content and self::$options
124111
*
@@ -268,8 +255,8 @@ public function attributeKeyIn(string $name, array $whitelist, $default = false)
268255
*/
269256
public function tagIn(array $whitelist, $default = false){
270257
return in_array($this->tag, $whitelist)
271-
? $default !== false ? $this->tag : true
272-
: $default;
258+
? $default !== false ? $this->tag : true
259+
: $default;
273260
}
274261

275262
/**
@@ -280,9 +267,6 @@ public function tagIn(array $whitelist, $default = false){
280267
* @return string
281268
* @codeCoverageIgnore
282269
*/
283-
public function sanitize(string $content):string{
284-
return 'Implement sanitize() method!';
285-
}
286270

287271
/**
288272
* Checks the tag and returns the processed bbcode, called from the parser within a module
@@ -322,6 +306,8 @@ protected function bbtagIn(array $array, $default = false){
322306
/**
323307
* Checks if an URL is valid using filter_var()
324308
*
309+
* @todo check against whitelist?
310+
*
325311
* @param string $url the URL to check
326312
*
327313
* @return bool|string the url if valid, otherwise false
@@ -330,7 +316,6 @@ public function checkUrl(string $url){
330316
if(filter_var($url, FILTER_VALIDATE_URL) === false){
331317
return false;
332318
}
333-
// todo: check against whitelist?
334319

335320
return $url;
336321
}

src/Modules/DB/DBBaseModule.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
namespace chillerlan\bbcode\Modules\DB;
1414

15-
use chillerlan\bbcode\BBTemp;
1615
use chillerlan\bbcode\Modules\Markup\MarkupBaseModule;
1716
use chillerlan\Database\Traits\DatabaseTrait;
1817

@@ -63,12 +62,8 @@ class DBBaseModule extends MarkupBaseModule{
6362

6463
/**
6564
* DBBaseModule constructor.
66-
*
67-
* @param \chillerlan\bbcode\BBTemp|null $bbtemp
6865
*/
69-
public function __construct(BBTemp $bbtemp = null){
70-
parent::__construct($bbtemp);
71-
66+
public function __construct(){
7267
$this->tags = [];
7368
$this->noparse_tags = [];
7469
$this->singletags = [];

src/Modules/DB/DBTags.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace chillerlan\bbcode\Modules\DB;
1313

14-
use chillerlan\bbcode\BBTemp;
1514
use chillerlan\bbcode\Modules\ModuleInterface;
1615

1716
/**

src/Modules/Html5/Code.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
namespace chillerlan\bbcode\Modules\Html5;
1414

15-
use chillerlan\bbcode\BBTemp;
1615
use chillerlan\bbcode\Modules\ModuleInterface;
1716

1817
/**
@@ -30,14 +29,8 @@ class Code extends Html5BaseModule implements ModuleInterface{
3029

3130
/**
3231
* Constructor
33-
*
34-
* calls self::setBBTemp() in case $bbtemp is set
35-
*
36-
* @param \chillerlan\bbcode\BBTemp $bbtemp
3732
*/
38-
public function __construct(BBTemp $bbtemp = null){
39-
parent::__construct($bbtemp);
40-
33+
public function __construct(){
4134
// set self::$noparse_tags to self::$tags because none of these should be parsed
4235
$this->noparse_tags = $this->tags;
4336
}

src/Modules/Html5/Noparse.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
namespace chillerlan\bbcode\Modules\Html5;
1414

15-
use chillerlan\bbcode\BBTemp;
1615
use chillerlan\bbcode\Modules\ModuleInterface;
1716

1817
/**
@@ -30,14 +29,8 @@ class Noparse extends Html5BaseModule implements ModuleInterface{
3029

3130
/**
3231
* Constructor
33-
*
34-
* calls self::setBBTemp() in case $bbtemp is set
35-
*
36-
* @param \chillerlan\bbcode\BBTemp $bbtemp
3732
*/
38-
public function __construct(BBTemp $bbtemp = null){
39-
parent::__construct($bbtemp);
40-
33+
public function __construct(){
4134
// set self::$noparse_tags to self::$tags because none of these should be parsed
4235
$this->noparse_tags = $this->tags;
4336
}

src/Modules/Markdown/Code.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
namespace chillerlan\bbcode\Modules\Markdown;
1414

15-
use chillerlan\bbcode\BBTemp;
1615
use chillerlan\bbcode\Modules\ModuleInterface;
1716

1817
/**
@@ -30,14 +29,8 @@ class Code extends MarkdownBaseModule implements ModuleInterface{
3029

3130
/**
3231
* Constructor
33-
*
34-
* calls self::setBBTemp() in case $bbtemp is set
35-
*
36-
* @param \chillerlan\bbcode\BBTemp $bbtemp
3732
*/
38-
public function __construct(BBTemp $bbtemp = null){
39-
parent::__construct($bbtemp);
40-
33+
public function __construct(){
4134
// set self::$noparse_tags to self::$tags because none of these should be parsed
4235
$this->noparse_tags = $this->tags;
4336
}

src/Modules/Markdown/Noparse.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
namespace chillerlan\bbcode\Modules\Markdown;
1414

15-
use chillerlan\bbcode\BBTemp;
1615
use chillerlan\bbcode\Modules\ModuleInterface;
1716

1817
/**
@@ -30,14 +29,8 @@ class Noparse extends MarkdownBaseModule implements ModuleInterface{
3029

3130
/**
3231
* Constructor
33-
*
34-
* calls self::setBBTemp() in case $bbtemp is set
35-
*
36-
* @param \chillerlan\bbcode\BBTemp $bbtemp
3732
*/
38-
public function __construct(BBTemp $bbtemp = null){
39-
parent::__construct($bbtemp);
40-
33+
public function __construct(){
4134
// set self::$noparse_tags to self::$tags because none of these should be parsed
4235
$this->noparse_tags = $this->tags;
4336
}

src/Modules/ModuleInterface.php

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
namespace chillerlan\bbcode\Modules;
1414

15-
use \chillerlan\bbcode\BBTemp;
16-
1715
/**
1816
* Implements the module specific functionality
1917
*/
@@ -27,32 +25,4 @@ interface ModuleInterface{
2725
*/
2826
public function __transform():string;
2927

30-
/**
31-
* Checks the tag and returns the processed bbcode, called from the parser
32-
*
33-
* This method is implemented in BaseModuleInterface, no need to overide it.
34-
* @see \chillerlan\bbcode\Modules\BaseModuleInterface::transform()
35-
*/
36-
public function transform():string;
37-
38-
/**
39-
* Sets self::$tag, self::$attributes, self::$content and self::$options
40-
*
41-
* This method is implemented in BaseModuleInterface, no need to overide it.
42-
* @see \chillerlan\bbcode\Modules\BaseModuleInterface::setBBTemp()
43-
*
44-
* @param \chillerlan\bbcode\BBTemp $bbtemp
45-
*
46-
* @return $this
47-
*/
48-
public function setBBTemp(BBTemp $bbtemp);
49-
50-
/**
51-
* Returns an array of tags which the module is able to process
52-
*
53-
* This method is implemented in BaseModuleInterface, no need to overide it.
54-
* @see \chillerlan\bbcode\Modules\BaseModuleInterface::getTags()
55-
*/
56-
public function getTags():Tagmap;
57-
5828
}

0 commit comments

Comments
 (0)