Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove static classes #206; Reactivate PHPCPD and PHPMD #220

Merged
merged 7 commits into from
May 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ before_script:
- pyrus install pear/PHP_CodeSniffer
- phpenv rehash
## PHP Copy/Paste Detector
#- curl -o phpcpd.phar https://phar.phpunit.de/phpcpd.phar
- curl -o phpcpd.phar https://phar.phpunit.de/phpcpd.phar
## PHP Mess Detector
#- pear config-set preferred_state beta
#- printf "\n" | pecl install imagick
#- pear channel-discover pear.phpmd.org
#- pear channel-discover pear.pdepend.org
#- pear install --alldeps phpmd/PHP_PMD
#- phpenv rehash
- pear config-set preferred_state beta
- printf "\n" | pecl install imagick
- pear channel-discover pear.phpmd.org
- pear channel-discover pear.pdepend.org
- pear install --alldeps phpmd/PHP_PMD
- phpenv rehash
## PHPLOC
#- curl -o phploc.phar https://phar.phpunit.de/phploc.phar
## PHPDocumentor
Expand All @@ -48,18 +48,17 @@ before_script:

script:
## PHP_CodeSniffer
- phpcs --standard=PSR2 -n src/ --ignore=src/PhpWord/Shared/PCLZip
- phpcs --standard=PSR2 -n tests/
- phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip
## PHP Copy/Paste Detector
#- php phpcpd.phar --verbose src/
- php phpcpd.phar src/ tests/ --verbose
## PHP Mess Detector
#- phpmd src/ text unusedcode,naming,design
- phpmd src/,tests/ text unusedcode,naming,design,controversial --exclude pclzip.lib.php
## PHPLOC
#- php phploc.phar src/
## PHPUnit
- phpunit -c ./ --coverage-text --coverage-html ./build/coverage
## PHPDocumentor
- vendor/bin/phpdoc.php -d ./src -t ./build/docs
- vendor/bin/phpdoc.php -d ./src -t ./build/docs -i ./src/PhpWord/Shared/PCLZip/*

after_script:
## PHPDocumentor
Expand Down
2 changes: 1 addition & 1 deletion .travis_shell_after_success.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if [ "$TRAVIS_REPO_SLUG" == "PHPOffice/PHPWord" ] && [ "$TRAVIS_PULL_REQUEST" ==

echo "--DEBUG : Git"
git add -f .
git commit -m "PHPDocumentor (Travis Build : $TRAVIS_BUILD_NUMBER - Branch : $TRAVIS_BRANCH)"
git commit -m "PHPDocumentor (Travis Build: $TRAVIS_BUILD_NUMBER - Branch: $TRAVIS_BRANCH)"
git push -fq origin gh-pages > /dev/null

echo -e "Published PHPDoc to gh-pages.\n"
Expand Down
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This is the changelog between releases of PHPWord. Releases are listed in revers

## 0.11.0 - Not yet released

PHPWord license is changed from LGPL 2.1 to LGPL 3 in this release.
This release changed PHPWord license from LGPL 2.1 to LGPL 3.

### Features

Expand All @@ -14,10 +14,17 @@ PHPWord license is changed from LGPL 2.1 to LGPL 3 in this release.

- ...

### Deprecated

- Static classes `Footnotes`, `Endnotes`, and `TOC`

### Miscellaneous

- License: Change the project license from LGPL 2.1 into LGPL 3.0 - GH-211
- Word2007 Writer: New `Style\Image` class - @ivanlanin
- Refactor: Replace static classes `Footnotes`, `Endnotes`, and `TOC` with `Collections` - @ivanlanin GH-206
- QA: Reactivate `phpcpd` and `phpmd` on Travis - @ivanlanin
- Refactor: PHPMD recommendation: Change all `get...` method that returns `boolean` into `is...` or `has...` - @ivanlanin

## 0.10.0 - 4 May 2014

Expand All @@ -43,7 +50,7 @@ This release marked heavy refactorings on internal code structure with the creat
- Link: Ability to add link in header/footer - @ivanlanin GH-187
- Object: Ability to add object in header, footer, textrun, and footnote - @ivanlanin GH-187
- Media: Add `Media::resetElements()` to reset all media data - @juzi GH-19
- General: Add `Style::resetStyles()`, `Footnote::resetElements()`, and `TOC::resetTitles()` - @ivanlanin GH-187
- General: Add `Style::resetStyles()` - @ivanlanin GH-187
- DOCX Reader: Ability to read header, footer, footnotes, link, preservetext, textbreak, pagebreak, table, list, image, and title - @ivanlanin
- Endnote: Ability to add endnotes - @ivanlanin
- ListItem: Ability to create custom list and reset list number - @ivanlanin GH-10 GH-198
Expand Down
14 changes: 0 additions & 14 deletions phpmd.xml

This file was deleted.

3 changes: 3 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="./build/coverage" charset="UTF-8" highlight="true" />
</logging>
</phpunit>
Binary file modified samples/resources/Sample_11_ReadWord2007.docx
Binary file not shown.
87 changes: 87 additions & 0 deletions src/PhpWord/Collection/AbstractCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php
/**
* PHPWord
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2014 PHPWord
* @license http:https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/

namespace PhpOffice\PhpWord\Collection;

/**
* Collection abstract class
*
* @since 0.10.0
*/
abstract class AbstractCollection
{
/**
* Items
*
* @var array
*/
private $items = array();

/**
* Get items
*
* @return array
*/
public function getItems()
{
return $this->items;
}

/**
* Get item by index
*
* @param int $index
* @return mixed
*/
public function getItem($index)
{
if (array_key_exists($index, $this->items)) {
return $this->items[$index];
} else {
return null;
}
}

/**
* Set item
*
* @param int $index
* @param mixed $item
*/
public function setItem($index, $item)
{
if (array_key_exists($index, $this->items)) {
$this->items[$index] = $item;
}
}

/**
* Add new item
*
* @param mixed $item
* @return int
*/
public function addItem($item)
{
$index = $this->countItems() + 1;
$this->items[$index] = $item;

return $index;
}

/**
* Get item count
*
* @return int
*/
public function countItems()
{
return count($this->items);
}
}
19 changes: 19 additions & 0 deletions src/PhpWord/Collection/Endnotes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* PHPWord
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2014 PHPWord
* @license http:https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/

namespace PhpOffice\PhpWord\Collection;

/**
* Endnotes collection
*
* @since 0.10.0
*/
class Endnotes extends AbstractCollection
{
}
19 changes: 19 additions & 0 deletions src/PhpWord/Collection/Footnotes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* PHPWord
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2014 PHPWord
* @license http:https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/

namespace PhpOffice\PhpWord\Collection;

/**
* Footnotes collection
*
* @since 0.10.0
*/
class Footnotes extends AbstractCollection
{
}
19 changes: 19 additions & 0 deletions src/PhpWord/Collection/Titles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* PHPWord
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2014 PHPWord
* @license http:https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/

namespace PhpOffice\PhpWord\Collection;

/**
* Titles collection
*
* @since 0.10.0
*/
class Titles extends AbstractCollection
{
}
Loading