| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * Copyright (c) Andreas Heigl<[email protected] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * Licensed under the MIT License. See LICENSE.md file in the project root | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * for full license information. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | namespace Callingallpapers\Subcommands\Sessionize\Parser; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Callingallpapers\Entity\CfpList; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Callingallpapers\Parser\ParserInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Callingallpapers\Writer\WriterInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use DOMDocument; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use DOMElement; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use DOMXPath; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | class Sessionize implements ParserInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     private $parser; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     public function __construct(EntryParser $parser) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         $this->parser = $parser; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * @param WriterInterface $output | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      * @return CfpList | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 32 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 33 |  |  |     public function parse(WriterInterface $writer) | 
            
                                                        
            
                                    
            
            
                | 34 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 35 |  |  |         $uri = 'https://sessionize.com/sitemap/events.xml'; | 
            
                                                        
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 37 |  |  |         $cfpList = new CfpList(); | 
            
                                                        
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 39 |  |  |         $dom = new DOMDocument('1.0', 'UTF-8'); | 
            
                                                        
            
                                    
            
            
                | 40 |  |  |         $dom->load($uri); | 
            
                                                        
            
                                    
            
            
                | 41 |  |  |         $dom->preserveWhiteSpace = false; | 
            
                                                        
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 43 |  |  |         $xpath = new DOMXPath($dom); | 
            
                                                        
            
                                    
            
            
                | 44 |  |  |         $nodes = $xpath->query("//url"); | 
            
                                                        
            
                                    
            
            
                | 45 |  |  |         if ($nodes->length < 1) { | 
            
                                                        
            
                                    
            
            
                | 46 |  |  |             return $cfpList; | 
            
                                                        
            
                                    
            
            
                | 47 |  |  |         } | 
            
                                                        
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 49 |  |  |         /** @var DOMElement $node */ | 
            
                                                        
            
                                    
            
            
                | 50 |  |  |         foreach ($nodes as $node) { | 
            
                                                        
            
                                    
            
            
                | 51 |  |  |             $priority = $node->getElementsByTagName('priority'); | 
            
                                                        
            
                                    
            
            
                | 52 |  |  |             $priority = $priority->item(0); | 
            
                                                        
            
                                    
            
            
                | 53 |  |  |             if ((float)$priority->textContent <= 0.6) { | 
            
                                                        
            
                                    
            
            
                | 54 |  |  |                 continue; | 
            
                                                        
            
                                    
            
            
                | 55 |  |  |             } | 
            
                                                        
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 57 |  |  |             $loc = $node->getElementsByTagName('loc'); | 
            
                                                        
            
                                    
            
            
                | 58 |  |  |             $loc = $loc->item(0); | 
            
                                                        
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 60 |  |  |             if (! $loc->textContent) { | 
            
                                                        
            
                                    
            
            
                | 61 |  |  |                 continue; | 
            
                                                        
            
                                    
            
            
                | 62 |  |  |             } | 
            
                                                        
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 64 |  |  |             try { | 
            
                                                        
            
                                    
            
            
                | 65 |  |  |                 $cfpList->append($this->parser->parse($loc->textContent)); | 
            
                                                        
            
                                    
            
            
                | 66 |  |  |             } catch (\Exception $e) { | 
            
                                                        
            
                                    
            
            
                | 67 |  |  |                 error_log($e->getMEssage()); | 
            
                                                        
            
                                    
            
            
                | 68 |  |  |             } | 
            
                                                        
            
                                    
            
            
                | 69 |  |  |         } | 
            
                                                        
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 71 |  |  |         return $cfpList; | 
            
                                                        
            
                                    
            
            
                | 72 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 73 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 74 |  |  |  | 
            
                        
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.