Skip to content

Commit fb7608f

Browse files
committed
improved phpDoc
1 parent 901e4a1 commit fb7608f

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

src/ComponentModel/Component.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313

1414

1515
/**
16-
* Component is the base class for all components.
17-
*
18-
* Components are objects implementing IComponent. They has parent component and own name.
16+
* Base class for all components. Components have a parent, name, and can be monitored by ancestors.
1917
*
2018
* @property-read string $name
2119
* @property-read IContainer|null $parent
@@ -32,7 +30,7 @@ abstract class Component implements IComponent
3230

3331

3432
/**
35-
* Finds the closest ancestor specified by class or interface name.
33+
* Finds the closest ancestor of specified type.
3634
* @param bool $throw throw exception if component doesn't exist?
3735
* @return ($throw is true ? IComponent : ?IComponent)
3836
*/
@@ -88,7 +86,7 @@ final public function lookupPath(?string $type = null, bool $throw = true): ?str
8886

8987

9088
/**
91-
* Starts monitoring of ancestors.
89+
* Starts monitoring ancestors for attach/detach events.
9290
*/
9391
final public function monitor(string $type, ?callable $attached = null, ?callable $detached = null): void
9492
{
@@ -110,7 +108,7 @@ final public function monitor(string $type, ?callable $attached = null, ?callabl
110108

111109

112110
/**
113-
* Stops monitoring of ancestors.
111+
* Stops monitoring ancestors of specified type.
114112
*/
115113
final public function unmonitor(string $type): void
116114
{
@@ -198,8 +196,8 @@ public function setParent(?IContainer $parent, ?string $name = null): static
198196

199197

200198
/**
201-
* Is called by a component when it is about to be set new parent. Descendant can
202-
* override this method to disallow a parent change by throwing an Nette\InvalidStateException
199+
* Validates the new parent before it's set.
200+
* Descendant classes can override this to implement custom validation logic.
203201
* @throws Nette\InvalidStateException
204202
*/
205203
protected function validateParent(IContainer $parent): void

src/ComponentModel/Container.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
/**
16-
* ComponentContainer is default implementation of IContainer.
16+
* Manages a collection of child components.
1717
*
1818
* @property-read IComponent[] $components
1919
*/
@@ -30,7 +30,7 @@ class Container extends Component implements IContainer
3030

3131

3232
/**
33-
* Adds the component to the container.
33+
* Adds a child component to the container.
3434
* @return static
3535
* @throws Nette\InvalidStateException
3636
*/
@@ -91,7 +91,7 @@ public function addComponent(IComponent $component, ?string $name, ?string $inse
9191

9292

9393
/**
94-
* Removes the component from the container.
94+
* Removes a child component from the container.
9595
*/
9696
public function removeComponent(IComponent $component): void
9797
{
@@ -106,7 +106,7 @@ public function removeComponent(IComponent $component): void
106106

107107

108108
/**
109-
* Returns component specified by name or path.
109+
* Retrieves a child component by name or creates it if it doesn't exist.
110110
* @param bool $throw throw exception if component doesn't exist?
111111
* @return ($throw is true ? IComponent : ?IComponent)
112112
*/
@@ -153,7 +153,7 @@ final public function getComponent(string $name, bool $throw = true): ?IComponen
153153

154154

155155
/**
156-
* Component factory. Delegates the creation of components to a createComponent<Name> method.
156+
* Creates a new component. Delegates creation to createComponent<Name> method if it exists.
157157
*/
158158
protected function createComponent(string $name): ?IComponent
159159
{
@@ -178,7 +178,7 @@ protected function createComponent(string $name): ?IComponent
178178

179179

180180
/**
181-
* Returns immediate child components.
181+
* Returns all immediate child components.
182182
* @return array<int|string,IComponent>
183183
*/
184184
final public function getComponents(): iterable
@@ -217,7 +217,8 @@ final public function getComponentTree(): array
217217

218218

219219
/**
220-
* Descendant can override this method to disallow insert a child by throwing an Nette\InvalidStateException.
220+
* Validates a child component before it's added to the container.
221+
* Descendant classes can override this to implement custom validation logic.
221222
* @throws Nette\InvalidStateException
222223
*/
223224
protected function validateChildComponent(IComponent $child): void
@@ -229,7 +230,7 @@ protected function validateChildComponent(IComponent $child): void
229230

230231

231232
/**
232-
* Object cloning.
233+
* Handles object cloning. Clones all child components and re-sets their parents.
233234
*/
234235
public function __clone()
235236
{

src/ComponentModel/IComponent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
/**
14-
* Provides functionality required by all components.
14+
* Defines core functionality required by all components.
1515
*/
1616
interface IComponent
1717
{
@@ -29,7 +29,7 @@ function getName(): ?string;
2929
function getParent(): ?IContainer;
3030

3131
/**
32-
* Sets the parent of this component.
32+
* Sets the parent container and optionally renames the component.
3333
*/
3434
function setParent(?IContainer $parent, ?string $name = null): static;
3535
}

src/ComponentModel/IContainer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
/**
16-
* Containers are objects that logically contain zero or more IComponent components.
16+
* Defines functionality for objects that can contain other components.
1717
*/
1818
interface IContainer extends IComponent
1919
{

0 commit comments

Comments
 (0)