Skip to content

Commit acd25a4

Browse files
committed
Merge pull request #220 from ivanlanin/nonstatic
Remove static classes #206; Reactivate PHPCPD and PHPMD
2 parents 6c3d1e7 + fd4fa11 commit acd25a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1258
-1338
lines changed

.travis.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ before_script:
3232
- pyrus install pear/PHP_CodeSniffer
3333
- phpenv rehash
3434
## PHP Copy/Paste Detector
35-
#- curl -o phpcpd.phar https://phar.phpunit.de/phpcpd.phar
35+
- curl -o phpcpd.phar https://phar.phpunit.de/phpcpd.phar
3636
## PHP Mess Detector
37-
#- pear config-set preferred_state beta
38-
#- printf "\n" | pecl install imagick
39-
#- pear channel-discover pear.phpmd.org
40-
#- pear channel-discover pear.pdepend.org
41-
#- pear install --alldeps phpmd/PHP_PMD
42-
#- phpenv rehash
37+
- pear config-set preferred_state beta
38+
- printf "\n" | pecl install imagick
39+
- pear channel-discover pear.phpmd.org
40+
- pear channel-discover pear.pdepend.org
41+
- pear install --alldeps phpmd/PHP_PMD
42+
- phpenv rehash
4343
## PHPLOC
4444
#- curl -o phploc.phar https://phar.phpunit.de/phploc.phar
4545
## PHPDocumentor
@@ -48,18 +48,17 @@ before_script:
4848

