Skip to content

Commit 8cc08db

Browse files
committed
Fixed PHPCSFixer
1 parent afbff36 commit 8cc08db

File tree

15 files changed

+132
-119
lines changed

15 files changed

+132
-119
lines changed

phpunit.xml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@
3030
</testsuite>
3131
</testsuites>
3232
<logging/>
33-
</phpunit>
33+
</phpunit>

samples/Sample_21_Password.php

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
include_once 'Sample_Header.php';
66

77
use PhpOffice\PhpPresentation\IOFactory;
8-
use PhpOffice\PhpPresentation\Slide;
9-
use PhpOffice\PhpPresentation\Shape\RichText;
108

119
echo '<h2>ODPresentation</h2>';
1210
$pptReader = IOFactory::createReader('ODPresentation');

samples/Sample_Header.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
use PhpOffice\PhpPresentation\Style\Bullet;
1818
use PhpOffice\PhpPresentation\Style\Color;
1919

20-
function hex_dump($data, $newline = "\n")
20+
function hex_dump($data, $newline = "\n"): void
2121
{
2222
static $from = '';
2323
static $to = '';
2424

25-
static $width = 16; # number of bytes per line
25+
static $width = 16; // number of bytes per line
2626

27-
static $pad = '.'; # padding for non-visible characters
27+
static $pad = '.'; // padding for non-visible characters
2828

2929
if ($from === '') {
30-
for ($i = 0; $i <= 0xFF; $i++) {
30+
for ($i = 0; $i <= 0xFF; ++$i) {
3131
$from .= chr($i);
3232
$to .= ($i >= 0x20 && $i <= 0x7E) ? chr($i) : $pad;
3333
}
@@ -223,7 +223,7 @@ function createTemplatedSlide(PhpPresentation $objPHPPresentation): Slide
223223
return $slide;
224224
}
225225

226-
class PhpPptTree
226+
class Sample_Header
227227
{
228228
protected $oPhpPresentation;
229229

@@ -531,13 +531,13 @@ protected function getConstantName($class, $search, $startWith = '')
531531
</div>
532532
<div class="navbar-collapse collapse">
533533
<ul class="nav navbar-nav">
534-
<?php foreach ($files as $key => $fileStr) :?>
534+
<?php foreach ($files as $key => $fileStr) { ?>
535535
<li class="dropdown active">
536536
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-code fa-lg"></i>&nbsp;Samples <?php echo $key?>x<strong
537537
class="caret"></strong></a>
538538
<ul class="dropdown-menu"><?php echo $fileStr; ?></ul>
539539
</li>
540-
<?php endforeach; ?>
540+
<?php } ?>
541541
</ul>
542542
<ul class="nav navbar-nav navbar-right">
543543
<li><a href="https://github.com/PHPOffice/PHPPresentation"><i class="fa fa-github fa-lg" title="GitHub"></i>&nbsp;</a></li>
@@ -548,4 +548,4 @@ class="caret"></strong></a>
548548
</div>
549549
</div>
550550
</div>
551-
<?php echo $pageHeading;
551+
<?php echo $pageHeading;

src/PhpPresentation/Reader/AbstractReader.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is part of PHPPresentation - A pure PHP library for reading and writing
45
* presentations documents.
@@ -10,8 +11,8 @@
1011
* file that was distributed with this source code. For the full list of
1112
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
1213
*
13-
* @link https://github.com/PHPOffice/PHPPresentation
14-
* @copyright 2009-2015 PHPPresentation contributors
14+
* @see https://github.com/PHPOffice/PHPPresentation
15+
*
1516
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
1617
*/
1718

@@ -34,11 +35,13 @@ public function getPassword()
3435

3536
/**
3637
* @param string $password
38+
*
3739
* @return AbstractReader
3840
*/
3941
public function setPassword($password)
4042
{
4143
$this->password = $password;
44+
4245
return $this;
4346
}
44-
}
47+
}

src/PhpPresentation/Reader/ODPresentation.php

+16-16
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class ODPresentation extends AbstractReader implements ReaderInterface
8383
protected $oXMLReader;
8484

8585
/**
86-
* @var \PhpOffice\Common\XMLReader
86+
* @var XMLReader
8787
*/
8888
protected $oXMLMetaInfManifest;
8989

@@ -773,8 +773,8 @@ protected function loadStylesFile(): void
773773

774774
/**
775775
* @param string $filename
776+
*
776777
* @return bool
777-
* @throws \Exception
778778
*/
779779
protected function loadFileFromODP($filename)
780780
{
@@ -787,7 +787,7 @@ protected function loadFileFromODP($filename)
787787
}
788788
}
789789
// Search file in META-INF/manifest.xml
790-
$oElement = $this->oXMLMetaInfManifest->getElement('/manifest:manifest/manifest:file-entry[@manifest:full-path=\''.$filename.'\']');
790+
$oElement = $this->oXMLMetaInfManifest->getElement('/manifest:manifest/manifest:file-entry[@manifest:full-path=\'' . $filename . '\']');
791791
if (!$oElement) {
792792
return false;
793793
}
@@ -798,14 +798,15 @@ protected function loadFileFromODP($filename)
798798
}
799799

