Removed custom autoloader.
This commit is contained in:
parent
95c097106f
commit
e6d73d8ff8
|
|
@ -26,7 +26,11 @@ Use the correspondent `getAlignment` and `setAlignment` methods instead. - @Roma
|
||||||
### Removed
|
### Removed
|
||||||
- `PhpOffice\PhpWord\Style\Alignment`. Style properties, which previously stored instances of this class, now deal with strings.
|
- `PhpOffice\PhpWord\Style\Alignment`. Style properties, which previously stored instances of this class, now deal with strings.
|
||||||
In each case set of available string values is defined by the correspondent simple type. - @RomanSyroeshko
|
In each case set of available string values is defined by the correspondent simple type. - @RomanSyroeshko
|
||||||
- Manual installation option. To install PHPWord use Composer since now. - @RomanSyroeshko
|
- Manual installation support. Since the release we have dependencies on third party libraries,
|
||||||
|
so installation via ZIP-archive download is not an option anymore. To install PHPWord use [Composer](https://getcomposer.org/).
|
||||||
|
We also removed `PhpOffice\PhpWord\Autoloader`, because the latter change made it completely useless.
|
||||||
|
Autoloaders provided by Composer are in use now (see `bootstrap.php`). - @RomanSyroeshko
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
0.12.1 (30 August 2015)
|
0.12.1 (30 August 2015)
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,6 @@ The following is a basic usage example of the PHPWord library.
|
||||||
```php
|
```php
|
||||||
<?php
|
<?php
|
||||||
require_once 'bootstrap.php';
|
require_once 'bootstrap.php';
|
||||||
\PhpOffice\PhpWord\Autoloader::register();
|
|
||||||
|
|
||||||
// Creating the new document...
|
// Creating the new document...
|
||||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ folder <https://github.com/PHPOffice/PHPWord/tree/master/samples/>`__.
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
require_once 'bootstrap.php';
|
require_once 'bootstrap.php';
|
||||||
\PhpOffice\PhpWord\Autoloader::register();
|
|
||||||
|
|
||||||
// Creating the new document...
|
// Creating the new document...
|
||||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . '/../bootstrap.php';
|
require_once __DIR__ . '/../bootstrap.php';
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Autoloader;
|
|
||||||
use PhpOffice\PhpWord\Settings;
|
use PhpOffice\PhpWord\Settings;
|
||||||
|
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
|
|
@ -11,7 +10,6 @@ define('EOL', CLI ? PHP_EOL : '<br />');
|
||||||
define('SCRIPT_FILENAME', basename($_SERVER['SCRIPT_FILENAME'], '.php'));
|
define('SCRIPT_FILENAME', basename($_SERVER['SCRIPT_FILENAME'], '.php'));
|
||||||
define('IS_INDEX', SCRIPT_FILENAME == 'index');
|
define('IS_INDEX', SCRIPT_FILENAME == 'index');
|
||||||
|
|
||||||
Autoloader::register();
|
|
||||||
Settings::loadConfig();
|
Settings::loadConfig();
|
||||||
|
|
||||||
// Set writers
|
// Set writers
|
||||||
|
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
|
||||||
* word processing documents.
|
|
||||||
*
|
|
||||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
|
||||||
* General Public License version 3 as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please read the LICENSE
|
|
||||||
* file that was distributed with this source code. For the full list of
|
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
|
||||||
*
|
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
|
||||||
* @copyright 2010-2014 PHPWord contributors
|
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord;
|
|
||||||
|
|
||||||
class Autoloader
|
|
||||||
{
|
|
||||||
/** @const string */
|
|
||||||
const NAMESPACE_PREFIX = 'PhpOffice\\PhpWord\\';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register
|
|
||||||
*
|
|
||||||
* @param bool $throw
|
|
||||||
* @param bool $prepend
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function register($throw = true, $prepend = false)
|
|
||||||
{
|
|
||||||
spl_autoload_register(array(new self, 'autoload'), $throw, $prepend);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Autoload
|
|
||||||
*
|
|
||||||
* @param string $class
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function autoload($class)
|
|
||||||
{
|
|
||||||
$prefixLength = strlen(self::NAMESPACE_PREFIX);
|
|
||||||
if (0 === strncmp(self::NAMESPACE_PREFIX, $class, $prefixLength)) {
|
|
||||||
$file = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, $prefixLength));
|
|
||||||
$file = realpath(__DIR__ . (empty($file) ? '' : DIRECTORY_SEPARATOR) . $file . '.php');
|
|
||||||
if (file_exists($file)) {
|
|
||||||
/** @noinspection PhpIncludeInspection Dynamic includes */
|
|
||||||
require_once $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
|
||||||
* word processing documents.
|
|
||||||
*
|
|
||||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
|
||||||
* General Public License version 3 as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please read the LICENSE
|
|
||||||
* file that was distributed with this source code. For the full list of
|
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
|
||||||
*
|
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
|
||||||
* @copyright 2010-2014 PHPWord contributors
|
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test class for PhpOffice\PhpWord\Autoloader
|
|
||||||
*
|
|
||||||
* @runTestsInSeparateProcesses
|
|
||||||
*/
|
|
||||||
class AutoloaderTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Register
|
|
||||||
*/
|
|
||||||
public function testRegister()
|
|
||||||
{
|
|
||||||
Autoloader::register();
|
|
||||||
$this->assertContains(
|
|
||||||
array('PhpOffice\\PhpWord\\Autoloader', 'autoload'),
|
|
||||||
spl_autoload_functions()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Autoload
|
|
||||||
*/
|
|
||||||
public function testAutoload()
|
|
||||||
{
|
|
||||||
$declaredCount = count(get_declared_classes());
|
|
||||||
Autoloader::autoload('Foo');
|
|
||||||
$this->assertCount(
|
|
||||||
$declaredCount,
|
|
||||||
get_declared_classes(),
|
|
||||||
'PhpOffice\\PhpWord\\Autoloader::autoload() is trying to load classes outside of the PhpOffice\\PhpWord namespace'
|
|
||||||
);
|
|
||||||
// TODO change this class to the main PhpWord class when it is namespaced
|
|
||||||
Autoloader::autoload('PhpOffice\\PhpWord\\Exception\\InvalidStyleException');
|
|
||||||
$this->assertTrue(
|
|
||||||
in_array('PhpOffice\\PhpWord\\Exception\\InvalidStyleException', get_declared_classes()),
|
|
||||||
'PhpOffice\\PhpWord\\Autoloader::autoload() failed to autoload the PhpOffice\\PhpWord\\Exception\\InvalidStyleException class'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -37,5 +37,3 @@ spl_autoload_register(function ($class) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
\PhpOffice\PhpWord\Autoloader::register();
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue