1
This commit is contained in:
@@ -21,22 +21,23 @@ namespace PhpOffice\PhpWord\Collection;
|
||||
* Collection abstract class.
|
||||
*
|
||||
* @since 0.10.0
|
||||
* @template T
|
||||
*/
|
||||
abstract class AbstractCollection
|
||||
{
|
||||
/**
|
||||
* Items.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Element\AbstractContainer[]
|
||||
* @var T[]
|
||||
*/
|
||||
private $items = [];
|
||||
|
||||
/**
|
||||
* Get items.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractContainer[]
|
||||
* @return T[]
|
||||
*/
|
||||
public function getItems()
|
||||
public function getItems(): array
|
||||
{
|
||||
return $this->items;
|
||||
}
|
||||
@@ -44,11 +45,9 @@ abstract class AbstractCollection
|
||||
/**
|
||||
* Get item by index.
|
||||
*
|
||||
* @param int $index
|
||||
*
|
||||
* @return ?\PhpOffice\PhpWord\Element\AbstractContainer
|
||||
* @return ?T
|
||||
*/
|
||||
public function getItem($index)
|
||||
public function getItem(int $index)
|
||||
{
|
||||
if (array_key_exists($index, $this->items)) {
|
||||
return $this->items[$index];
|
||||
@@ -60,10 +59,9 @@ abstract class AbstractCollection
|
||||
/**
|
||||
* Set item.
|
||||
*
|
||||
* @param int $index
|
||||
* @param ?\PhpOffice\PhpWord\Element\AbstractContainer $item
|
||||
* @param ?T $item
|
||||
*/
|
||||
public function setItem($index, $item): void
|
||||
public function setItem(int $index, $item): void
|
||||
{
|
||||
if (array_key_exists($index, $this->items)) {
|
||||
$this->items[$index] = $item;
|
||||
@@ -73,11 +71,9 @@ abstract class AbstractCollection
|
||||
/**
|
||||
* Add new item.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $item
|
||||
*
|
||||
* @return int
|
||||
* @param T $item
|
||||
*/
|
||||
public function addItem($item)
|
||||
public function addItem($item): int
|
||||
{
|
||||
$index = $this->countItems();
|
||||
$this->items[$index] = $item;
|
||||
@@ -87,10 +83,8 @@ abstract class AbstractCollection
|
||||
|
||||
/**
|
||||
* Get item count.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function countItems()
|
||||
public function countItems(): int
|
||||
{
|
||||
return count($this->items);
|
||||
}
|
||||
|
||||
@@ -17,10 +17,13 @@
|
||||
|
||||
namespace PhpOffice\PhpWord\Collection;
|
||||
|
||||
use PhpOffice\PhpWord\Element\Bookmark;
|
||||
|
||||
/**
|
||||
* Bookmarks collection.
|
||||
*
|
||||
* @since 0.12.0
|
||||
* @extends AbstractCollection<Bookmark>
|
||||
*/
|
||||
class Bookmarks extends AbstractCollection
|
||||
{
|
||||
|
||||
@@ -17,10 +17,13 @@
|
||||
|
||||
namespace PhpOffice\PhpWord\Collection;
|
||||
|
||||
use PhpOffice\PhpWord\Element\Chart;
|
||||
|
||||
/**
|
||||
* Charts collection.
|
||||
*
|
||||
* @since 0.12.0
|
||||
* @extends AbstractCollection<Chart>
|
||||
*/
|
||||
class Charts extends AbstractCollection
|
||||
{
|
||||
|
||||
@@ -17,10 +17,13 @@
|
||||
|
||||
namespace PhpOffice\PhpWord\Collection;
|
||||
|
||||
use PhpOffice\PhpWord\Element\Comment;
|
||||
|
||||
/**
|
||||
* Comments collection.
|
||||
*
|
||||
* @since 0.12.0
|
||||
* @extends AbstractCollection<Comment>
|
||||
*/
|
||||
class Comments extends AbstractCollection
|
||||
{
|
||||
|
||||
@@ -17,10 +17,13 @@
|
||||
|
||||
namespace PhpOffice\PhpWord\Collection;
|
||||
|
||||
use PhpOffice\PhpWord\Element\Endnote;
|
||||
|
||||
/**
|
||||
* Endnotes collection.
|
||||
*
|
||||
* @since 0.10.0
|
||||
* @extends AbstractCollection<Endnote>
|
||||
*/
|
||||
class Endnotes extends AbstractCollection
|
||||
{
|
||||
|
||||
@@ -17,10 +17,13 @@
|
||||
|
||||
namespace PhpOffice\PhpWord\Collection;
|
||||
|
||||
use PhpOffice\PhpWord\Element\Footnote;
|
||||
|
||||
/**
|
||||
* Footnotes collection.
|
||||
*
|
||||
* @since 0.10.0
|
||||
* @extends AbstractCollection<Footnote>
|
||||
*/
|
||||
class Footnotes extends AbstractCollection
|
||||
{
|
||||
|
||||
@@ -17,10 +17,13 @@
|
||||
|
||||
namespace PhpOffice\PhpWord\Collection;
|
||||
|
||||
use PhpOffice\PhpWord\Element\Title;
|
||||
|
||||
/**
|
||||
* Titles collection.
|
||||
*
|
||||
* @since 0.10.0
|
||||
* @extends AbstractCollection<Title>
|
||||
*/
|
||||
class Titles extends AbstractCollection
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user