php-svg-lib icon indicating copy to clipboard operation
php-svg-lib copied to clipboard

Improvements of phpdocs and fix phpstan reported errors

Open williamdes opened this issue 5 months ago • 1 comments

Ref: #133

Left over:

./vendor/bin/phpstan analyse --level=3 src/
 29/29 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ ------------------------------------------------------------------------------------------- 
  Line   Svg/Style.php                                                                              
 ------ ------------------------------------------------------------------------------------------- 
  100    Argument of an invalid type Svg\Style supplied for foreach, only iterables are supported.  
         🪪  foreach.nonIterable                                                                    
 ------ ------------------------------------------------------------------------------------------- 

 ------ --------------------------------------------------------------------------------------------------- 
  Line   Svg/Surface/CPdf.php                                                                               
 ------ --------------------------------------------------------------------------------------------------- 
  609    Property Svg\Surface\CPdf::$catalogId (int) does not accept string.                                
         🪪  assign.propertyType                                                                            
  874    PHPDoc tag @throws with type FontLib\Exception\FontNotFoundException is not subtype of Throwable   
         🪪  throws.notThrowable                                                                            
  1056   PHPDoc tag @throws with type FontLib\Exception\FontNotFoundException is not subtype of Throwable   
         🪪  throws.notThrowable                                                                            
  1116   Variable $object in isset() is never defined.                                                      
         🪪  isset.variable                                                                                 
  1117   Undefined variable: $object                                                                        
         🪪  variable.undefined                                                                             
  1119   Undefined variable: $object                                                                        
         🪪  variable.undefined                                                                             
  1662   Property Svg\Surface\CPdf::$procsetObjectId (int) does not accept string.                          
         🪪  assign.propertyType                                                                            
  1702   Property Svg\Surface\CPdf::$infoObject (int) does not accept string.                               
         🪪  assign.propertyType                                                                            
  1923   Property Svg\Surface\CPdf::$currentPage (int) does not accept string.                              
         🪪  assign.propertyType                                                                            
  2082   Binary operation "+" between string and 1 results in an error.                                     
         🪪  binaryOp.invalid                                                                               
  2713   Property Svg\Surface\CPdf::$arc4_objnum (int) does not accept string.                              
         🪪  assign.propertyType                                                                            
  3429   Binary operation ">>" between non-empty-list<string>|non-falsy-string and 8 results in an error.   
         🪪  binaryOp.invalid                                                                               
  3430   Binary operation "&" between non-empty-list<string>|non-falsy-string and 255 results in an error.  
         🪪  binaryOp.invalid                                                                               
  3493   PHPDoc tag @throws with type FontLib\Exception\FontNotFoundException is not subtype of Throwable   
         🪪  throws.notThrowable                                                                            
  3651   Call to vsprintf contains 3 placeholders, 4 values given.                                          
         🪪  argument.vsprintf                                                                              
  3690   Call to vsprintf contains 3 placeholders, 4 values given.                                          
         🪪  argument.vsprintf                                                                              
  6091   Variable $errormsg might not be defined.                                                           
         🪪  variable.undefined                                                                             
  6106   Variable $idata might not be defined.                                                              
         🪪  variable.undefined                                                                             
  6108   Variable $pdata might not be defined.                                                              
         🪪  variable.undefined                                                                             
  6112   Variable $color might not be defined.                                                              
         🪪  variable.undefined                                                                             
  6113   Variable $ncolor might not be defined.                                                             
         🪪  variable.undefined                                                                             
 ------ --------------------------------------------------------------------------------------------------- 

 ------ ------------------------------------------------------- 
  Line   Svg/Surface/SurfaceCpdf.php                            
 ------ ------------------------------------------------------- 
  133    Call to an undefined method Svg\Surface\CPdf::clip().  
         🪪  method.notFound                                    
 ------ ------------------------------------------------------- 

 ------ ------------------------------------------------------------ 
  Line   Svg/Tag/AbstractTag.php                                     
 ------ ------------------------------------------------------------ 
  232    Variable $meetOrSlice on left side of ?? is never defined.  
         🪪  nullCoalesce.variable                                   
 ------ ------------------------------------------------------------ 

                                                                                                                        
 [ERROR] Found 24 errors                                                                                                

williamdes avatar Sep 18 '25 11:09 williamdes

I'll make a few minor changes once you have a chance to review my comments and make any necessary changes.

I noted a few issues I'd like to address separately from this PR since most of these changes are documentary in nature. Namely:

  1. Add the missing clip method to Cpdf
  2. Add the missing _convert_to_png method to SurfaceCpdf

bsweeney avatar Nov 16 '25 19:11 bsweeney