Skip to content

Commit fff3630

Browse files
committed
Support migration of prefixed classes
1 parent fb5f8d4 commit fff3630

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

docs/topics/migration-from-PHPExcel.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ and are replaced by `IOFactory::registerWriter()` instead:
176176
- `PHPExcel_Settings::getPdfRenderer()`
177177
- `PHPExcel_Settings::setPdfRenderer()`
178178
- `PHPExcel_Settings::getPdfRendererName()`
179-
- `PHPExcel_Settings::setPdfRendererName()` were renamed as `setDefaultPdfWriter()`
179+
- `PHPExcel_Settings::setPdfRendererName()`
180180

181181
Before:
182182

src/PhpSpreadsheet/Cell/Cell.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,6 @@ public static function getValueBinder()
618618
* Set value binder to use.
619619
*
620620
* @param IValueBinder $binder
621-
*
622-
* @throws Exception
623621
*/
624622
public static function setValueBinder(IValueBinder $binder)
625623
{

src/PhpSpreadsheet/Helper/Migrator.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Migrator
1212
public function getMapping()
1313
{
1414
// Order matters here, we should have the deepest namespaces first (the most "unique" strings)
15-
$mapping = [
15+
$classes = [
1616
'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE\Blip::class,
1717
'PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer\SpContainer::class,
1818
'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE::class,
@@ -205,16 +205,38 @@ public function getMapping()
205205
'PHPExcel_Style' => \PhpOffice\PhpSpreadsheet\Style\Style::class,
206206
'PHPExcel_Worksheet' => \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::class,
207207
'PHPExcel' => \PhpOffice\PhpSpreadsheet\Spreadsheet::class,
208-
// methods
208+
];
209+
210+
$methods = [
209211
'MINUTEOFHOUR' => 'MINUTE',
210212
'SECONDOFMINUTE' => 'SECOND',
211213
'DAYOFWEEK' => 'WEEKDAY',
212214
'WEEKOFYEAR' => 'WEEKNUM',
213215
'ExcelToPHPObject' => 'excelToDateTimeObject',
214216
'ExcelToPHP' => 'excelToTimestamp',
215217
'FormattedPHPToExcel' => 'formattedPHPToExcel',
218+
'Cell::absoluteCoordinate' => 'Coordinate::absoluteCoordinate',
219+
'Cell::absoluteReference' => 'Coordinate::absoluteReference',
220+
'Cell::buildRange' => 'Coordinate::buildRange',
221+
'Cell::columnIndexFromString' => 'Coordinate::columnIndexFromString',
222+
'Cell::coordinateFromString' => 'Coordinate::coordinateFromString',
223+
'Cell::extractAllCellReferencesInRange' => 'Coordinate::extractAllCellReferencesInRange',
224+
'Cell::getRangeBoundaries' => 'Coordinate::getRangeBoundaries',
225+
'Cell::mergeRangesInCollection' => 'Coordinate::mergeRangesInCollection',
226+
'Cell::rangeBoundaries' => 'Coordinate::rangeBoundaries',
227+
'Cell::rangeDimension' => 'Coordinate::rangeDimension',
228+
'Cell::splitRange' => 'Coordinate::splitRange',
229+
'Cell::stringFromColumnIndex' => 'Coordinate::stringFromColumnIndex',
216230
];
217231

232+
// Keep '\' prefix for class names
233+
$prefixedClasses = [];
234+
foreach ($classes as $key => &$value) {
235+
$value = str_replace('PhpOffice\\', '\\PhpOffice\\', $value);
236+
$prefixedClasses['\\' . $key] = $value;
237+
}
238+
$mapping = $prefixedClasses + $classes + $methods;
239+
218240
return $mapping;
219241
}
220242

@@ -228,6 +250,7 @@ private function recursiveReplace($path)
228250
$patterns = [
229251
'/*.md',
230252
'/*.php',
253+
'/*.phtml',
231254
'/*.txt',
232255
'/*.TXT',
233256
];

0 commit comments

Comments
 (0)