800800
$fileContent = $this->oZip->getFromName($filename);
801-
if (!$fileContent){
801+
if (!$fileContent) {
802802
return false;
803803
}
804804

805805
// No Encrypted file
806806
if (!$bEncrypted) {
807807
$this->oXMLReader = new XMLReader();
808808
$this->oXMLReader->getDomFromString($fileContent);
809+
809810
return true;
810811
}
811812

@@ -851,7 +852,7 @@ protected function loadFileFromODP($filename)
851852
var_dump($iv);
852853

853854
$pwdHash = hash('sha256', $this->getPassword());
854-
echo 'sha256('.$this->getPassword().'): ';
855+
echo 'sha256(' . $this->getPassword() . '): ';
855856
var_dump($pwdHash);
856857
//$pwdHash = substr($pwdHash, 0 , 32);
857858
//var_dump($pwdHash);
@@ -864,15 +865,15 @@ protected function loadFileFromODP($filename)
864865
//var_dump($key);
865866

866867
$data = openssl_decrypt($fileContent, 'AES-256-CBC', $key, 0, $iv);
867-
if(!$data) {
868-
while ($msg = openssl_error_string())
868+
if (!$data) {
869+
while ($msg = openssl_error_string()) {
869870
var_dump($msg);
871+
}
870872
die();
871-
} else {
872-
var_dump($data);
873-
$data = gzinflate($data);
874-
var_dump($data);
875873
}
874+
var_dump($data);
875+
$data = gzinflate($data);
876+
var_dump($data);
876877

877878
/*$data = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $fileContent, MCRYPT_MODE_CBC, $iv);
878879
var_dump($data);
@@ -884,18 +885,16 @@ protected function loadFileFromODP($filename)
884885
return false;
885886
}
886887

887-
protected function hash_pbkdf2($a = 'sha256', $password, $salt, $rounds = 5000, $key_length = 32, $raw_output = false)
888+
protected function hash_pbkdf2($a, $password, $salt, $rounds = 5000, $key_length = 32, $raw_output = false)
888889
{
889890
// Derived key
890891
$dk = '';
891892
// Create key
892-
for ($block=1; $block<=$key_length; $block++)
893-
{
893+
for ($block = 1; $block <= $key_length; ++$block) {
894894
// Initial hash for this block
895895
$ib = $h = hash_hmac($a, $salt . pack('N', $block), $password, true);
896896
// Perform block iterations
897-
for ($i=1; $i<$rounds; $i++)
898-
{
897+
for ($i = 1; $i < $rounds; ++$i) {
899898
// XOR each iteration
900899
$ib ^= ($h = hash_hmac($a, $h, $password, true));
901900
}
@@ -904,6 +903,7 @@ protected function hash_pbkdf2($a = 'sha256', $password, $salt, $rounds = 5000,
904903
}
905904
// Return derived key of correct length
906905
$key = substr($dk, 0, $key_length);
906+
907907
return $raw_output ? $key : base64_encode($key);
908908
}
909909

0 commit comments

Comments
 (0)