Skip to content

Commit

Permalink
Support PHP 7 by renaming the string class
Browse files Browse the repository at this point in the history
  • Loading branch information
sabberworm committed Aug 24, 2015
1 parent c82be3f commit 647f53d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ php:
- "5.3"
- "5.5"
- "5.6"
- "7.0"
- "nightly"
- hhvm
script: phpunit .

18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ If you want to manipulate a `RuleSet`, use the methods `addRule(Rule $oRule)`, `

* `Size` – consists of a numeric `size` value and a unit.
* `Color` – colors can be input in the form #rrggbb, #rgb or schema(val1, val2, …) but are always stored as an array of ('s' => val1, 'c' => val2, 'h' => val3, …) and output in the second form.
* `String` – this is just a wrapper for quoted strings to distinguish them from keywords; always output with double quotes.
* `CSSString` – this is just a wrapper for quoted strings to distinguish them from keywords; always output with double quotes.
* `URL` – URLs in CSS; always output in URL("") notation.

There is another abstract subclass of `Value`, `ValueList`. A `ValueList` represents a lists of `Value`s, separated by some separation character (mostly `,`, whitespace, or `/`). There are two types of `ValueList`s:
Expand Down Expand Up @@ -193,8 +193,8 @@ To see what you can do with output formatting, look at the tests in `tests/Sabbe
[0]=>
object(Sabberworm\CSS\Property\Charset)#6 (1) {
["sCharset":"Sabberworm\CSS\Property\Charset":private]=>
object(Sabberworm\CSS\Value\String)#5 (1) {
["sString":"Sabberworm\CSS\Value\String":private]=>
object(Sabberworm\CSS\Value\CSSString)#5 (1) {
["sString":"Sabberworm\CSS\Value\CSSString":private]=>
string(5) "utf-8"
}
}
Expand All @@ -211,8 +211,8 @@ To see what you can do with output formatting, look at the tests in `tests/Sabbe
["sRule":"Sabberworm\CSS\Rule\Rule":private]=>
string(11) "font-family"
["mValue":"Sabberworm\CSS\Rule\Rule":private]=>
object(Sabberworm\CSS\Value\String)#9 (1) {
["sString":"Sabberworm\CSS\Value\String":private]=>
object(Sabberworm\CSS\Value\CSSString)#9 (1) {
["sString":"Sabberworm\CSS\Value\CSSString":private]=>
string(10) "CrassRoots"
}
["bIsImportant":"Sabberworm\CSS\Rule\Rule":private]=>
Expand All @@ -228,8 +228,8 @@ To see what you can do with output formatting, look at the tests in `tests/Sabbe
["mValue":"Sabberworm\CSS\Rule\Rule":private]=>
object(Sabberworm\CSS\Value\URL)#11 (1) {
["oURL":"Sabberworm\CSS\Value\URL":private]=>
object(Sabberworm\CSS\Value\String)#12 (1) {
["sString":"Sabberworm\CSS\Value\String":private]=>
object(Sabberworm\CSS\Value\CSSString)#12 (1) {
["sString":"Sabberworm\CSS\Value\CSSString":private]=>
string(15) "../media/cr.ttf"
}
}
Expand Down Expand Up @@ -469,8 +469,8 @@ To see what you can do with output formatting, look at the tests in `tests/Sabbe
[1]=>
string(9) "Helvetica"
[2]=>
object(Sabberworm\CSS\Value\String)#14 (1) {
["sString":"Sabberworm\CSS\Value\String":private]=>
object(Sabberworm\CSS\Value\CSSString)#14 (1) {
["sString":"Sabberworm\CSS\Value\CSSString":private]=>
string(9) "Gill Sans"
}
[3]=>
Expand Down
2 changes: 1 addition & 1 deletion lib/Sabberworm/CSS/CSSList/CSSBlockList.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function allValues($oElement, &$aResult, $sSearchString = null, $bSear
}
}
} else {
//Non-List Value or String (CSS identifier)
//Non-List Value or CSSString (CSS identifier)
$aResult[] = $oElement;
}
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Sabberworm/CSS/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Sabberworm\CSS\Value\Size;
use Sabberworm\CSS\Value\Color;
use Sabberworm\CSS\Value\URL;
use Sabberworm\CSS\Value\String;
use Sabberworm\CSS\Value\CSSString;
use Sabberworm\CSS\Rule\Rule;
use Sabberworm\CSS\Parsing\UnexpectedTokenException;

Expand Down Expand Up @@ -139,7 +139,7 @@ private function parseAtRule() {
if ($sPrefix !== null && !is_string($sPrefix)) {
throw new \Exception('Wrong namespace prefix '.$sPrefix);
}
if (!($mUrl instanceof String || $mUrl instanceof URL)) {
if (!($mUrl instanceof CSSString || $mUrl instanceof URL)) {
throw new \Exception('Wrong namespace url of invalid type '.$mUrl);
}
return new CSSNamespace($mUrl, $sPrefix);
Expand Down Expand Up @@ -214,7 +214,7 @@ private function parseStringValue() {
}
$this->consume($sQuote);
}
return new String($sResult);
return new CSSString($sResult);
}

private function parseCharacter($bIsForIdentifier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Sabberworm\CSS\Value;

class String extends PrimitiveValue {
class CSSString extends PrimitiveValue {

private $sString;

Expand Down
4 changes: 2 additions & 2 deletions lib/Sabberworm/CSS/Value/URL.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ class URL extends PrimitiveValue {

private $oURL;

public function __construct(String $oURL) {
public function __construct(CSSString $oURL) {
$this->oURL = $oURL;
}

public function setURL(String $oURL) {
public function setURL(CSSString $oURL) {
$this->oURL = $oURL;
}

Expand Down

0 comments on commit 647f53d

Please sign in to comment.