See Release Notes
Long Term Support Release
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Helper; 4 5 class Migrator 6 { 7 /** 8 * @var string[] 9 */ 10 private $from; 11 12 /** 13 * @var string[] 14 */ 15 private $to; 16 17 public function __construct() 18 { 19 $this->from = array_keys($this->getMapping()); 20 $this->to = array_values($this->getMapping()); 21 } 22 23 /** 24 * Return the ordered mapping from old PHPExcel class names to new PhpSpreadsheet one. 25 * 26 * @return string[] 27 */ 28 public function getMapping() 29 { 30 // Order matters here, we should have the deepest namespaces first (the most "unique" strings) 31 $classes = [ 32 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE\Blip::class, 33 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer\SpContainer::class, 34 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE::class, 35 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer::class, 36 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer::class, 37 'PHPExcel_Shared_OLE_PPS_File' => \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS\File::class, 38 'PHPExcel_Shared_OLE_PPS_Root' => \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS\Root::class, 39 'PHPExcel_Worksheet_AutoFilter_Column_Rule' => \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::class, 40 'PHPExcel_Writer_OpenDocument_Cell_Comment' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Cell\Comment::class, 41 'PHPExcel_Calculation_Token_Stack' => \PhpOffice\PhpSpreadsheet\Calculation\Token\Stack::class, 42 'PHPExcel_Chart_Renderer_jpgraph' => \PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph::class, 43 'PHPExcel_Reader_Excel5_Escher' => \PhpOffice\PhpSpreadsheet\Reader\Xls\Escher::class, 44 'PHPExcel_Reader_Excel5_MD5' => \PhpOffice\PhpSpreadsheet\Reader\Xls\MD5::class, 45 'PHPExcel_Reader_Excel5_RC4' => \PhpOffice\PhpSpreadsheet\Reader\Xls\RC4::class, 46 'PHPExcel_Reader_Excel2007_Chart' => \PhpOffice\PhpSpreadsheet\Reader\Xlsx\Chart::class, 47 'PHPExcel_Reader_Excel2007_Theme' => \PhpOffice\PhpSpreadsheet\Reader\Xlsx\Theme::class, 48 'PHPExcel_Shared_Escher_DgContainer' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer::class, 49 'PHPExcel_Shared_Escher_DggContainer' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer::class, 50 'CholeskyDecomposition' => \PhpOffice\PhpSpreadsheet\Shared\JAMA\CholeskyDecomposition::class, 51 'EigenvalueDecomposition' => \PhpOffice\PhpSpreadsheet\Shared\JAMA\EigenvalueDecomposition::class, 52 'PHPExcel_Shared_JAMA_LUDecomposition' => \PhpOffice\PhpSpreadsheet\Shared\JAMA\LUDecomposition::class, 53 'PHPExcel_Shared_JAMA_Matrix' => \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix::class, 54 'QRDecomposition' => \PhpOffice\PhpSpreadsheet\Shared\JAMA\QRDecomposition::class, 55 'PHPExcel_Shared_JAMA_QRDecomposition' => \PhpOffice\PhpSpreadsheet\Shared\JAMA\QRDecomposition::class, 56 'SingularValueDecomposition' => \PhpOffice\PhpSpreadsheet\Shared\JAMA\SingularValueDecomposition::class, 57 'PHPExcel_Shared_OLE_ChainedBlockStream' => \PhpOffice\PhpSpreadsheet\Shared\OLE\ChainedBlockStream::class, 58 'PHPExcel_Shared_OLE_PPS' => \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS::class, 59 'PHPExcel_Best_Fit' => \PhpOffice\PhpSpreadsheet\Shared\Trend\BestFit::class, 60 'PHPExcel_Exponential_Best_Fit' => \PhpOffice\PhpSpreadsheet\Shared\Trend\ExponentialBestFit::class, 61 'PHPExcel_Linear_Best_Fit' => \PhpOffice\PhpSpreadsheet\Shared\Trend\LinearBestFit::class, 62 'PHPExcel_Logarithmic_Best_Fit' => \PhpOffice\PhpSpreadsheet\Shared\Trend\LogarithmicBestFit::class, 63 'polynomialBestFit' => \PhpOffice\PhpSpreadsheet\Shared\Trend\PolynomialBestFit::class, 64 'PHPExcel_Polynomial_Best_Fit' => \PhpOffice\PhpSpreadsheet\Shared\Trend\PolynomialBestFit::class, 65 'powerBestFit' => \PhpOffice\PhpSpreadsheet\Shared\Trend\PowerBestFit::class, 66 'PHPExcel_Power_Best_Fit' => \PhpOffice\PhpSpreadsheet\Shared\Trend\PowerBestFit::class, 67 'trendClass' => \PhpOffice\PhpSpreadsheet\Shared\Trend\Trend::class, 68 'PHPExcel_Worksheet_AutoFilter_Column' => \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::class, 69 'PHPExcel_Worksheet_Drawing_Shadow' => \PhpOffice\PhpSpreadsheet\Worksheet\Drawing\Shadow::class, 70 'PHPExcel_Writer_OpenDocument_Content' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Content::class, 71 'PHPExcel_Writer_OpenDocument_Meta' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Meta::class, 72 'PHPExcel_Writer_OpenDocument_MetaInf' => \PhpOffice\PhpSpreadsheet\Writer\Ods\MetaInf::class, 73 'PHPExcel_Writer_OpenDocument_Mimetype' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Mimetype::class, 74 'PHPExcel_Writer_OpenDocument_Settings' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Settings::class, 75 'PHPExcel_Writer_OpenDocument_Styles' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Styles::class, 76 'PHPExcel_Writer_OpenDocument_Thumbnails' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Thumbnails::class, 77 'PHPExcel_Writer_OpenDocument_WriterPart' => \PhpOffice\PhpSpreadsheet\Writer\Ods\WriterPart::class, 78 'PHPExcel_Writer_PDF_Core' => \PhpOffice\PhpSpreadsheet\Writer\Pdf::class, 79 'PHPExcel_Writer_PDF_DomPDF' => \PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf::class, 80 'PHPExcel_Writer_PDF_mPDF' => \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf::class, 81 'PHPExcel_Writer_PDF_tcPDF' => \PhpOffice\PhpSpreadsheet\Writer\Pdf\Tcpdf::class, 82 'PHPExcel_Writer_Excel5_BIFFwriter' => \PhpOffice\PhpSpreadsheet\Writer\Xls\BIFFwriter::class, 83 'PHPExcel_Writer_Excel5_Escher' => \PhpOffice\PhpSpreadsheet\Writer\Xls\Escher::class, 84 'PHPExcel_Writer_Excel5_Font' => \PhpOffice\PhpSpreadsheet\Writer\Xls\Font::class, 85 'PHPExcel_Writer_Excel5_Parser' => \PhpOffice\PhpSpreadsheet\Writer\Xls\Parser::class, 86 'PHPExcel_Writer_Excel5_Workbook' => \PhpOffice\PhpSpreadsheet\Writer\Xls\Workbook::class, 87 'PHPExcel_Writer_Excel5_Worksheet' => \PhpOffice\PhpSpreadsheet\Writer\Xls\Worksheet::class, 88 'PHPExcel_Writer_Excel5_Xf' => \PhpOffice\PhpSpreadsheet\Writer\Xls\Xf::class, 89 'PHPExcel_Writer_Excel2007_Chart' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Chart::class, 90 'PHPExcel_Writer_Excel2007_Comments' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Comments::class, 91 'PHPExcel_Writer_Excel2007_ContentTypes' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\ContentTypes::class, 92 'PHPExcel_Writer_Excel2007_DocProps' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\DocProps::class, 93 'PHPExcel_Writer_Excel2007_Drawing' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Drawing::class, 94 'PHPExcel_Writer_Excel2007_Rels' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Rels::class, 95 'PHPExcel_Writer_Excel2007_RelsRibbon' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\RelsRibbon::class, 96 'PHPExcel_Writer_Excel2007_RelsVBA' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\RelsVBA::class, 97 'PHPExcel_Writer_Excel2007_StringTable' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\StringTable::class, 98 'PHPExcel_Writer_Excel2007_Style' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Style::class, 99 'PHPExcel_Writer_Excel2007_Theme' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Theme::class, 100 'PHPExcel_Writer_Excel2007_Workbook' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Workbook::class, 101 'PHPExcel_Writer_Excel2007_Worksheet' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet::class, 102 'PHPExcel_Writer_Excel2007_WriterPart' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\WriterPart::class, 103 'PHPExcel_CachedObjectStorage_CacheBase' => \PhpOffice\PhpSpreadsheet\Collection\Cells::class, 104 'PHPExcel_CalcEngine_CyclicReferenceStack' => \PhpOffice\PhpSpreadsheet\Calculation\Engine\CyclicReferenceStack::class, 105 'PHPExcel_CalcEngine_Logger' => \PhpOffice\PhpSpreadsheet\Calculation\Engine\Logger::class, 106 'PHPExcel_Calculation_Functions' => \PhpOffice\PhpSpreadsheet\Calculation\Functions::class, 107 'PHPExcel_Calculation_Function' => \PhpOffice\PhpSpreadsheet\Calculation\Category::class, 108 'PHPExcel_Calculation_Database' => \PhpOffice\PhpSpreadsheet\Calculation\Database::class, 109 'PHPExcel_Calculation_DateTime' => \PhpOffice\PhpSpreadsheet\Calculation\DateTime::class, 110 'PHPExcel_Calculation_Engineering' => \PhpOffice\PhpSpreadsheet\Calculation\Engineering::class, 111 'PHPExcel_Calculation_Exception' => \PhpOffice\PhpSpreadsheet\Calculation\Exception::class, 112 'PHPExcel_Calculation_ExceptionHandler' => \PhpOffice\PhpSpreadsheet\Calculation\ExceptionHandler::class, 113 'PHPExcel_Calculation_Financial' => \PhpOffice\PhpSpreadsheet\Calculation\Financial::class, 114 'PHPExcel_Calculation_FormulaParser' => \PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::class, 115 'PHPExcel_Calculation_FormulaToken' => \PhpOffice\PhpSpreadsheet\Calculation\FormulaToken::class, 116 'PHPExcel_Calculation_Logical' => \PhpOffice\PhpSpreadsheet\Calculation\Logical::class, 117 'PHPExcel_Calculation_LookupRef' => \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::class, 118 'PHPExcel_Calculation_MathTrig' => \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::class, 119 'PHPExcel_Calculation_Statistical' => \PhpOffice\PhpSpreadsheet\Calculation\Statistical::class, 120 'PHPExcel_Calculation_TextData' => \PhpOffice\PhpSpreadsheet\Calculation\TextData::class, 121 'PHPExcel_Cell_AdvancedValueBinder' => \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder::class, 122 'PHPExcel_Cell_DataType' => \PhpOffice\PhpSpreadsheet\Cell\DataType::class, 123 'PHPExcel_Cell_DataValidation' => \PhpOffice\PhpSpreadsheet\Cell\DataValidation::class, 124 'PHPExcel_Cell_DefaultValueBinder' => \PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder::class, 125 'PHPExcel_Cell_Hyperlink' => \PhpOffice\PhpSpreadsheet\Cell\Hyperlink::class, 126 'PHPExcel_Cell_IValueBinder' => \PhpOffice\PhpSpreadsheet\Cell\IValueBinder::class, 127 'PHPExcel_Chart_Axis' => \PhpOffice\PhpSpreadsheet\Chart\Axis::class, 128 'PHPExcel_Chart_DataSeries' => \PhpOffice\PhpSpreadsheet\Chart\DataSeries::class, 129 'PHPExcel_Chart_DataSeriesValues' => \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::class, 130 'PHPExcel_Chart_Exception' => \PhpOffice\PhpSpreadsheet\Chart\Exception::class, 131 'PHPExcel_Chart_GridLines' => \PhpOffice\PhpSpreadsheet\Chart\GridLines::class, 132 'PHPExcel_Chart_Layout' => \PhpOffice\PhpSpreadsheet\Chart\Layout::class, 133 'PHPExcel_Chart_Legend' => \PhpOffice\PhpSpreadsheet\Chart\Legend::class, 134 'PHPExcel_Chart_PlotArea' => \PhpOffice\PhpSpreadsheet\Chart\PlotArea::class, 135 'PHPExcel_Properties' => \PhpOffice\PhpSpreadsheet\Chart\Properties::class, 136 'PHPExcel_Chart_Title' => \PhpOffice\PhpSpreadsheet\Chart\Title::class, 137 'PHPExcel_DocumentProperties' => \PhpOffice\PhpSpreadsheet\Document\Properties::class, 138 'PHPExcel_DocumentSecurity' => \PhpOffice\PhpSpreadsheet\Document\Security::class, 139 'PHPExcel_Helper_HTML' => \PhpOffice\PhpSpreadsheet\Helper\Html::class, 140 'PHPExcel_Reader_Abstract' => \PhpOffice\PhpSpreadsheet\Reader\BaseReader::class, 141 'PHPExcel_Reader_CSV' => \PhpOffice\PhpSpreadsheet\Reader\Csv::class, 142 'PHPExcel_Reader_DefaultReadFilter' => \PhpOffice\PhpSpreadsheet\Reader\DefaultReadFilter::class, 143 'PHPExcel_Reader_Excel2003XML' => \PhpOffice\PhpSpreadsheet\Reader\Xml::class, 144 'PHPExcel_Reader_Exception' => \PhpOffice\PhpSpreadsheet\Reader\Exception::class, 145 'PHPExcel_Reader_Gnumeric' => \PhpOffice\PhpSpreadsheet\Reader\Gnumeric::class, 146 'PHPExcel_Reader_HTML' => \PhpOffice\PhpSpreadsheet\Reader\Html::class, 147 'PHPExcel_Reader_IReadFilter' => \PhpOffice\PhpSpreadsheet\Reader\IReadFilter::class, 148 'PHPExcel_Reader_IReader' => \PhpOffice\PhpSpreadsheet\Reader\IReader::class, 149 'PHPExcel_Reader_OOCalc' => \PhpOffice\PhpSpreadsheet\Reader\Ods::class, 150 'PHPExcel_Reader_SYLK' => \PhpOffice\PhpSpreadsheet\Reader\Slk::class, 151 'PHPExcel_Reader_Excel5' => \PhpOffice\PhpSpreadsheet\Reader\Xls::class, 152 'PHPExcel_Reader_Excel2007' => \PhpOffice\PhpSpreadsheet\Reader\Xlsx::class, 153 'PHPExcel_RichText_ITextElement' => \PhpOffice\PhpSpreadsheet\RichText\ITextElement::class, 154 'PHPExcel_RichText_Run' => \PhpOffice\PhpSpreadsheet\RichText\Run::class, 155 'PHPExcel_RichText_TextElement' => \PhpOffice\PhpSpreadsheet\RichText\TextElement::class, 156 'PHPExcel_Shared_CodePage' => \PhpOffice\PhpSpreadsheet\Shared\CodePage::class, 157 'PHPExcel_Shared_Date' => \PhpOffice\PhpSpreadsheet\Shared\Date::class, 158 'PHPExcel_Shared_Drawing' => \PhpOffice\PhpSpreadsheet\Shared\Drawing::class, 159 'PHPExcel_Shared_Escher' => \PhpOffice\PhpSpreadsheet\Shared\Escher::class, 160 'PHPExcel_Shared_File' => \PhpOffice\PhpSpreadsheet\Shared\File::class, 161 'PHPExcel_Shared_Font' => \PhpOffice\PhpSpreadsheet\Shared\Font::class, 162 'PHPExcel_Shared_OLE' => \PhpOffice\PhpSpreadsheet\Shared\OLE::class, 163 'PHPExcel_Shared_OLERead' => \PhpOffice\PhpSpreadsheet\Shared\OLERead::class, 164 'PHPExcel_Shared_PasswordHasher' => \PhpOffice\PhpSpreadsheet\Shared\PasswordHasher::class, 165 'PHPExcel_Shared_String' => \PhpOffice\PhpSpreadsheet\Shared\StringHelper::class, 166 'PHPExcel_Shared_TimeZone' => \PhpOffice\PhpSpreadsheet\Shared\TimeZone::class, 167 'PHPExcel_Shared_XMLWriter' => \PhpOffice\PhpSpreadsheet\Shared\XMLWriter::class, 168 'PHPExcel_Shared_Excel5' => \PhpOffice\PhpSpreadsheet\Shared\Xls::class, 169 'PHPExcel_Style_Alignment' => \PhpOffice\PhpSpreadsheet\Style\Alignment::class, 170 'PHPExcel_Style_Border' => \PhpOffice\PhpSpreadsheet\Style\Border::class, 171 'PHPExcel_Style_Borders' => \PhpOffice\PhpSpreadsheet\Style\Borders::class, 172 'PHPExcel_Style_Color' => \PhpOffice\PhpSpreadsheet\Style\Color::class, 173 'PHPExcel_Style_Conditional' => \PhpOffice\PhpSpreadsheet\Style\Conditional::class, 174 'PHPExcel_Style_Fill' => \PhpOffice\PhpSpreadsheet\Style\Fill::class, 175 'PHPExcel_Style_Font' => \PhpOffice\PhpSpreadsheet\Style\Font::class, 176 'PHPExcel_Style_NumberFormat' => \PhpOffice\PhpSpreadsheet\Style\NumberFormat::class, 177 'PHPExcel_Style_Protection' => \PhpOffice\PhpSpreadsheet\Style\Protection::class, 178 'PHPExcel_Style_Supervisor' => \PhpOffice\PhpSpreadsheet\Style\Supervisor::class, 179 'PHPExcel_Worksheet_AutoFilter' => \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter::class, 180 'PHPExcel_Worksheet_BaseDrawing' => \PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::class, 181 'PHPExcel_Worksheet_CellIterator' => \PhpOffice\PhpSpreadsheet\Worksheet\CellIterator::class, 182 'PHPExcel_Worksheet_Column' => \PhpOffice\PhpSpreadsheet\Worksheet\Column::class, 183 'PHPExcel_Worksheet_ColumnCellIterator' => \PhpOffice\PhpSpreadsheet\Worksheet\ColumnCellIterator::class, 184 'PHPExcel_Worksheet_ColumnDimension' => \PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension::class, 185 'PHPExcel_Worksheet_ColumnIterator' => \PhpOffice\PhpSpreadsheet\Worksheet\ColumnIterator::class, 186 'PHPExcel_Worksheet_Drawing' => \PhpOffice\PhpSpreadsheet\Worksheet\Drawing::class, 187 'PHPExcel_Worksheet_HeaderFooter' => \PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooter::class, 188 'PHPExcel_Worksheet_HeaderFooterDrawing' => \PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing::class, 189 'PHPExcel_WorksheetIterator' => \PhpOffice\PhpSpreadsheet\Worksheet\Iterator::class, 190 'PHPExcel_Worksheet_MemoryDrawing' => \PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::class, 191 'PHPExcel_Worksheet_PageMargins' => \PhpOffice\PhpSpreadsheet\Worksheet\PageMargins::class, 192 'PHPExcel_Worksheet_PageSetup' => \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::class, 193 'PHPExcel_Worksheet_Protection' => \PhpOffice\PhpSpreadsheet\Worksheet\Protection::class, 194 'PHPExcel_Worksheet_Row' => \PhpOffice\PhpSpreadsheet\Worksheet\Row::class, 195 'PHPExcel_Worksheet_RowCellIterator' => \PhpOffice\PhpSpreadsheet\Worksheet\RowCellIterator::class, 196 'PHPExcel_Worksheet_RowDimension' => \PhpOffice\PhpSpreadsheet\Worksheet\RowDimension::class, 197 'PHPExcel_Worksheet_RowIterator' => \PhpOffice\PhpSpreadsheet\Worksheet\RowIterator::class, 198 'PHPExcel_Worksheet_SheetView' => \PhpOffice\PhpSpreadsheet\Worksheet\SheetView::class, 199 'PHPExcel_Writer_Abstract' => \PhpOffice\PhpSpreadsheet\Writer\BaseWriter::class, 200 'PHPExcel_Writer_CSV' => \PhpOffice\PhpSpreadsheet\Writer\Csv::class, 201 'PHPExcel_Writer_Exception' => \PhpOffice\PhpSpreadsheet\Writer\Exception::class, 202 'PHPExcel_Writer_HTML' => \PhpOffice\PhpSpreadsheet\Writer\Html::class, 203 'PHPExcel_Writer_IWriter' => \PhpOffice\PhpSpreadsheet\Writer\IWriter::class, 204 'PHPExcel_Writer_OpenDocument' => \PhpOffice\PhpSpreadsheet\Writer\Ods::class, 205 'PHPExcel_Writer_PDF' => \PhpOffice\PhpSpreadsheet\Writer\Pdf::class, 206 'PHPExcel_Writer_Excel5' => \PhpOffice\PhpSpreadsheet\Writer\Xls::class, 207 'PHPExcel_Writer_Excel2007' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx::class, 208 'PHPExcel_CachedObjectStorageFactory' => \PhpOffice\PhpSpreadsheet\Collection\CellsFactory::class, 209 'PHPExcel_Calculation' => \PhpOffice\PhpSpreadsheet\Calculation\Calculation::class, 210 'PHPExcel_Cell' => \PhpOffice\PhpSpreadsheet\Cell\Cell::class, 211 'PHPExcel_Chart' => \PhpOffice\PhpSpreadsheet\Chart\Chart::class, 212 'PHPExcel_Comment' => \PhpOffice\PhpSpreadsheet\Comment::class, 213 'PHPExcel_Exception' => \PhpOffice\PhpSpreadsheet\Exception::class, 214 'PHPExcel_HashTable' => \PhpOffice\PhpSpreadsheet\HashTable::class, 215 'PHPExcel_IComparable' => \PhpOffice\PhpSpreadsheet\IComparable::class, 216 'PHPExcel_IOFactory' => \PhpOffice\PhpSpreadsheet\IOFactory::class, 217 'PHPExcel_NamedRange' => \PhpOffice\PhpSpreadsheet\NamedRange::class, 218 'PHPExcel_ReferenceHelper' => \PhpOffice\PhpSpreadsheet\ReferenceHelper::class, 219 'PHPExcel_RichText' => \PhpOffice\PhpSpreadsheet\RichText\RichText::class, 220 'PHPExcel_Settings' => \PhpOffice\PhpSpreadsheet\Settings::class, 221 'PHPExcel_Style' => \PhpOffice\PhpSpreadsheet\Style\Style::class, 222 'PHPExcel_Worksheet' => \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::class, 223 ]; 224 225 $methods = [ 226 'MINUTEOFHOUR' => 'MINUTE', 227 'SECONDOFMINUTE' => 'SECOND', 228 'DAYOFWEEK' => 'WEEKDAY', 229 'WEEKOFYEAR' => 'WEEKNUM', 230 'ExcelToPHPObject' => 'excelToDateTimeObject', 231 'ExcelToPHP' => 'excelToTimestamp', 232 'FormattedPHPToExcel' => 'formattedPHPToExcel', 233 'Cell::absoluteCoordinate' => 'Coordinate::absoluteCoordinate', 234 'Cell::absoluteReference' => 'Coordinate::absoluteReference', 235 'Cell::buildRange' => 'Coordinate::buildRange', 236 'Cell::columnIndexFromString' => 'Coordinate::columnIndexFromString', 237 'Cell::coordinateFromString' => 'Coordinate::coordinateFromString', 238 'Cell::extractAllCellReferencesInRange' => 'Coordinate::extractAllCellReferencesInRange', 239 'Cell::getRangeBoundaries' => 'Coordinate::getRangeBoundaries', 240 'Cell::mergeRangesInCollection' => 'Coordinate::mergeRangesInCollection', 241 'Cell::rangeBoundaries' => 'Coordinate::rangeBoundaries', 242 'Cell::rangeDimension' => 'Coordinate::rangeDimension', 243 'Cell::splitRange' => 'Coordinate::splitRange', 244 'Cell::stringFromColumnIndex' => 'Coordinate::stringFromColumnIndex', 245 ]; 246 247 // Keep '\' prefix for class names 248 $prefixedClasses = []; 249 foreach ($classes as $key => &$value) { 250 $value = str_replace('PhpOffice\\', '\\PhpOffice\\', $value); 251 $prefixedClasses['\\' . $key] = $value; 252 } 253 $mapping = $prefixedClasses + $classes + $methods; 254 255 return $mapping; 256 } 257 258 /** 259 * Search in all files in given directory. 260 * 261 * @param string $path 262 */ 263 private function recursiveReplace($path) 264 { 265 $patterns = [ 266 '/*.md', 267 '/*.txt', 268 '/*.TXT', 269 '/*.php', 270 '/*.phpt', 271 '/*.php3', 272 '/*.php4', 273 '/*.php5', 274 '/*.phtml', 275 ]; 276 277 foreach ($patterns as $pattern) { 278 foreach (glob($path . $pattern) as $file) { 279 if (strpos($path, '/vendor/') !== false) { 280 echo $file . " skipped\n"; 281 282 continue; 283 } 284 $original = file_get_contents($file); 285 $converted = $this->replace($original); 286 287 if ($original !== $converted) { 288 echo $file . " converted\n"; 289 file_put_contents($file, $converted); 290 } 291 } 292 } 293 294 // Do the recursion in subdirectory 295 foreach (glob($path . '/*', GLOB_ONLYDIR) as $subpath) { 296 if (strpos($subpath, $path . '/') === 0) { 297 $this->recursiveReplace($subpath); 298 } 299 } 300 } 301 302 public function migrate() 303 { 304 $path = realpath(getcwd()); 305 echo 'This will search and replace recursively in ' . $path . PHP_EOL; 306 echo 'You MUST backup your files first, or you risk losing data.' . PHP_EOL; 307 echo 'Are you sure ? (y/n)'; 308 309 $confirm = fread(STDIN, 1); 310 if ($confirm === 'y') { 311 $this->recursiveReplace($path); 312 } 313 } 314 315 /** 316 * Migrate the given code from PHPExcel to PhpSpreadsheet. 317 * 318 * @param string $original 319 * 320 * @return string 321 */ 322 public function replace($original) 323 { 324 $converted = str_replace($this->from, $this->to, $original); 325 326 // The string "PHPExcel" gets special treatment because of how common it might be. 327 // This regex requires a word boundary around the string, and it can't be 328 // preceded by $ or -> (goal is to filter out cases where a variable is named $PHPExcel or similar) 329 $converted = preg_replace('~(?<!\$|->)(\b|\\\\)PHPExcel\b~', '\\' . \PhpOffice\PhpSpreadsheet\Spreadsheet::class, $converted); 330 331 return $converted; 332 } 333 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body