rectorphp / rector-phpoffice Goto Github PK
View Code? Open in Web Editor NEW[DISCONTUINED] Rector upgrades rules for PHP Office
Home Page: https://getrector.org
License: MIT License
[DISCONTUINED] Rector upgrades rules for PHP Office
Home Page: https://getrector.org
License: MIT License
Hi,
I'm new to rector. I'm trying to use it to convert some php-excel programs to phpspreadsheet.
The basic installation instructions don't work.
Here is what I did:
-created a new folder and install using the command : composer require rector/rector --dev (see image 1)
-created a rector.php file with the content copied from the install page (see image 2)
-created a src folder and put an excel report to be processed
-ran the command : vendor\bin\rector process src (see image 3)
I get this error : [ERROR] Class "Rector\Doctrine\Set\PHPOfficeSetList" not found
What did I missed ? This is on windows 10 with wamp server. See attached screen captures.
Thank you
.
Hello,
I am currently migrating my old phpexcel code the phpoffice/phpspreadsheet (better late than never ;-).
However, I encountered the following problem: rule ChangeConditionalReturnedCellRector is not applied where it should be.
Rector config file :
------------------ start rector.php -------------------------
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\PHPOffice\Rector\MethodCall\ChangeConditionalReturnedCellRector;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rule(ChangeConditionalReturnedCellRector::class);
};
------------------ end rector.php ---------------------------
Sample code :
------------------ start rector.testfile.php ------------------
<?php
$workbook = new PHPExcel();
$sheet = $workbook->getActiveSheet();
$sheet->setCellValue('A1', 'Hello rector!');
unset($workbook);
------------------ end rector.testfile.php --------------------
Command-line execution :
------------------ start command-line -------------------------
rector process rector.testfile.php --dry-run --debug
rector.testfile.php
[file] rector.testfile.php
[rule] Rector\PHPOffice\Rector\MethodCall\ChangeConditionalReturnedCellRector
[file] rector.testfile.php
[rule] Rector\PHPOffice\Rector\MethodCall\ChangeConditionalReturnedCellRector
[OK] Rector is done!
------------------ end command-line ----------------------------
I was expected line:
$sheet->setCellValue('A1', 'Hello rector!');
to be changed to:
$sheet->getCell('A1')->setValue('Hello rector!');
But nothing happened.
I investigated a little bit and found that the rule was not applied because rector did not find any node of type 'PHPExcel_Worksheet'.
Questions :
Am I doing something wrong (I have no prior experience with rector)?
Am I missing something important in my rector config file?
Any help would be greatly appreciated, thanks.
Subject | Details |
---|---|
Rector version | e.g. v0.11.5 (invoke vendor/bin/rector --version ) |
I run PHPOfficeSetList::PHPEXCEL_TO_PHPSPREADSHEET
set against my code. However Rector is changing completely unrelated files. It removed an argument from a method call inside a class that has nothing to do with phpexcel.
I can say that this class had a problem with typehint missmatch, i.e. property's @var
had another type in comparison with related constructor parameter type. This was probably a source of invalid removal. However Rector should never touch this class. It should focus only on PHPExcel symbols and only on methods from PHPExcel and not refactor anything else.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.