Changeset 60771 for trunk/src/wp-includes/SimplePie/src/Source.php
- Timestamp:
- 09/16/2025 10:45:37 PM (2 months ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/SimplePie/src/Source.php (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/SimplePie/src/Source.php
r59141 r60771 1 1 <?php 2 2 3 /** 4 * SimplePie 5 * 6 * A PHP-Based RSS and Atom Feed Framework. 7 * Takes the hard work out of managing a complete RSS/Atom solution. 8 * 9 * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 10 * All rights reserved. 11 * 12 * Redistribution and use in source and binary forms, with or without modification, are 13 * permitted provided that the following conditions are met: 14 * 15 * * Redistributions of source code must retain the above copyright notice, this list of 16 * conditions and the following disclaimer. 17 * 18 * * Redistributions in binary form must reproduce the above copyright notice, this list 19 * of conditions and the following disclaimer in the documentation and/or other materials 20 * provided with the distribution. 21 * 22 * * Neither the name of the SimplePie Team nor the names of its contributors may be used 23 * to endorse or promote products derived from this software without specific prior 24 * written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS 27 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 28 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS 29 * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 33 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 * POSSIBILITY OF SUCH DAMAGE. 35 * 36 * @package SimplePie 37 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 * @author Ryan Parman 39 * @author Sam Sneddon 40 * @author Ryan McCue 41 * @link http://simplepie.org/ SimplePie 42 * @license http://www.opensource.org/licenses/bsd-license.php BSD License 43 */ 3 // SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue 4 // SPDX-License-Identifier: BSD-3-Clause 5 6 declare(strict_types=1); 44 7 45 8 namespace SimplePie; … … 51 14 * 52 15 * This class can be overloaded with {@see \SimplePie::set_source_class()} 53 *54 * @package SimplePie55 * @subpackage API56 16 */ 57 17 class Source implements RegistryAware 58 18 { 19 /** @var Item */ 59 20 public $item; 21 /** @var array<string, mixed> */ 60 22 public $data = []; 23 /** @var Registry */ 61 24 protected $registry; 62 25 63 public function __construct($item, $data) 26 /** 27 * @param array<string, mixed> $data 28 */ 29 public function __construct(Item $item, array $data) 64 30 { 65 31 $this->item = $item; … … 67 33 } 68 34 69 public function set_registry(\SimplePie\Registry $registry)/* : void */ 35 /** 36 * @return void 37 */ 38 public function set_registry(\SimplePie\Registry $registry) 70 39 { 71 40 $this->registry = $registry; 72 41 } 73 42 43 /** 44 * @return string 45 */ 74 46 public function __toString() 75 47 { … … 77 49 } 78 50 79 public function get_source_tags($namespace, $tag) 51 /** 52 * @param string $namespace 53 * @param string $tag 54 * @return array<array<string, mixed>>|null 55 */ 56 public function get_source_tags(string $namespace, string $tag) 80 57 { 81 58 if (isset($this->data['child'][$namespace][$tag])) { … … 86 63 } 87 64 88 public function get_base($element = []) 65 /** 66 * @param array<string, mixed> $element 67 * @return string 68 */ 69 public function get_base(array $element = []) 89 70 { 90 71 return $this->item->get_base($element); 91 72 } 92 73 93 public function sanitize($data, $type, $base = '') 74 /** 75 * @param string $data 76 * @param int-mask-of<SimplePie::CONSTRUCT_*> $type 77 * @param string $base 78 * @return string 79 */ 80 public function sanitize(string $data, $type, string $base = '') 94 81 { 95 82 return $this->item->sanitize($data, $type, $base); 96 83 } 97 84 85 /** 86 * @return Item 87 */ 98 88 public function get_item() 99 89 { … … 101 91 } 102 92 93 /** 94 * @return string|null 95 */ 103 96 public function get_title() 104 97 { … … 122 115 } 123 116 124 public function get_category($key = 0) 117 /** 118 * @param int $key 119 * @return Category|null 120 */ 121 public function get_category(int $key = 0) 125 122 { 126 123 $categories = $this->get_categories(); … … 132 129 } 133 130 131 /** 132 * @return array<Category>|null 133 */ 134 134 public function get_categories() 135 135 { … … 176 176 } 177 177 178 public function get_author($key = 0) 178 /** 179 * @param int $key 180 * @return Author|null 181 */ 182 public function get_author(int $key = 0) 179 183 { 180 184 $authors = $this->get_authors(); … … 186 190 } 187 191 192 /** 193 * @return array<Author>|null 194 */ 188 195 public function get_authors() 189 196 { … … 197 204 } 198 205 if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'])) { 199 $uri = $this->sanitize($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0])); 206 $uri = $author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]; 207 $uri = $this->sanitize($uri['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($uri)); 200 208 } 201 209 if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'])) { … … 214 222 } 215 223 if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'])) { 216 $url = $this->sanitize($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0])); 224 $url = $author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]; 225 $url = $this->sanitize($url['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($url)); 217 226 } 218 227 if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'])) { … … 240 249 } 241 250 242 public function get_contributor($key = 0) 251 /** 252 * @param int $key 253 * @return Author|null 254 */ 255 public function get_contributor(int $key = 0) 243 256 { 244 257 $contributors = $this->get_contributors(); … … 250 263 } 251 264 265 /** 266 * @return array<Author>|null 267 */ 252 268 public function get_contributors() 253 269 { … … 261 277 } 262 278 if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'])) { 263 $uri = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0])); 279 $uri = $contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]; 280 $uri = $this->sanitize($uri['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($uri)); 264 281 } 265 282 if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'])) { … … 278 295 } 279 296 if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'])) { 280 $url = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0])); 297 $url = $contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]; 298 $url = $this->sanitize($url['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($url)); 281 299 } 282 300 if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'])) { … … 295 313 } 296 314 297 public function get_link($key = 0, $rel = 'alternate') 315 /** 316 * @param int $key 317 * @param string $rel 318 * @return string|null 319 */ 320 public function get_link(int $key = 0, string $rel = 'alternate') 298 321 { 299 322 $links = $this->get_links($rel); … … 307 330 /** 308 331 * Added for parity between the parent-level and the item/entry-level. 332 * 333 * @return string|null 309 334 */ 310 335 public function get_permalink() … … 313 338 } 314 339 315 public function get_links($rel = 'alternate') 340 /** 341 * @param string $rel 342 * @return array<string>|null 343 */ 344 public function get_links(string $rel = 'alternate') 316 345 { 317 346 if (!isset($this->data['links'])) { … … 345 374 $keys = array_keys($this->data['links']); 346 375 foreach ($keys as $key) { 376 $key = (string) $key; 377 347 378 if ($this->registry->call(Misc::class, 'is_isegment_nz_nc', [$key])) { 348 379 if (isset($this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key])) { … … 366 397 } 367 398 399 /** 400 * @return string|null 401 */ 368 402 public function get_description() 369 403 { … … 391 425 } 392 426 427 /** 428 * @return string|null 429 */ 393 430 public function get_copyright() 394 431 { … … 408 445 } 409 446 447 /** 448 * @return string|null 449 */ 410 450 public function get_language() 411 451 { … … 423 463 } 424 464 465 /** 466 * @return float|null 467 */ 425 468 public function get_latitude() 426 469 { … … 434 477 } 435 478 479 /** 480 * @return float|null 481 */ 436 482 public function get_longitude() 437 483 { … … 447 493 } 448 494 495 /** 496 * @return string|null 497 */ 449 498 public function get_image_url() 450 499 {
Note: See TracChangeset
for help on using the changeset viewer.