4949
script:
5050
## PHP_CodeSniffer
51-
- phpcs --standard=PSR2 -n src/ --ignore=src/PhpWord/Shared/PCLZip
52-
- phpcs --standard=PSR2 -n tests/
51+
- phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip
5352
## PHP Copy/Paste Detector
54-
#- php phpcpd.phar --verbose src/
53+
- php phpcpd.phar src/ tests/ --verbose
5554
## PHP Mess Detector
56-
#- phpmd src/ text unusedcode,naming,design
55+
- phpmd src/,tests/ text unusedcode,naming,design,controversial --exclude pclzip.lib.php
5756
## PHPLOC
5857
#- php phploc.phar src/
5958
## PHPUnit
6059
- phpunit -c ./ --coverage-text --coverage-html ./build/coverage
6160
## PHPDocumentor
62-
- vendor/bin/phpdoc.php -d ./src -t ./build/docs
61+
- vendor/bin/phpdoc.php -d ./src -t ./build/docs -i ./src/PhpWord/Shared/PCLZip/*
6362

6463
after_script:
6564
## PHPDocumentor

.travis_shell_after_success.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if [ "$TRAVIS_REPO_SLUG" == "PHPOffice/PHPWord" ] && [ "$TRAVIS_PULL_REQUEST" ==
3131

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

3737
echo -e "Published PHPDoc to gh-pages.\n"

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This is the changelog between releases of PHPWord. Releases are listed in revers
44

55
## 0.11.0 - Not yet released
66

7-
PHPWord license is changed from LGPL 2.1 to LGPL 3 in this release.
7+
This release changed PHPWord license from LGPL 2.1 to LGPL 3.
88

99
### Features
1010

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

1515
- ...
1616

17+
### Deprecated
18+
19+
- Static classes `Footnotes`, `Endnotes`, and `TOC`
20+
1721
### Miscellaneous
1822

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

2229
## 0.10.0 - 4 May 2014
2330

@@ -43,7 +50,7 @@ This release marked heavy refactorings on internal code structure with the creat
4350
- Link: Ability to add link in header/footer - @ivanlanin GH-187
4451
- Object: Ability to add object in header, footer, textrun, and footnote - @ivanlanin GH-187
4552
- Media: Add `Media::resetElements()` to reset all media data - @juzi GH-19
46-
- General: Add `Style::resetStyles()`, `Footnote::resetElements()`, and `TOC::resetTitles()` - @ivanlanin GH-187
53+
- General: Add `Style::resetStyles()` - @ivanlanin GH-187
4754
- DOCX Reader: Ability to read header, footer, footnotes, link, preservetext, textbreak, pagebreak, table, list, image, and title - @ivanlanin
4855
- Endnote: Ability to add endnotes - @ivanlanin
4956
- ListItem: Ability to create custom list and reset list number - @ivanlanin GH-10 GH-198

phpmd.xml

Lines changed: 0 additions & 14 deletions
This file was deleted.

phpunit.xml.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@
2121
</exclude>
2222
</whitelist>
2323
</filter>
24+
<logging>
25+
<log type="coverage-html" target="./build/coverage" charset="UTF-8" highlight="true" />
26+
</logging>
2427
</phpunit>
0 Bytes
Binary file not shown.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
/**
3+
* PHPWord
4+
*
5+
* @link https://github.com/PHPOffice/PHPWord
6+
* @copyright 2014 PHPWord
7+
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
8+
*/
9+
10+
namespace PhpOffice\PhpWord\Collection;
11+
12+
/**
13+
* Collection abstract class
14+
*
15+
* @since 0.10.0
16+
*/
17+
abstract class AbstractCollection
18+
{
19+
/**
20+
* Items
21+
*
22+
* @var array
23+
*/
24+
private $items = array();
25+
26+
/**
27+
* Get items
28+
*
29+
* @return array
30+
*/
31+
public function getItems()
32+
{
33+
return $this->items;
34+
}
35+
36+
/**
37+
* Get item by index
38+
*
39+
* @param int $index
40+
* @return mixed
41+
*/
42+
public function getItem($index)
43+
{
44+
if (array_key_exists($index, $this->items)) {
45+
return $this->items[$index];
46+
} else {
47+
return null;
48+
}
49+
}
50+
51+
/**
52+
* Set item
53+
*
54+
* @param int $index
55+
* @param mixed $item
56+
*/
57+
public function setItem($index, $item)
58+
{
59+
if (array_key_exists($index, $this->items)) {
60+
$this->items[$index] = $item;
61+
}
62+
}
63+
64+
/**
65+
* Add new item
66+
*
67+
* @param mixed $item
68+
* @return int
69+
*/
70+
public function addItem($item)
71+
{
72+
$index = $this->countItems() + 1;
73+
$this->items[$index] = $item;
74+
75+
return $index;
76+
}
77+
78+
/**
79+
* Get item count
80+
*
81+
* @return int
82+
*/
83+
public function countItems()
84+
{
85+
return count($this->items);
86+
}
87+
}

src/PhpWord/Collection/Endnotes.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* PHPWord
4+
*
5+
* @link https://github.com/PHPOffice/PHPWord
6+
* @copyright 2014 PHPWord
7+
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
8+
*/
9+
10+
namespace PhpOffice\PhpWord\Collection;
11+
12+
/**
13+
* Endnotes collection
14+
*
15+
* @since 0.10.0
16+
*/
17+
class Endnotes extends AbstractCollection
18+
{
19+
}

src/PhpWord/Collection/Footnotes.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* PHPWord
4+
*
5+
* @link https://github.com/PHPOffice/PHPWord
6+
* @copyright 2014 PHPWord
7+
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
8+
*/
9+
10+
namespace PhpOffice\PhpWord\Collection;
11+
12+
/**
13+
* Footnotes collection
14+
*
15+
* @since 0.10.0
16+
*/
17+
class Footnotes extends AbstractCollection
18+
{
19+
}

src/PhpWord/Collection/Titles.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* PHPWord
4+
*
5+
* @link https://github.com/PHPOffice/PHPWord
6+
* @copyright 2014 PHPWord
7+
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
8+
*/
9+
10+
namespace PhpOffice\PhpWord\Collection;
11+
12+
/**
13+
* Titles collection
14+
*
15+
* @since 0.10.0
16+
*/
17+
class Titles extends AbstractCollection
18+
{
19+
}

0 commit comments

Comments
 (0)