Skip to content

Commit 048436c

Browse files
committed
Use INI instead of YML
1 parent f380c29 commit 048436c

File tree

10 files changed

+33
-1224
lines changed

10 files changed

+33
-1224
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Thumbs.db
66
Desktop.ini
77
composer.phar
88
phpunit.xml
9-
phpword.yml
9+
phpword.ini
1010
/.buildpath
1111
/.idea
1212
/.project

.scrutinizer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
filter:
2-
excluded_paths: [ 'vendor/*', 'tests/*', 'samples/*', 'src/PhpWord/Shared/PCLZip/*', 'src/PhpWord/Shared/Spyc/*' ]
2+
excluded_paths: [ 'vendor/*', 'tests/*', 'samples/*', 'src/PhpWord/Shared/PCLZip/*' ]
33

44
before_commands:
55
- "composer install --prefer-source --dev"

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ before_script:
4444

4545
script:
4646
## PHP_CodeSniffer
47-
- ./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip --ignore=src/PhpWord/Shared/Spyc
47+
- ./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip
4848
## PHP Copy/Paste Detector
4949
- php phpcpd.phar src/ tests/ --verbose
5050
## PHP Mess Detector
51-
- phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php,Spyc.php
51+
- phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php
5252
## PHPLOC
5353
#- php phploc.phar src/
5454
## PHPUnit

phpword.ini.dist

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
; Default config file for PHPWord
2+
; Copy this file into phpword.ini and use Settings::loadConfig to load
3+
4+
[General]
5+
6+
compatibility = true
7+
zipClass = ZipArchive
8+
pdfRendererName = DomPDF
9+
pdfRendererPath =
10+
11+
[Font]
12+
13+
defaultFontName = Arial
14+
defaultFontSize = 10

phpword.yml.dist

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

src/PhpWord/Settings.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,14 @@ public static function hasCompatibility()
132132
* This sets the setIndent and setIndentString for better compatibility
133133
*
134134
* @param bool $compatibility
135-
* @return bool
135+
* @return true
136136
*/
137137
public static function setCompatibility($compatibility)
138138
{
139-
if (is_bool($compatibility)) {
140-
self::$xmlWriterCompatibility = $compatibility;
141-
return true;
142-
}
139+
$compatibility = (bool)$compatibility;
140+
self::$xmlWriterCompatibility = $compatibility;
143141

144-
return false;
142+
return true;
145143
}
146144

147145
/**
@@ -328,20 +326,25 @@ public static function loadConfig($filename = null)
328326
// Get config file
329327
$configFile = null;
330328
$configPath = __DIR__ . '/../../';
331-
$files = array($filename, "{$configPath}phpword.yml", "{$configPath}phpword.yml.dist");
329+
if ($filename !== null) {
330+
$files = array($filename);
331+
} else {
332+
$files = array("{$configPath}phpword.ini", "{$configPath}phpword.ini.dist");
333+
}
332334
foreach ($files as $file) {
333335
if (file_exists($file)) {
334336
$configFile = realpath($file);
335337
break;
336338
}
337339
}
338340

339-
// Use Spyc to load config file
341+
// Parse config file
340342
$config = array();
341-
$spycLibrary = realpath(__DIR__ . '/Shared/Spyc/Spyc.php');
342-
if (file_exists($spycLibrary) && $configFile !== null) {
343-
require_once $spycLibrary;
344-
$config = spyc_load_file($configFile);
343+
if ($configFile !== null) {
344+
$config = parse_ini_file($configFile);
345+
if ($config === false) {
346+
return $config;
347+
}
345348
}
346349

347350
// Set config value

src/PhpWord/Shared/Spyc/COPYING

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

src/PhpWord/Shared/Spyc/README.md

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

0 commit comments

Comments
 (0)