Skip to content

Commit 50ce4ac

Browse files
author
Vítězslav Dvořák
committed
Refactors documentation and class structure in Container and Document
Improves class documentation for Container and Document by restructuring property and method annotations for clarity. Removes redundant comments and enhances the readability of the code. Updates the `getUri` method to provide a safer alternative to PHP_SELF, ensuring better security practices. Ensures consistent documentation style across classes.
1 parent b25cdcd commit 50ce4ac

2 files changed

Lines changed: 51 additions & 37 deletions

File tree

src/Ease/Container.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@
99
*
1010
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
1111
*
12-
/**
13-
* Class Container
14-
*
15-
* @property array $pageParts Array of objects and fragments to draw
16-
* @property bool $drawStatus Has the page already been rendered?
17-
* @property bool $finalized Is class finalized?
18-
* @property string|null $embedName Name of the embedded part
19-
*
20-
* @method mixed addItem(mixed $pageItem) Include next element into current object
21-
* @method bool setEmbedName(string $embedName) Notify component about its embed name
22-
* @method void afterAdd() Method executed after adding object into new one
23-
* @method void finalize() Method executed before rendering
24-
* @method bool finalized(?bool $state = null) Get/Set finalization flag
25-
* @method void draw() Recursive draw object and its contents
26-
*
27-
* @inheritdoc
28-
*/
29-
class Container extends \Ease\Sand implements \Ease\Embedable
12+
* For the full copyright and license information, please view the LICENSE
3013
* file that was distributed with this source code.
3114
*/
3215

3316
namespace Ease;
3417

18+
/**
19+
* Class Container.
20+
*
21+
* @property bool $drawStatus Has the page already been rendered?
22+
* @property null|string $embedName Name of the embedded part
23+
* @property bool $finalized Is class finalized?
24+
* @property array $pageParts Array of objects and fragments to draw
25+
*
26+
* @method mixed addItem(mixed $pageItem) Include next element into current object
27+
* @method void afterAdd() Method executed after adding object into new one
28+
* @method void draw() Recursive draw object and its contents
29+
*
30+
* {@inheritDoc}
31+
* @method void finalize() Method executed before rendering
32+
* @method bool finalized(?bool $state = null) Get/Set finalization flag
33+
* @method bool setEmbedName(string $embedName) Notify component about its embed name
34+
*/
3535
class Container extends Sand implements Embedable
3636
{
3737
use Glue;

src/Ease/Document.php

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717

1818
/**
1919
* An object designed to "hold" content - not visible itself.
20+
*
21+
* Class Document
22+
*
23+
* @property array $allItems Array of links to all embedded objects
24+
* @property object $lastItem A link to the last element added
25+
* @property bool $pageClosed Is page closed for adding new contents?
26+
* @property array $raiseItems Which objects to take over from the accepting object
27+
* @property \Ease\WebPage $webPage A link to the base object of the page
2028
*/
2129
class Document extends Container
2230
{
@@ -133,25 +141,31 @@ public function redirect($url): void
133141
} else {
134142
header('Location: '.$url);
135143
}
136-
/**
137-
* Class Document
138-
*
139-
* @property \Ease\WebPage $webPage A link to the base object of the page
140-
* @property array $raiseItems Which objects to take over from the accepting object
141-
* @property object $lastItem A link to the last element added
142-
* @property bool $pageClosed Is page closed for adding new contents?
143-
* @property array $allItems Array of links to all embedded objects
144-
*
145-
* @method int addJavaScript(string $javaScript, ?string $position = '0', bool $inDocumentReady = true) Inserts JavaScript into the page
146-
* @method string includeJavaScript(string $javaScriptFile, ?string $position = null) Includes Javascript into the page
147-
* @method bool addCSS(string $css) Add another CSS definition to stack
148-
* @method bool includeCss(string $cssFile, bool $fwPrefix = false, string $media = 'screen') Include an CSS file call into page
149-
* @method void redirect(string $url) Perform http redirect
150-
* @method string getUri() Returns the desired address
151-
* @method string phpSelf(bool $dropqs = true) Returns the current URL
152-
* @inheritdoc
153-
*/
154-
class Document extends \Ease\Container
144+
145+
session_write_close();
146+
WebPage::$pageClosed = true;
147+
}
148+
149+
/**
150+
* Returns the desired address.
151+
*
152+
* @method bool addCSS(string $css) Add another CSS definition to stack
153+
* @method int addJavaScript(string $javaScript, ?string $position = '0', bool $inDocumentReady = true) Inserts JavaScript into the page
154+
* @method string getUri() Returns the desired address
155+
* @method bool includeCss(string $cssFile, bool $fwPrefix = false, string $media = 'screen') Include an CSS file call into page
156+
* @method string includeJavaScript(string $javaScriptFile, ?string $position = null) Includes Javascript into the page
157+
* @method string phpSelf(bool $dropqs = true) Returns the current URL
158+
* {@inheritDoc}
159+
* @method void redirect(string $url) Perform http redirect
160+
*/
161+
public static function getUri()
162+
{
163+
return $_SERVER['REQUEST_URI'];
164+
}
165+
166+
/**
167+
* Returns the current URL. This is instead of PHP_SELF which is unsafe.
168+
*
155169
* @param bool $dropqs whether to drop the querystring or not. Default true
156170
*
157171
* @return string the current URL or NULL for php-cli

0 commit comments

Comments
 (0)