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::setPdfRenderer()`
- `PHPExcel_Settings::getPdfRendererName()`
- `PHPExcel_Settings::setPdfRendererName()` were renamed as `setDefaultPdfWriter()`
- `PHPExcel_Settings::setPdfRendererName()`
Before:

View File

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

View File

@ -12,7 +12,7 @@ class Migrator
public function getMapping()
{
// 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_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,
@ -205,7 +205,9 @@ class Migrator
'PHPExcel_Style' => \PhpOffice\PhpSpreadsheet\Style\Style::class,
'PHPExcel_Worksheet' => \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::class,
'PHPExcel' => \PhpOffice\PhpSpreadsheet\Spreadsheet::class,
// methods
];
$methods = [
'MINUTEOFHOUR' => 'MINUTE',
'SECONDOFMINUTE' => 'SECOND',
'DAYOFWEEK' => 'WEEKDAY',
@ -213,8 +215,28 @@ class Migrator
'ExcelToPHPObject' => 'excelToDateTimeObject',
'ExcelToPHP' => 'excelToTimestamp',
'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;
}
@ -228,6 +250,7 @@ class Migrator
$patterns = [
'/*.md',
'/*.php',
'/*.phtml',
'/*.txt',
'/*.TXT',
];