| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /*************************************************************************** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * for license information see LICENSE.md | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  ***************************************************************************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | namespace Oc\GeoCache; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Eluceo\iCal\Component\Calendar; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Eluceo\iCal\Component\Event; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Endroid\QrCode\ErrorCorrectionLevel; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Endroid\QrCode\LabelAlignment; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Endroid\QrCode\QrCode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Oc\GeoCache\Persistence\GeoCache\GeoCacheEntity; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | class Util | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 17 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |     public function generateIcsStringFromGeoCache(GeoCacheEntity $geoCache): string | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |         if ($geoCache->type !== 6) { | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |             throw new \InvalidArgumentException('the given geoCache is not an event cache!'); | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |         $vCalendar = new Calendar('https://www.opencaching.de/' . $geoCache->wpOc); | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |         $vEvent = new Event(); | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |         $vEvent | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |             ->setDtStart($geoCache->dateHidden) | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |             ->setDtEnd($geoCache->dateHidden->add(new \DateInterval('PT1H'))) | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |             ->setNoTime(true) | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |             ->setSummary($geoCache->name) | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |             ->setDescription('https://www.opencaching.de/viewcache.php?cacheid=' . $geoCache->cacheId); | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |         $vCalendar->addComponent($vEvent); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |         return $vCalendar->render(); | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     public function generateQrCodeFromString(string $qrCodeValue): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         $qrCode = new QrCode($qrCodeValue); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         $qrCode->setSize(400); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         $qrCode->setWriterByName('png'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         $qrCode->setMargin(10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         $qrCode->setEncoding('UTF-8'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         $qrCode->setErrorCorrectionLevel(new ErrorCorrectionLevel(ErrorCorrectionLevel::HIGH)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         $qrCode->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $qrCode->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         $qrCode->setLabel('www.opencaching.de', 16, null, LabelAlignment::CENTER); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         $qrCode->setValidateResult(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         $logo = imagecreatefrompng(__DIR__ . '/../../../theme/frontend/images/logo/qr-code-oc-logo.png'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $qrCodeGenerated = imagecreatefromstring($qrCode->writeString()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         imagecopy( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |             $qrCodeGenerated, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             $logo, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             150, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |             150, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |             0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |             0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |             imagesx($logo), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |             imagesy($logo) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         imagepng($qrCodeGenerated); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         imagedestroy($qrCodeGenerated); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 70 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 71 |  |  |  | 
            
                        
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: