Support migration of prefixed classes

This commit is contained in:
Adrien Crivelli 2017-12-25 10:49:14 +09:00
parent fb5f8d4763
commit fff3630780
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
3 changed files with 26 additions and 5 deletions

View File

@ -176,7 +176,7 @@ and are replaced by `IOFactory::registerWriter()` instead:
- `PHPExcel_Settings::getPdfRenderer()` - `PHPExcel_Settings::getPdfRenderer()`
- `PHPExcel_Settings::setPdfRenderer()` - `PHPExcel_Settings::setPdfRenderer()`
- `PHPExcel_Settings::getPdfRendererName()` - `PHPExcel_Settings::getPdfRendererName()`
- `PHPExcel_Settings::setPdfRendererName()` were renamed as `setDefaultPdfWriter()` - `PHPExcel_Settings::setPdfRendererName()`
Before: Before:

View File

@ -618,8 +618,6 @@ class Cell
* Set value binder to use. * Set value binder to use.
* *
* @param IValueBinder $binder * @param IValueBinder $binder
*
* @throws Exception
*/ */
public static function setValueBinder(IValueBinder $binder) public static function setValueBinder(IValueBinder $binder)
{ {

View File

@ -12,7 +12,7 @@ class Migrator
public function getMapping() public function getMapping()
{ {
// Order matters here, we should have the deepest namespaces first (the most "unique" strings) // Order matters here, we should have the deepest namespaces first (the most "unique" strings)
$mapping = [ $classes = [
'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE\Blip::class, 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE\Blip::class,
'PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer\SpContainer::class, 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer\SpContainer::class,
'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE::class, 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE::class,
@ -205,7 +205,9 @@ class Migrator
'PHPExcel_Style' => \PhpOffice\PhpSpreadsheet\Style\Style::class, 'PHPExcel_Style' => \PhpOffice\PhpSpreadsheet\Style\Style::class,
'PHPExcel_Worksheet' => \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::class, 'PHPExcel_Worksheet' => \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::class,
'PHPExcel' => \PhpOffice\PhpSpreadsheet\Spreadsheet::class, 'PHPExcel' => \PhpOffice\PhpSpreadsheet\Spreadsheet::class,
// methods ];
$methods = [
'MINUTEOFHOUR' => 'MINUTE', 'MINUTEOFHOUR' => 'MINUTE',
'SECONDOFMINUTE' => 'SECOND', 'SECONDOFMINUTE' => 'SECOND',
'DAYOFWEEK' => 'WEEKDAY', 'DAYOFWEEK' => 'WEEKDAY',
@ -213,8 +215,28 @@ class Migrator
'ExcelToPHPObject' => 'excelToDateTimeObject', 'ExcelToPHPObject' => 'excelToDateTimeObject',
'ExcelToPHP' => 'excelToTimestamp', 'ExcelToPHP' => 'excelToTimestamp',
'FormattedPHPToExcel' => 'formattedPHPToExcel', 'FormattedPHPToExcel' => 'formattedPHPToExcel',
'Cell::absoluteCoordinate' => 'Coordinate::absoluteCoordinate',
'Cell::absoluteReference' => 'Coordinate::absoluteReference',
'Cell::buildRange' => 'Coordinate::buildRange',
'Cell::columnIndexFromString' => 'Coordinate::columnIndexFromString',
'Cell::coordinateFromString' => 'Coordinate::coordinateFromString',
'Cell::extractAllCellReferencesInRange' => 'Coordinate::extractAllCellReferencesInRange',
'Cell::getRangeBoundaries' => 'Coordinate::getRangeBoundaries',
'Cell::mergeRangesInCollection' => 'Coordinate::mergeRangesInCollection',
'Cell::rangeBoundaries' => 'Coordinate::rangeBoundaries',
'Cell::rangeDimension' => 'Coordinate::rangeDimension',
'Cell::splitRange' => 'Coordinate::splitRange',
'Cell::stringFromColumnIndex' => 'Coordinate::stringFromColumnIndex',
]; ];
// Keep '\' prefix for class names
$prefixedClasses = [];
foreach ($classes as $key => &$value) {
$value = str_replace('PhpOffice\\', '\\PhpOffice\\', $value);
$prefixedClasses['\\' . $key] = $value;
}
$mapping = $prefixedClasses + $classes + $methods;
return $mapping; return $mapping;
} }
@ -228,6 +250,7 @@ class Migrator
$patterns = [ $patterns = [
'/*.md', '/*.md',
'/*.php', '/*.php',
'/*.phtml',
'/*.txt', '/*.txt',
'/*.TXT', '/*.TXT',
]; ];