Skip to content

Commit c78e24b

Browse files
committed
PHPMD fixes
1 parent c3817bc commit c78e24b

File tree

11 files changed

+27
-28
lines changed

11 files changed

+27
-28
lines changed

Classes/PHPPowerPoint/Shared/ZipStreamWrapper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ public static function register()
7474
/**
7575
* Open stream
7676
*
77+
* Original param array $options and string $opened_path aren't used
78+
*
7779
* @param string $path
7880
* @param string $mode
79-
* @param array $options
80-
* @param string $opened_path
8181
*/
82-
public function stream_open($path, $mode, $options, &$opened_path)
82+
public function stream_open($path, $mode)
8383
{
8484
// Check for mode
8585
if ($mode{0} != 'r') {

Classes/PHPPowerPoint/Writer/ODPresentation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function save($pFilename = null)
129129

130130
// Add mimetype to ZIP file
131131
//@todo Not in ZIPARCHIVE::CM_STORE mode
132-
$objZip->addFromString('mimetype', $this->getWriterPart('mimetype')->writeMimetype($this->_presentation));
132+
$objZip->addFromString('mimetype', $this->getWriterPart('mimetype')->writeMimetype());
133133

134134
// Add content.xml to ZIP file
135135
$objZip->addFromString('content.xml', $this->getWriterPart('content')->writeContent($this->_presentation));
@@ -141,7 +141,7 @@ public function save($pFilename = null)
141141
$objZip->addFromString('styles.xml', $this->getWriterPart('styles')->writeStyles($this->_presentation));
142142

143143
// Add META-INF/manifest.xml
144-
$objZip->addFromString('META-INF/manifest.xml', $this->getWriterPart('manifest')->writeManifest($this->_presentation));
144+
$objZip->addFromString('META-INF/manifest.xml', $this->getWriterPart('manifest')->writeManifest());
145145

146146
// Add media
147147
$arrMedia = array();

Classes/PHPPowerPoint/Writer/ODPresentation/Manifest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ class PHPPowerPoint_Writer_ODPresentation_Manifest extends PHPPowerPoint_Writer_
3737
/**
3838
* Write Manifest file to XML format
3939
*
40-
* @param PHPPowerPoint $pPHPPowerPoint
4140
* @return string XML Output
4241
* @throws Exception
4342
*/
44-
public function writeManifest(PHPPowerPoint $pPHPPowerPoint = null)
43+
public function writeManifest()
4544
{
4645
// Create XML writer
4746
$objWriter = null;

Classes/PHPPowerPoint/Writer/ODPresentation/Mimetype.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ class PHPPowerPoint_Writer_ODPresentation_Mimetype extends PHPPowerPoint_Writer_
3737
/**
3838
* Write Mimetype to Text format
3939
*
40-
* @param PHPPowerPoint $pPHPPowerPoint
4140
* @return string Text Output
4241
* @throws Exception
4342
*/
44-
public function writeMimetype(PHPPowerPoint $pPHPPowerPoint = null)
43+
public function writeMimetype()
4544
{
4645
return 'application/vnd.oasis.opendocument.presentation';
4746
}

Classes/PHPPowerPoint/Writer/PowerPoint2007.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public function save($pFilename = null)
168168
$objZip->addFromString('[Content_Types].xml', $this->getWriterPart('ContentTypes')->writeContentTypes($this->_presentation));
169169

170170
// Add relationships to ZIP file
171-
$objZip->addFromString('_rels/.rels', $this->getWriterPart('Rels')->writeRelationships($this->_presentation));
171+
$objZip->addFromString('_rels/.rels', $this->getWriterPart('Rels')->writeRelationships());
172172
$objZip->addFromString('ppt/_rels/presentation.xml.rels', $this->getWriterPart('Rels')->writePresentationRelationships($this->_presentation));
173173

174174
// Add document properties to ZIP file
@@ -179,7 +179,7 @@ public function save($pFilename = null)
179179
$masterSlides = $this->getLayoutPack()->getMasterSlides();
180180
foreach ($masterSlides as $masterSlide) {
181181
$objZip->addFromString('ppt/theme/_rels/theme' . $masterSlide['masterid'] . '.xml.rels', $this->getWriterPart('Rels')->writeThemeRelationships($masterSlide['masterid']));
182-
$objZip->addFromString('ppt/theme/theme' . $masterSlide['masterid'] . '.xml', utf8_encode($this->getWriterPart('Theme')->writeTheme($this->_presentation, $masterSlide['masterid'])));
182+
$objZip->addFromString('ppt/theme/theme' . $masterSlide['masterid'] . '.xml', utf8_encode($this->getWriterPart('Theme')->writeTheme($masterSlide['masterid'])));
183183
}
184184

185185
// Add slide masters to ZIP file
@@ -223,7 +223,9 @@ public function save($pFilename = null)
223223
// Add slides (drawings, ...) and slide relationships (drawings, ...)
224224
for ($i = 0; $i < $this->_presentation->getSlideCount(); ++$i) {
225225
// Add slide
226-
$objZip->addFromString('ppt/slides/_rels/slide' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeSlideRelationships($this->_presentation->getSlide($i), ($i + 1)));
226+
$objZip->addFromString(
227+
'ppt/slides/_rels/slide' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeSlideRelationships($this->_presentation->getSlide($i))
228+
);
227229
$objZip->addFromString('ppt/slides/slide' . ($i + 1) . '.xml', $this->getWriterPart('Slide')->writeSlide($this->_presentation->getSlide($i)));
228230
}
229231

Classes/PHPPowerPoint/Writer/PowerPoint2007/LayoutPack.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,12 @@ public function findLayout($name = '', $masterId = 1)
207207
*/
208208
public function findLayoutIndex($name = '', $masterId = 1)
209209
{
210-
$i = 0;
210+
$index = 0;
211211
foreach ($this->_layouts as $layout) {
212212
if ($layout['name'] == $name && $layout['masterid'] == $masterId) {
213-
return $i;
213+
return $index;
214214
}
215-
216-
++$i;
215+
++$index;
217216
}
218217

219218
throw new Exception("Could not find slide layout $name in current layout pack.");

Classes/PHPPowerPoint/Writer/PowerPoint2007/LayoutPack/TemplateBased.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,16 +171,16 @@ public function __construct($fileName = '')
171171
/**
172172
* Compare master slides
173173
*
174-
* @param array $a
175-
* @param array $b
174+
* @param array $firstSlide
175+
* @param array $secondSlide
176176
*/
177-
public static function cmp_master($a, $b)
177+
public static function cmp_master($firstSlide, $secondSlide)
178178
{
179-
if ($a['masterid'] == $b['masterid']) {
179+
if ($firstSlide['masterid'] == $secondSlide['masterid']) {
180180
return 0;
181181
}
182182

183-
return ($a['masterid'] < $b['masterid']) ? -1 : 1;
183+
return ($firstSlide['masterid'] < $secondSlide['masterid']) ? -1 : 1;
184184
}
185185

186186
/**

Classes/PHPPowerPoint/Writer/PowerPoint2007/Presentation.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ public function writePresentation(PHPPowerPoint $pPHPPowerPoint = null)
6767
$relationId = 1;
6868
$slideMasterId = 2147483648;
6969
$masterSlides = $this->getParentWriter()->getLayoutPack()->getMasterSlides();
70-
foreach ($masterSlides as $masterSlide) {
70+
$masterSlidesCount = count($masterSlides);
71+
// @todo foreach ($masterSlides as $masterSlide)
72+
for ($i = 0; $i < $masterSlidesCount; $i++) {
7173
// p:sldMasterId
7274
$objWriter->startElement('p:sldMasterId');
7375
$objWriter->writeAttribute('id', $slideMasterId);

Classes/PHPPowerPoint/Writer/PowerPoint2007/Rels.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ class PHPPowerPoint_Writer_PowerPoint2007_Rels extends PHPPowerPoint_Writer_Powe
3737
/**
3838
* Write relationships to XML format
3939
*
40-
* @param PHPPowerPoint $pPHPPowerPoint
4140
* @return string XML Output
4241
* @throws Exception
4342
*/
44-
public function writeRelationships(PHPPowerPoint $pPHPPowerPoint = null)
43+
public function writeRelationships()
4544
{
4645
// Create XML writer
4746
$objWriter = null;
@@ -271,11 +270,10 @@ public function writeThemeRelationships($masterId = 1)
271270
* Write slide relationships to XML format
272271
*
273272
* @param PHPPowerPoint_Slide $pSlide
274-
* @param int $pSlideId
275273
* @return string XML Output
276274
* @throws Exception
277275
*/
278-
public function writeSlideRelationships(PHPPowerPoint_Slide $pSlide = null, $pSlideId = 1)
276+
public function writeSlideRelationships(PHPPowerPoint_Slide $pSlide = null)
279277
{
280278
// Create XML writer
281279
$objWriter = null;

Classes/PHPPowerPoint/Writer/PowerPoint2007/Theme.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class PHPPowerPoint_Writer_PowerPoint2007_Theme extends PHPPowerPoint_Writer_Pow
4242
* @return string XML Output
4343
* @throws Exception
4444
*/
45-
public function writeTheme(PHPPowerPoint $pPHPPowerPoint = null, $masterId = 1)
45+
public function writeTheme($masterId = 1)
4646
{
4747
// Write theme from layout pack
4848
$layoutPack = $this->getParentWriter()->getLayoutPack();

0 commit comments

Comments
 (0)