magento-engcom / import-export-improvements

Open Software License 3.0
31 stars 29 forks source link

Clean up Model/Import file (PHPStan) #121

Closed dmanners closed 5 years ago

dmanners commented 5 years ago

Preconditions (*)

  1. 2.3-develop
  2. phpstan installed and run against app/code/Magento/ImportExport

Steps to reproduce (*)

  1. run ./vendor/bin/phpstan analyse -l 0 app/code/Magento/ImportExport/

Expected result (*)

  1. No Errors

Actual result (*)

 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------
  Line   Model/Import.php
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------
  206    Access to an undefined property Magento\ImportExport\Model\Import::$_coreConfig.
  216    Access to an undefined property Magento\ImportExport\Model\Import::$importHistoryModel.
  217    Access to an undefined property Magento\ImportExport\Model\Import::$localeDate.
  418    Access to an undefined property Magento\ImportExport\Model\Import::$importHistoryModel.
  437    Access to an undefined property Magento\ImportExport\Model\Import::$importHistoryModel.
  439    Access to an undefined property Magento\ImportExport\Model\Import::$importHistoryModel.
  733    Access to an undefined property Magento\ImportExport\Model\Import::$localeDate.
  745    Access to an undefined property Magento\ImportExport\Model\Import::$importHistoryModel.
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------
thicolares commented 5 years ago

May I? :) I've just reproduced the errors. Can you assign it to me?

thicolares commented 5 years ago

After cleaning up the first error, I got:

  148    Property Magento\ImportExport\Model\Import::$_csvFactory has unknown class                    
         Magento\ImportExport\Model\Export\Adapter\CsvFactor as its type.                              
  158    Property Magento\ImportExport\Model\Import::$_uploaderFactory has unknown class               
         Magento\MediaStorage\Model\File\UploaderFactory as its type.                                  
  203    Parameter $csvFactory of method Magento\ImportExport\Model\Import::__construct() has invalid  
         typehint type Magento\ImportExport\Model\Export\Adapter\CsvFactory.                           
  203    Parameter $uploaderFactory of method Magento\ImportExport\Model\Import::__construct() has     
         invalid typehint type Magento\MediaStorage\Model\File\UploaderFactory.

I could not found the \Magento\MediaStorage\Model\File\UploaderFactory nor its history. Do you know about it?

denispapec commented 5 years ago

Hi @colares, \Magento\MediaStorage\Model\File\UploaderFactory is a factory class, created during Magento compilation from Uploader class. After cleaning up errors from initial comments, compiling Magento code, there shouldn't be any more phpstan errors from this file.

thicolares commented 5 years ago

Mm.. Thank you, @denispapec! In fact I suspected that I had forgotten some step, since I did not find the class in the repository. I will compile Magento this time. Btw, that's my first time ever I'm interacting with a Magento's code :)

dmanners commented 5 years ago

Hi @colares thanks for the question. Yes the factory classes during compilation sorry for not adding that information in original ticket.