Small cleanup

This commit is contained in:
the-djmaze 2022-12-22 10:03:02 +01:00
parent 9f69a992c8
commit 7c4f1c309e
2 changed files with 9 additions and 12 deletions

View file

@ -2,9 +2,6 @@
namespace LessPHP; namespace LessPHP;
class stdClass extends \stdClass {};
class Exception extends \Exception {};
/** /**
* lessphp v0.3.9-sm * lessphp v0.3.9-sm
* http://leafo.net/lessphp * http://leafo.net/lessphp
@ -1480,7 +1477,7 @@ class lessc {
/* environment functions */ /* environment functions */
protected function makeOutputBlock($type, $selectors = null) { protected function makeOutputBlock($type, $selectors = null) {
$b = new stdclass; $b = new \stdClass;
$b->lines = array(); $b->lines = array();
$b->children = array(); $b->children = array();
$b->selectors = $selectors; $b->selectors = $selectors;
@ -1491,7 +1488,7 @@ class lessc {
// the state of execution // the state of execution
protected function pushEnv($block = null) { protected function pushEnv($block = null) {
$e = new stdclass; $e = new \stdClass;
$e->parent = $this->env; $e->parent = $this->env;
$e->store = array(); $e->store = array();
$e->block = $block; $e->block = $block;
@ -1595,7 +1592,7 @@ class lessc {
if ($this->sourceLoc >= 0) { if ($this->sourceLoc >= 0) {
$this->sourceParser->throwError($msg, $this->sourceLoc); $this->sourceParser->throwError($msg, $this->sourceLoc);
} }
throw new exception($msg); throw new \Exception($msg);
} }
static protected $cssColors = array( static protected $cssColors = array(
@ -1831,7 +1828,7 @@ class lessc_parser {
// TODO report where the block was opened // TODO report where the block was opened
if (!is_null($this->env->parent)) if (!is_null($this->env->parent))
throw new exception('parse error: unclosed block'); throw new \Exception('parse error: unclosed block');
return $this->env; return $this->env;
} }
@ -1962,7 +1959,7 @@ class lessc_parser {
if ($this->literal('}', false)) { if ($this->literal('}', false)) {
try { try {
$block = $this->pop(); $block = $this->pop();
} catch (exception $e) { } catch (\Exception $e) {
$this->seek($s); $this->seek($s);
$this->throwError($e->getMessage()); $this->throwError($e->getMessage());
} }
@ -2939,13 +2936,13 @@ class lessc_parser {
// TODO this depends on $this->count // TODO this depends on $this->count
if ($this->peek("(.*?)(\n|$)", $m, $count)) { if ($this->peek("(.*?)(\n|$)", $m, $count)) {
throw new exception("$msg: failed at `$m[1]` $loc"); throw new \Exception("$msg: failed at `$m[1]` $loc");
} }
throw new exception("$msg: $loc"); throw new \Exception("$msg: $loc");
} }
protected function pushBlock($selectors=null, $type=null) { protected function pushBlock($selectors=null, $type=null) {
$b = new stdclass; $b = new \stdClass;
$b->parent = $this->env; $b->parent = $this->env;
$b->type = $type; $b->type = $type;

View file

@ -66,7 +66,7 @@ class Client
if (!\preg_match('@^(https?:)?//@', $url)) { if (!\preg_match('@^(https?:)?//@', $url)) {
// If the url starts with a slash, we must calculate the url based off // If the url starts with a slash, we must calculate the url based off
// the root of the base url. // the root of the base url.
if (0 === \strpos($url, '/')) { if (\str_starts_with($url, '/')) {
$parts = \parse_url($this->baseUri); $parts = \parse_url($this->baseUri);
$url = $parts['scheme'] . '://' . $parts['host'] . (isset($parts['port'])?':' . $parts['port']:'') . $url; $url = $parts['scheme'] . '://' . $parts['host'] . (isset($parts['port'])?':' . $parts['port']:'') . $url;
} else { } else {