| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace PhpOffice\PhpPresentation\Writer\PowerPoint2007; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use PhpOffice\PhpPresentation\Shape\Drawing; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use PhpOffice\PhpPresentation\Shape\MemoryDrawing; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | class PptMedia extends AbstractDecoratorWriter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |      * @return \PhpOffice\Common\Adapter\Zip\ZipInterface | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 12 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 13 | 92 |  |     public function render() | 
            
                                                        
            
                                    
            
            
                | 14 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 15 | 92 |  |         for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) { | 
            
                                                        
            
                                    
            
            
                | 16 | 31 |  |             $shape = $this->getDrawingHashTable()->getByIndex($i); | 
            
                                                        
            
                                    
            
            
                | 17 | 31 |  |             if ($shape instanceof Drawing || $shape instanceof Media) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 18 | 6 |  |                 $imagePath     = $shape->getPath(); | 
            
                                                        
            
                                    
            
            
                | 19 | 6 |  |                 if (strpos($imagePath, 'zip://') !== false) { | 
            
                                                        
            
                                    
            
            
                | 20 | 1 |  |                     $imagePath         = substr($imagePath, 6); | 
            
                                                        
            
                                    
            
            
                | 21 | 1 |  |                     $imagePathSplitted = explode('#', $imagePath); | 
            
                                                        
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 23 | 1 |  |                     $imageZip = new \ZipArchive(); | 
            
                                                        
            
                                    
            
            
                | 24 | 1 |  |                     $imageZip->open($imagePathSplitted[0]); | 
            
                                                        
            
                                    
            
            
                | 25 | 1 |  |                     $imageContents = $imageZip->getFromName($imagePathSplitted[1]); | 
            
                                                        
            
                                    
            
            
                | 26 | 1 |  |                     $imageZip->close(); | 
            
                                                        
            
                                    
            
            
                | 27 | 1 |  |                     unset($imageZip); | 
            
                                                        
            
                                    
            
            
                | 28 | 5 |  |                 } elseif (strpos($imagePath, 'data:image/') === 0) { | 
            
                                                        
            
                                    
            
            
                | 29 | 1 |  |                     list(, $imageContents) = explode(';', $imagePath); | 
            
                                                        
            
                                    
            
            
                | 30 | 1 |  |                     list(, $imageContents) = explode(',', $imageContents); | 
            
                                                        
            
                                    
            
            
                | 31 | 1 |  |                     $imageContents = base64_decode($imageContents); | 
            
                                                        
            
                                    
            
            
                | 32 |  |  |                 } else { | 
            
                                                        
            
                                    
            
            
                | 33 | 4 |  |                     $imageContents = file_get_contents($imagePath); | 
            
                                                        
            
                                    
            
            
                | 34 |  |  |                 } | 
            
                                                        
            
                                    
            
            
                | 35 | 6 |  |                 $this->getZip()->addFromString('ppt/media/' . str_replace(' ', '_', $shape->getIndexedFilename()), $imageContents); | 
            
                                                        
            
                                    
            
            
                | 36 |  |  |             } elseif ($shape instanceof MemoryDrawing) { | 
            
                                                        
            
                                    
            
            
                | 37 | 1 |  |                 ob_start(); | 
            
                                                        
            
                                    
            
            
                | 38 | 1 |  |                 call_user_func($shape->getRenderingFunction(), $shape->getImageResource()); | 
            
                                                        
            
                                    
            
            
                | 39 | 1 |  |                 $imageContents = ob_get_contents(); | 
            
                                                        
            
                                    
            
            
                | 40 | 1 |  |                 ob_end_clean(); | 
            
                                                        
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 42 | 1 |  |                 $this->getZip()->addFromString('ppt/media/' . str_replace(' ', '_', $shape->getIndexedFilename()), $imageContents); | 
            
                                                        
            
                                    
            
            
                | 43 |  |  |             } | 
            
                                                        
            
                                    
            
            
                | 44 |  |  |         } | 
            
                                                        
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 46 | 92 |  |         return $this->getZip(); | 
            
                                                        
            
                                    
            
            
                | 47 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 48 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 49 |  |  |  | 
            
                        
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.jsonfile (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.jsonto be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
requireorrequire-devsection?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceofchecks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.