Skip to content

Commit

Permalink
add cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
Gemorroj committed Jun 9, 2019
1 parent c8e64cd commit 919746b
Show file tree
Hide file tree
Showing 38 changed files with 521 additions and 523 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ composer.phar
composer.lock
vendor/
phpunit.xml

.php_cs
.php_cs.cache
26 changes: 26 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(['src', 'tests']);

return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
// 'compact_nullable_typehint' => true,
'linebreak_after_opening_tag' => true,
// 'list_syntax' => ['syntax' => 'short'],
// 'mb_str_functions' => true,
'native_function_invocation' => true,
'no_null_property_initialization' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
'phpdoc_order' => true,
'strict_comparison' => true,
])
->setRiskyAllowed(true)
->setFinder($finder)
;
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"geshi/geshi": "^1.0.9"
},
"require-dev": {
"phpunit/phpunit": "^5.7"
"phpunit/phpunit": "^5.7",
"friendsofphp/php-cs-fixer": "^2.15"
},
"homepage": "http://xbb.uz",
"support": {
Expand Down
6 changes: 3 additions & 3 deletions src/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Attributes extends \ArrayObject
/**
* @var array
*/
protected $attributes = array('class' => 'bb');
protected $attributes = ['class' => 'bb'];

/**
* @param string $name
Expand Down Expand Up @@ -95,9 +95,9 @@ public function __toString()
{
$str = '';
foreach ($this->getIterator() as $name => $value) {
$str .= htmlspecialchars($name, ENT_NOQUOTES) . '="' . htmlspecialchars($value) . '" ';
$str .= \htmlspecialchars($name, ENT_NOQUOTES) . '="' . \htmlspecialchars($value) . '" ';
}

return rtrim($str);
return \rtrim($str);
}
}
1 change: 0 additions & 1 deletion src/Tag/A.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

use Xbbcode\Attributes;


/**
* Class A
* Класс для тегов [a], [anchor] и [url]
Expand Down
1 change: 0 additions & 1 deletion src/Tag/Abbr.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

use Xbbcode\Attributes;


/**
* Class Abbr
* Класс для тега [abbr]
Expand Down
1 change: 0 additions & 1 deletion src/Tag/Acronym.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

use Xbbcode\Attributes;


/**
* Class Acronym
* Класс для тега [acronym]
Expand Down
1 change: 0 additions & 1 deletion src/Tag/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

namespace Xbbcode\Tag;


/**
* Class Address
* Класс для тега [address]
Expand Down
1 change: 0 additions & 1 deletion src/Tag/Align.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

use Xbbcode\Attributes;


/**
* Class Align
* Класс для тегов [align], [center], [justify], [left] и [right]
Expand Down
1 change: 0 additions & 1 deletion src/Tag/Altfont.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

use Xbbcode\Attributes;


/**
* Class Altfont
* Класс для тега [altfont]
Expand Down
1 change: 0 additions & 1 deletion src/Tag/Bbcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

use Xbbcode\Attributes;


/**
* Class Bbcode
* Класс для тега [bbcode]
Expand Down
3 changes: 1 addition & 2 deletions src/Tag/Bdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

use Xbbcode\Attributes;


/**
* Class Bdo
* Класс для тега [bdo]
Expand All @@ -41,7 +40,7 @@ protected function getAttributes()
$attr = parent::getAttributes();

$dir = '';
switch (strtolower($this->attributes['bdo'])) {
switch (\strtolower($this->attributes['bdo'])) {
case 'ltr':
$dir = 'ltr';
break;
Expand Down
1 change: 0 additions & 1 deletion src/Tag/Br.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

namespace Xbbcode\Tag;


/**
* Class Br
* Класс для тега [br]
Expand Down
1 change: 0 additions & 1 deletion src/Tag/Caption.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

namespace Xbbcode\Tag;


/**
* Class Caption
* Класс для тега [caption]
Expand Down
12 changes: 5 additions & 7 deletions src/Tag/Code.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

namespace Xbbcode\Tag;


/**
* Class Code
* Класс для тегов подсветки синтаксиса и для тегов [code] и [pre]
Expand All @@ -33,7 +32,7 @@ class Code extends Tag
const BEHAVIOUR = 'pre';

/* Альтернативные названия языков и их трансляция в обозначения GeSHi */
public $langSynonym = array(
public $langSynonym = [
'algol' => 'algol86',
'c++' => 'cpp',
'c#' => 'csharp',
Expand All @@ -45,7 +44,7 @@ class Code extends Tag
'oracle' => 'oracle8',
't-sql' => 'tsql',
'vb.net' => 'vbnet',
);
];
/**
* @var \GeSHi
*/
Expand Down Expand Up @@ -167,7 +166,7 @@ protected function setTab()
protected function setExtra()
{
if (isset($this->attributes['extra'])) {
$extra = explode(',', $this->attributes['extra']);
$extra = \explode(',', $this->attributes['extra']);
$this->geshi->highlight_lines_extra($extra);
}

Expand All @@ -187,8 +186,7 @@ protected function getHeader()
$title = $this->geshi->get_language_name();
}

return '<div class="bb_code_header"><span class="bb_code_lang">' . htmlspecialchars($title, ENT_NOQUOTES) . '</span></div>';

return '<div class="bb_code_header"><span class="bb_code_lang">' . \htmlspecialchars($title, ENT_NOQUOTES) . '</span></div>';
}


