Skip to content

Commit 227eae2

Browse files
committed
Global namespace to PHP core Exception class
1 parent f5404c9 commit 227eae2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/php/Sabberworm/CSS/CSSParser.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private function parseList(CSSList $oList, $bIsRoot = false) {
4444
} else if($this->comes('}')) {
4545
$this->consume('}');
4646
if($bIsRoot) {
47-
throw new Exception("Unopened {");
47+
throw new \Exception("Unopened {");
4848
} else {
4949
return;
5050
}
@@ -54,7 +54,7 @@ private function parseList(CSSList $oList, $bIsRoot = false) {
5454
$this->consumeWhiteSpace();
5555
}
5656
if(!$bIsRoot) {
57-
throw new Exception("Unexpected end of document");
57+
throw new \Exception("Unexpected end of document");
5858
}
5959
}
6060

@@ -97,7 +97,7 @@ private function parseAtRule() {
9797
private function parseIdentifier($bAllowFunctions = true) {
9898
$sResult = $this->parseCharacter(true);
9999
if($sResult === null) {
100-
throw new Exception("Identifier expected, got {$this->peek(5)}");
100+
throw new \Exception("Identifier expected, got {$this->peek(5)}");
101101
}
102102
$sCharacter;
103103
while(($sCharacter = $this->parseCharacter(true)) !== null) {
@@ -133,7 +133,7 @@ private function parseStringValue() {
133133
while(!$this->comes($sQuote)) {
134134
$sContent = $this->parseCharacter(false);
135135
if($sContent === null) {
136-
throw new Exception("Non-well-formed quoted string {$this->peek(3)}");
136+
throw new \Exception("Non-well-formed quoted string {$this->peek(3)}");
137137
}
138138
$sResult .= $sContent;
139139
}
@@ -214,7 +214,7 @@ private function parseRule() {
214214
$this->consumeWhiteSpace();
215215
$sImportantMarker = $this->consume(strlen('important'));
216216
if(mb_convert_case($sImportantMarker, MB_CASE_LOWER) !== 'important') {
217-
throw new Exception("! was followed by “".$sImportantMarker."”. Expected “important”");
217+
throw new \Exception("! was followed by “".$sImportantMarker."”. Expected “important”");
218218
}
219219
$oRule->setIsImportant(true);
220220
}
@@ -403,13 +403,13 @@ private function consume($mValue = 1) {
403403
if(is_string($mValue)) {
404404
$iLength = mb_strlen($mValue, $this->sCharset);
405405
if(mb_substr($this->sText, $this->iCurrentPosition, $iLength, $this->sCharset) !== $mValue) {
406-
throw new Exception("Expected $mValue, got ".$this->peek(5));
406+
throw new \Exception("Expected $mValue, got ".$this->peek(5));
407407
}
408408
$this->iCurrentPosition += mb_strlen($mValue, $this->sCharset);
409409
return $mValue;
410410
} else {
411411
if($this->iCurrentPosition+$mValue > $this->iLength) {
412-
throw new Exception("Tried to consume $mValue chars, exceeded file end");
412+
throw new \Exception("Tried to consume $mValue chars, exceeded file end");
413413
}
414414
$sResult = mb_substr($this->sText, $this->iCurrentPosition, $mValue, $this->sCharset);
415415
$this->iCurrentPosition += $mValue;
@@ -422,7 +422,7 @@ private function consumeExpression($mExpression) {
422422
if(preg_match($mExpression, $this->inputLeft(), $aMatches, PREG_OFFSET_CAPTURE) === 1) {
423423
return $this->consume($aMatches[0][0]);
424424
}
425-
throw new Exception("Expected pattern $mExpression not found, got: {$this->peek(5)}");
425+
throw new \Exception("Expected pattern $mExpression not found, got: {$this->peek(5)}");
426426
}
427427

428428
private function consumeWhiteSpace() {
@@ -449,7 +449,7 @@ private function isEnd() {
449449
private function consumeUntil($sEnd) {
450450
$iEndPos = mb_strpos($this->sText, $sEnd, $this->iCurrentPosition, $this->sCharset);
451451
if($iEndPos === false) {
452-
throw new Exception("Required $sEnd not found, got {$this->peek(5)}");
452+
throw new \Exception("Required $sEnd not found, got {$this->peek(5)}");
453453
}
454454
return $this->consume($iEndPos-$this->iCurrentPosition);
455455
}

0 commit comments

Comments
 (0)