From a632cd64939ac4dd66bad7c589c822a0d19eb784 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sat, 21 Jan 2017 16:44:04 +0100 Subject: [PATCH] some classes & members marked as final (BC break) This reverts commit "Christmas Gift 2013" 0dfe244000b474c37fdd8539c8f7f75c93dcb01e. --- src/Utils/Callback.php | 2 +- src/Utils/FileSystem.php | 2 +- src/Utils/Html.php | 52 ++++++++++++++++++------------------- src/Utils/Json.php | 2 +- src/Utils/ObjectHelpers.php | 2 +- src/Utils/ObjectMixin.php | 2 +- src/Utils/Random.php | 2 +- src/Utils/Reflection.php | 2 +- 8 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/Utils/Callback.php b/src/Utils/Callback.php index cd77bbcd9..c1c4b8c01 100644 --- a/src/Utils/Callback.php +++ b/src/Utils/Callback.php @@ -16,7 +16,7 @@ /** * PHP callable tools. */ -class Callback +final class Callback { use Nette\StaticClass; diff --git a/src/Utils/FileSystem.php b/src/Utils/FileSystem.php index d211f5fd0..bf1ee0240 100644 --- a/src/Utils/FileSystem.php +++ b/src/Utils/FileSystem.php @@ -15,7 +15,7 @@ /** * File system tool. */ -class FileSystem +final class FileSystem { use Nette\StaticClass; diff --git a/src/Utils/Html.php b/src/Utils/Html.php index 56af35d95..3751db4ac 100644 --- a/src/Utils/Html.php +++ b/src/Utils/Html.php @@ -84,7 +84,7 @@ public static function el(string $name = NULL, $attrs = NULL) * @return static * @throws Nette\InvalidArgumentException */ - public function setName(string $name, bool $isEmpty = NULL) + final public function setName(string $name, bool $isEmpty = NULL) { $this->name = $name; $this->isEmpty = $isEmpty === NULL ? isset(static::$emptyElements[$name]) : $isEmpty; @@ -95,7 +95,7 @@ public function setName(string $name, bool $isEmpty = NULL) /** * Returns element's name. */ - public function getName(): string + final public function getName(): string { return $this->name; } @@ -104,7 +104,7 @@ public function getName(): string /** * Is element empty? */ - public function isEmpty(): bool + final public function isEmpty(): bool { return $this->isEmpty; } @@ -180,7 +180,7 @@ public function removeAttribute(string $name) * Overloaded setter for element's attribute. * @return void */ - public function __set(string $name, $value) + final public function __set(string $name, $value) { $this->attrs[$name] = $value; } @@ -190,7 +190,7 @@ public function __set(string $name, $value) * Overloaded getter for element's attribute. * @return mixed */ - public function &__get(string $name) + final public function &__get(string $name) { return $this->attrs[$name]; } @@ -199,7 +199,7 @@ public function &__get(string $name) /** * Overloaded tester for element's attribute. */ - public function __isset(string $name): bool + final public function __isset(string $name): bool { return isset($this->attrs[$name]); } @@ -209,7 +209,7 @@ public function __isset(string $name): bool * Overloaded unsetter for element's attribute. * @return void */ - public function __unset(string $name) + final public function __unset(string $name) { unset($this->attrs[$name]); } @@ -219,7 +219,7 @@ public function __unset(string $name) * Overloaded setter for element's attribute. * @return mixed */ - public function __call(string $m, array $args) + final public function __call(string $m, array $args) { $p = substr($m, 0, 3); if ($p === 'get' || $p === 'set' || $p === 'add') { @@ -250,7 +250,7 @@ public function __call(string $m, array $args) * Special setter for element's attribute. * @return static */ - public function href(string $path, array $query = NULL) + final public function href(string $path, array $query = NULL) { if ($query) { $query = http_build_query($query, '', '&'); @@ -283,7 +283,7 @@ public function data(string $name, $value = NULL) * @return static * @throws Nette\InvalidArgumentException */ - public function setHtml($html) + final public function setHtml($html) { if (is_array($html)) { throw new Nette\InvalidArgumentException(sprintf('Textual content must be a scalar, %s given.', gettype($html))); @@ -297,7 +297,7 @@ public function setHtml($html) /** * Returns element's HTML content. */ - public function getHtml(): string + final public function getHtml(): string { $s = ''; foreach ($this->children as $child) { @@ -316,7 +316,7 @@ public function getHtml(): string * @return static * @throws Nette\InvalidArgumentException */ - public function setText($text) + final public function setText($text) { if (!is_array($text) && !$text instanceof self) { $text = htmlspecialchars((string) $text, ENT_NOQUOTES, 'UTF-8'); @@ -328,7 +328,7 @@ public function setText($text) /** * Returns element's textual content. */ - public function getText(): string + final public function getText(): string { return html_entity_decode(strip_tags($this->getHtml()), ENT_QUOTES, 'UTF-8'); } @@ -339,7 +339,7 @@ public function getText(): string * @param Html|string Html node or raw HTML string * @return static */ - public function addHtml($child) + final public function addHtml($child) { return $this->insert(NULL, $child); } @@ -361,7 +361,7 @@ public function addText(string $text) * @param array|string $attrs element's attributes or raw HTML string * @return static created element */ - public function create(string $name, $attrs = NULL) + final public function create(string $name, $attrs = NULL) { $this->insert(NULL, $child = static::el($name, $attrs)); return $child; @@ -398,7 +398,7 @@ public function insert(int $index = NULL, $child, bool $replace = FALSE) * @param Html|string Html node or raw HTML string * @return void */ - public function offsetSet($index, $child) + final public function offsetSet($index, $child) { $this->insert($index, $child, TRUE); } @@ -409,7 +409,7 @@ public function offsetSet($index, $child) * @param int * @return static|string */ - public function offsetGet($index) + final public function offsetGet($index) { return $this->children[$index]; } @@ -419,7 +419,7 @@ public function offsetGet($index) * Exists child node? (\ArrayAccess implementation). * @param int */ - public function offsetExists($index): bool + final public function offsetExists($index): bool { return isset($this->children[$index]); } @@ -441,7 +441,7 @@ public function offsetUnset($index) /** * Returns children count. */ - public function count(): int + final public function count(): int { return count($this->children); } @@ -460,7 +460,7 @@ public function removeChildren() /** * Iterates over elements. */ - public function getIterator(): \ArrayIterator + final public function getIterator(): \ArrayIterator { return new \ArrayIterator($this->children); } @@ -469,7 +469,7 @@ public function getIterator(): \ArrayIterator /** * Returns all children. */ - public function getChildren(): array + final public function getChildren(): array { return $this->children; } @@ -478,7 +478,7 @@ public function getChildren(): array /** * Renders element's start tag, content and end tag. */ - public function render(int $indent = NULL): string + final public function render(int $indent = NULL): string { $s = $this->startTag(); @@ -506,7 +506,7 @@ public function render(int $indent = NULL): string } - public function __toString(): string + final public function __toString(): string { try { return $this->render(); @@ -519,7 +519,7 @@ public function __toString(): string /** * Returns element's start tag. */ - public function startTag(): string + final public function startTag(): string { if ($this->name) { return '<' . $this->name . $this->attributes() . (static::$xhtml && $this->isEmpty ? ' />' : '>'); @@ -533,7 +533,7 @@ public function startTag(): string /** * Returns element's end tag. */ - public function endTag(): string + final public function endTag(): string { return $this->name && !$this->isEmpty ? 'name . '>' : ''; } @@ -543,7 +543,7 @@ public function endTag(): string * Returns element's attributes. * @internal */ - public function attributes(): string + final public function attributes(): string { if (!is_array($this->attrs)) { return ''; diff --git a/src/Utils/Json.php b/src/Utils/Json.php index 6186a6843..99be8cd3a 100644 --- a/src/Utils/Json.php +++ b/src/Utils/Json.php @@ -15,7 +15,7 @@ /** * JSON encoder and decoder. */ -class Json +final class Json { use Nette\StaticClass; diff --git a/src/Utils/ObjectHelpers.php b/src/Utils/ObjectHelpers.php index 5bbe5d49a..d327035e2 100644 --- a/src/Utils/ObjectHelpers.php +++ b/src/Utils/ObjectHelpers.php @@ -16,7 +16,7 @@ /** * Nette\SmartObject helpers. */ -class ObjectHelpers +final class ObjectHelpers { use Nette\StaticClass; diff --git a/src/Utils/ObjectMixin.php b/src/Utils/ObjectMixin.php index 4f84e0701..f0d612b15 100644 --- a/src/Utils/ObjectMixin.php +++ b/src/Utils/ObjectMixin.php @@ -17,7 +17,7 @@ * Nette\Object behaviour mixin. * @deprecated */ -class ObjectMixin +final class ObjectMixin { use Nette\StaticClass; diff --git a/src/Utils/Random.php b/src/Utils/Random.php index cd0318ad8..e994ce433 100644 --- a/src/Utils/Random.php +++ b/src/Utils/Random.php @@ -15,7 +15,7 @@ /** * Secure random string generator. */ -class Random +final class Random { use Nette\StaticClass; diff --git a/src/Utils/Reflection.php b/src/Utils/Reflection.php index f528e244e..71d3206b8 100644 --- a/src/Utils/Reflection.php +++ b/src/Utils/Reflection.php @@ -15,7 +15,7 @@ /** * PHP reflection helpers. */ -class Reflection +final class Reflection { use Nette\StaticClass;