Expand All @@ -200,7 +198,7 @@ protected function getHeader()
protected function getFooter()
{
if (isset($this->attributes['footer'])) {
return '<div class="bb_code_footer">' . htmlspecialchars($this->attributes['footer'], ENT_NOQUOTES) . '</div>';
return '<div class="bb_code_footer">' . \htmlspecialchars($this->attributes['footer'], ENT_NOQUOTES) . '</div>';
}

return '';
Expand Down
1 change: 0 additions & 1 deletion src/Tag/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

use Xbbcode\Attributes;


/**
* Class Color
* Класс для тега [color]
Expand Down
1 change: 0 additions & 1 deletion src/Tag/Font.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

use Xbbcode\Attributes;


/**
* Class Font
* Класс для тега [font]
Expand Down
3 changes: 1 addition & 2 deletions src/Tag/Google.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

namespace Xbbcode\Tag;


/**
* Class Google
* Класс для тега [google]
Expand All @@ -45,6 +44,6 @@ protected function getHref()
$href = $this->getTreeText();
}

return '//www.google.com/search?q=' . rawurlencode($href);
return '//www.google.com/search?q=' . \rawurlencode($href);
}
}
1 change: 0 additions & 1 deletion src/Tag/Hr.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

namespace Xbbcode\Tag;


/**
* Class Hr
* Класс для тега [hr]
Expand Down
1 change: 0 additions & 1 deletion src/Tag/Img.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

use Xbbcode\Attributes;


/**
* Class Img
* Класс для тега [img]
Expand Down
1 change: 0 additions & 1 deletion src/Tag/Li.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

use Xbbcode\Attributes;


/**
* Class Li
* Класс для тега [*]
Expand Down
3 changes: 1 addition & 2 deletions src/Tag/Nobb.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

namespace Xbbcode\Tag;


/**
* Class Nobb
* Класс для тега [nobb]
Expand All @@ -38,6 +37,6 @@ class Nobb extends Tag
*/
public function __toString()
{
return htmlspecialchars($this->getTreeText(), ENT_NOQUOTES);
return \htmlspecialchars($this->getTreeText(), ENT_NOQUOTES);
}
}
1 change: 0 additions & 1 deletion src/Tag/Ol.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

use Xbbcode\Attributes;


/**
* Class Ol
* Класс для тегов [ol]
Expand Down
1 change: 0 additions & 1 deletion src/Tag/P.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

namespace Xbbcode\Tag;


/**
* Class P
* Класс для тега [p] и тегов [h1], [h2], [h3], [h4], [h5], [h6]
Expand Down
3 changes: 1 addition & 2 deletions src/Tag/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

use Xbbcode\Attributes;


/**
* Class Quote
* Класс для тегов [quote] и [blockquote]
Expand All @@ -51,7 +50,7 @@ protected function getAuthor()
}

if ($author) {
return '<div class="bb_quote_author">' . htmlspecialchars($author, ENT_NOQUOTES) . ':</div>';
return '<div class="bb_quote_author">' . \htmlspecialchars($author, ENT_NOQUOTES) . ':</div>';
}

return '';
Expand Down
1 change: 0 additions & 1 deletion src/Tag/Simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

namespace Xbbcode\Tag;


/**
* Class Simple
* Класс для простейших тегов, например, [b]
Expand Down
1 change: 0 additions & 1 deletion src/Tag/Size.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

use Xbbcode\Attributes;


/**
* Class Size
* Класс для тега [size]
Expand Down
9 changes: 4 additions & 5 deletions src/Tag/Spoiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

use Xbbcode\Attributes;


/**
* Class Spoiler
* Класс для тегов [spoiler] и [hide]
Expand All @@ -40,12 +39,12 @@ class Spoiler extends Tag
*/
protected function getSpoiler($id)
{
return '<input class="bb_spoiler" type="button" value="' . htmlspecialchars(
return '<input class="bb_spoiler" type="button" value="' . \htmlspecialchars(
$this->showButton
) . '" onclick="var node = document.getElementById(\'' . $id . '\'); (node.style.display == \'none\' ? (node.style.display = \'block\', this.value = \'' . htmlspecialchars(
) . '" onclick="var node = document.getElementById(\'' . $id . '\'); (node.style.display == \'none\' ? (node.style.display = \'block\', this.value = \'' . \htmlspecialchars(
$this->hideButton,
ENT_QUOTES
) . '\') : (node.style.display = \'none\', this.value = \'' . htmlspecialchars(
) . '\') : (node.style.display = \'none\', this.value = \'' . \htmlspecialchars(
$this->showButton,
ENT_QUOTES
) . '\'));" />';
Expand All @@ -61,7 +60,7 @@ protected function getAttributes()
$attr->add('class', 'bb_spoiler');
$attr->set('style', 'display: none');

$id = uniqid('xbbcode');
$id = \uniqid('xbbcode');
$attr->set('id', $id);

return $attr;
Expand Down
1 change: 0 additions & 1 deletion src/Tag/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

use Xbbcode\Attributes;


/**
* Class Table
* Класс для тега [table]
Expand Down
Loading

0 comments on commit 919746b

Please sign in to comment.