@@ -61,9 +61,9 @@ private static function fromRss(SimpleXMLElement $xml): static
6161 // generate 'url' & 'timestamp' tags
6262 $ item ->url = (string ) $ item ->link ;
6363 if (isset ($ item ->{'dc:date ' })) {
64- $ item ->timestamp = strtotime ($ item ->{'dc:date ' });
64+ $ item ->timestamp = strtotime (( string ) $ item ->{'dc:date ' });
6565 } elseif (isset ($ item ->pubDate )) {
66- $ item ->timestamp = strtotime ($ item ->pubDate );
66+ $ item ->timestamp = strtotime (( string ) $ item ->pubDate );
6767 }
6868 }
6969 $ feed = new static ;
@@ -74,16 +74,17 @@ private static function fromRss(SimpleXMLElement $xml): static
7474
7575 private static function fromAtom (SimpleXMLElement $ xml ): static
7676 {
77- if (!in_array ('http://www.w3.org/2005/Atom ' , $ xml ->getDocNamespaces (), strict: true )
78- && !in_array ('http://purl.org/atom/ns# ' , $ xml ->getDocNamespaces (), strict: true )
77+ $ ns = $ xml ->getDocNamespaces () ?: [];
78+ if (!in_array ('http://www.w3.org/2005/Atom ' , $ ns , strict: true )
79+ && !in_array ('http://purl.org/atom/ns# ' , $ ns , strict: true )
7980 ) {
8081 throw new FeedException ('Invalid feed. ' );
8182 }
8283
8384 // generate 'url' & 'timestamp' tags
8485 foreach ($ xml ->entry as $ entry ) {
8586 $ entry ->url = (string ) $ entry ->link ['href ' ];
86- $ entry ->timestamp = strtotime ($ entry ->updated );
87+ $ entry ->timestamp = strtotime (( string ) $ entry ->updated );
8788 }
8889 $ feed = new static ;
8990 $ feed ->xml = $ xml ;
@@ -149,7 +150,7 @@ private static function loadXml(string $url, ?string $user, ?string $pass): Simp
149150 && $ data = @file_get_contents ($ cacheFile )
150151 ) {
151152 // ok
152- } elseif ($ data = trim ( self ::httpRequest ($ url , $ user , $ pass ))) {
153+ } elseif (( $ data = self ::httpRequest ($ url , $ user , $ pass )) !== false && $ data = trim ( $ data )) {
153154 if (self ::$ cacheDir ) {
154155 file_put_contents ($ cacheFile , $ data );
155156 }
@@ -183,7 +184,7 @@ private static function httpRequest(string $url, ?string $user, ?string $pass):
183184 curl_setopt ($ curl , CURLOPT_FOLLOWLOCATION , value: true ); // sometime is useful :)
184185 }
185186 $ result = curl_exec ($ curl );
186- return curl_errno ($ curl ) === 0 && curl_getinfo ($ curl , CURLINFO_HTTP_CODE ) === 200
187+ return curl_errno ($ curl ) === 0 && curl_getinfo ($ curl , CURLINFO_HTTP_CODE ) === 200 && is_string ( $ result )
187188 ? $ result
188189 : false ;
189190
0 commit comments