Skip to content

Commit

Permalink
PHP 7 compatiblity
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWeinert committed Aug 9, 2016
1 parent 2b01707 commit 1e04468
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 20 deletions.
2 changes: 2 additions & 0 deletions src/PhpCss/Ast/Visitor/Xpath.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,8 @@ public function visitSelectorSimplePseudoClassLanguage(
private function strtolower($string) {
if (is_callable('mb_strtolower')) {
return mb_strtolower($string, 'utf-8');
} elseif (class_exists('Transliterator', FALSE)) {
return \Transliterator::create('Any-Lower')->transliterate($string);
}
return strtolower($string);
}
Expand Down
2 changes: 1 addition & 1 deletion src/PhpCss/Parser/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function parse() {
break;
case Scanner\Token::SINGLEQUOTE_STRING_START :
case Scanner\Token::DOUBLEQUOTE_STRING_START :
$attribute->literal = $this->delegate(String::CLASS);
$attribute->literal = $this->delegate(Text::CLASS);
break;
}
$this->read(Scanner\Token::ATTRIBUTE_SELECTOR_END);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* The string parser collects all string character tokens until a string end token is found.
*/
class String extends PhpCss\Parser {
class Text extends PhpCss\Parser {

public function parse() {
$string = '';
Expand Down
4 changes: 2 additions & 2 deletions src/PhpCss/Scanner/Status/Selector.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ public function isEndToken(Scanner\Token $token) {
public function getNewStatus(Scanner\Token $token) {
switch ($token->type) {
case Scanner\Token::SINGLEQUOTE_STRING_START :
return new Scanner\Status\String\Single();
return new Scanner\Status\Text\Single();
case Scanner\Token::DOUBLEQUOTE_STRING_START :
return new Scanner\Status\String\Double();
return new Scanner\Status\Text\Double();
case Scanner\Token::ATTRIBUTE_SELECTOR_START :
return new Scanner\Status\Selector\Attribute();
}
Expand Down
4 changes: 2 additions & 2 deletions src/PhpCss/Scanner/Status/Selector/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ public function isEndToken(Scanner\Token $token) {
public function getNewStatus(Scanner\Token $token) {
switch ($token->type) {
case Scanner\Token::SINGLEQUOTE_STRING_START :
return new Scanner\Status\String\Single();
return new Scanner\Status\Text\Single();
case Scanner\Token::DOUBLEQUOTE_STRING_START :
return new Scanner\Status\String\Double();
return new Scanner\Status\Text\Double();
}
return NULL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright Copyright 2010-2014 PhpCss Team
*/

namespace PhpCss\Scanner\Status\String {
namespace PhpCss\Scanner\Status\Text {

use PhpCss\Scanner;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright Copyright 2010-2014 PhpCss Team
*/

namespace PhpCss\Scanner\Status\String {
namespace PhpCss\Scanner\Status\Text {

use PhpCss\Scanner;

Expand Down
4 changes: 2 additions & 2 deletions tests/PhpCss/Scanner/Status/Selector/AttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ public static function getNewStatusDataProvider() {
new Scanner\Token(
Scanner\Token::SINGLEQUOTE_STRING_START, "'", 0
),
new Scanner\Status\String\Single()
new Scanner\Status\Text\Single()
),
'double quote string start' => array(
new Scanner\Token(
Scanner\Token::DOUBLEQUOTE_STRING_START, "'", 0
),
new Scanner\Status\String\Double()
new Scanner\Status\Text\Double()
)
);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/PhpCss/Scanner/Status/SelectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ public static function getNewStatusDataProvider() {
),
'single quote string start' => array(
new Scanner\Token(Scanner\Token::SINGLEQUOTE_STRING_START, "'", 0),
new Scanner\Status\String\Single()
new Scanner\Status\Text\Single()
),
'double quote string start' => array(
new Scanner\Token(Scanner\Token::DOUBLEQUOTE_STRING_START, "'", 0),
new Scanner\Status\String\Double()
new Scanner\Status\Text\Double()
),
'attributes selector start' => array(
new Scanner\Token(Scanner\Token::ATTRIBUTE_SELECTOR_START, "[", 0),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace PhpCss\Scanner\Status\String {
namespace PhpCss\Scanner\Status\Text {

use PhpCss\Scanner;

Expand All @@ -8,7 +8,7 @@
class DoubleTest extends \PHPUnit_Framework_TestCase {

/**
* @covers PhpCss\Scanner\Status\String\Double::getToken
* @covers PhpCss\Scanner\Status\Text\Double::getToken
* @dataProvider getTokenDataProvider
*/
public function testGetToken($string, $expectedToken) {
Expand All @@ -20,7 +20,7 @@ public function testGetToken($string, $expectedToken) {
}

/**
* @covers PhpCss\Scanner\Status\String\Double::isEndToken
* @covers PhpCss\Scanner\Status\Text\Double::isEndToken
*/
public function testIsEndToken() {
$status = new Double();
Expand All @@ -33,7 +33,7 @@ public function testIsEndToken() {
);
}
/**
* @covers PhpCss\Scanner\Status\String\Double::getNewStatus
* @covers PhpCss\Scanner\Status\Text\Double::getNewStatus
*/
public function testGetNewStatus() {
$status = new Double();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace PhpCss\Scanner\Status\String {
namespace PhpCss\Scanner\Status\Text {

use PhpCss\Scanner;

Expand All @@ -8,7 +8,7 @@
class SingleTest extends \PHPUnit_Framework_TestCase {

/**
* @covers PhpCss\Scanner\Status\String\Single::getToken
* @covers PhpCss\Scanner\Status\Text\Single::getToken
* @dataProvider getTokenDataProvider
*/
public function testGetToken($string, $expectedToken) {
Expand All @@ -20,7 +20,7 @@ public function testGetToken($string, $expectedToken) {
}

/**
* @covers PhpCss\Scanner\Status\String\Single::isEndToken
* @covers PhpCss\Scanner\Status\Text\Single::isEndToken
*/
public function testIsEndToken() {
$status = new Single();
Expand All @@ -33,7 +33,7 @@ public function testIsEndToken() {
);
}
/**
* @covers PhpCss\Scanner\Status\String\Single::getNewStatus
* @covers PhpCss\Scanner\Status\Text\Single::getNewStatus
*/
public function testGetNewStatus() {
$status = new Single();
Expand Down
10 changes: 10 additions & 0 deletions tests/PhpCss/ScannerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,16 @@ public static function selectorsDataProvider() {
"TOKEN::SELECTOR_COMBINATOR @0 ' + '",
"TOKEN::IDENTIFIER @3 'p'"
)
),
array(
'p:not(:scope)',
array(
"TOKEN::IDENTIFIER @0 'p'",
"TOKEN::PSEUDOCLASS @1 ':not'",
"TOKEN::PARENTHESES_START @5 '('",
"TOKEN::PSEUDOCLASS @6 ':scope'",
"TOKEN::PARENTHESES_END @12 ')'"
)
)
);
}
Expand Down

0 comments on commit 1e04468

Please sign in to comment.