Changeset 60771
- Timestamp:
- 09/16/2025 10:45:37 PM (2 months ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 7 added
- 1 deleted
- 77 edited
-
SimplePie/autoloader.php (modified) (2 diffs)
-
SimplePie/library/SimplePie.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Author.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Cache.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Cache/Base.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Cache/DB.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Cache/File.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Cache/Memcache.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Cache/Memcached.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Cache/MySQL.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Cache/Redis.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Caption.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Category.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Content/Type/Sniffer.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Copyright.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Core.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Credit.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Decode/HTML/Entities.php (modified) (10 diffs)
-
SimplePie/library/SimplePie/Enclosure.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Exception.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/File.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/HTTP/Parser.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/IRI.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Item.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Locator.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Misc.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Net/IPv6.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Parse/Date.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Parser.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Rating.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Registry.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Restriction.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Sanitize.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/Source.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/XML/Declaration/Parser.php (modified) (2 diffs)
-
SimplePie/library/SimplePie/gzdecode.php (modified) (2 diffs)
-
SimplePie/src/Author.php (modified) (6 diffs)
-
SimplePie/src/Cache.php (modified) (7 diffs)
-
SimplePie/src/Cache/Base.php (modified) (4 diffs)
-
SimplePie/src/Cache/BaseDataCache.php (modified) (3 diffs)
-
SimplePie/src/Cache/CallableNameFilter.php (modified) (3 diffs)
-
SimplePie/src/Cache/DB.php (modified) (2 diffs)
-
SimplePie/src/Cache/DataCache.php (modified) (3 diffs)
-
SimplePie/src/Cache/File.php (modified) (6 diffs)
-
SimplePie/src/Cache/Memcache.php (modified) (8 diffs)
-
SimplePie/src/Cache/Memcached.php (modified) (7 diffs)
-
SimplePie/src/Cache/MySQL.php (modified) (10 diffs)
-
SimplePie/src/Cache/NameFilter.php (modified) (3 diffs)
-
SimplePie/src/Cache/Psr16.php (modified) (6 diffs)
-
SimplePie/src/Cache/Redis.php (modified) (8 diffs)
-
SimplePie/src/Caption.php (modified) (8 diffs)
-
SimplePie/src/Category.php (modified) (4 diffs)
-
SimplePie/src/Content/Type/Sniffer.php (modified) (10 diffs)
-
SimplePie/src/Copyright.php (modified) (5 diffs)
-
SimplePie/src/Credit.php (modified) (6 diffs)
-
SimplePie/src/Decode (deleted)
-
SimplePie/src/Enclosure.php (modified) (57 diffs)
-
SimplePie/src/Exception.php (modified) (2 diffs)
-
SimplePie/src/File.php (modified) (9 diffs)
-
SimplePie/src/Gzdecode.php (modified) (9 diffs)
-
SimplePie/src/HTTP/Client.php (added)
-
SimplePie/src/HTTP/ClientException.php (added)
-
SimplePie/src/HTTP/FileClient.php (added)
-
SimplePie/src/HTTP/Parser.php (modified) (24 diffs)
-
SimplePie/src/HTTP/Psr18Client.php (added)
-
SimplePie/src/HTTP/Psr7Response.php (added)
-
SimplePie/src/HTTP/RawTextResponse.php (added)
-
SimplePie/src/HTTP/Response.php (added)
-
SimplePie/src/IRI.php (modified) (37 diffs)
-
SimplePie/src/Item.php (modified) (55 diffs)
-
SimplePie/src/Locator.php (modified) (17 diffs)
-
SimplePie/src/Misc.php (modified) (42 diffs)
-
SimplePie/src/Net/IPv6.php (modified) (12 diffs)
-
SimplePie/src/Parse/Date.php (modified) (25 diffs)
-
SimplePie/src/Parser.php (modified) (26 diffs)
-
SimplePie/src/Rating.php (modified) (5 diffs)
-
SimplePie/src/Registry.php (modified) (11 diffs)
-
SimplePie/src/RegistryAware.php (modified) (3 diffs)
-
SimplePie/src/Restriction.php (modified) (6 diffs)
-
SimplePie/src/Sanitize.php (modified) (39 diffs)
-
SimplePie/src/SimplePie.php (modified) (137 diffs)
-
SimplePie/src/Source.php (modified) (26 diffs)
-
SimplePie/src/XML/Declaration/Parser.php (modified) (17 diffs)
-
class-wp-simplepie-file.php (modified) (1 diff)
-
feed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/SimplePie/autoloader.php
r59141 r60771 1 1 <?php 2 /**3 * SimplePie4 *5 * A PHP-Based RSS and Atom Feed Framework.6 * Takes the hard work out of managing a complete RSS/Atom solution.7 *8 * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors9 * All rights reserved.10 *11 * Redistribution and use in source and binary forms, with or without modification, are12 * permitted provided that the following conditions are met:13 *14 * * Redistributions of source code must retain the above copyright notice, this list of15 * conditions and the following disclaimer.16 *17 * * Redistributions in binary form must reproduce the above copyright notice, this list18 * of conditions and the following disclaimer in the documentation and/or other materials19 * provided with the distribution.20 *21 * * Neither the name of the SimplePie Team nor the names of its contributors may be used22 * to endorse or promote products derived from this software without specific prior23 * written permission.24 *25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS26 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY27 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS28 * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR32 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE33 * POSSIBILITY OF SUCH DAMAGE.34 *35 * @package SimplePie36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue37 * @author Ryan Parman38 * @author Sam Sneddon39 * @author Ryan McCue40 * @link http://simplepie.org/ SimplePie41 * @license http://www.opensource.org/licenses/bsd-license.php BSD License42 */43 2 3 // SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue 4 // SPDX-License-Identifier: BSD-3-Clause 44 5 45 6 /** … … 94 55 /** 95 56 * Autoloader class 96 *97 * @package SimplePie98 * @subpackage API99 57 */ 100 58 class SimplePie_Autoloader -
trunk/src/wp-includes/SimplePie/library/SimplePie.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-2017, 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 * @version 1.7.0 38 * @copyright 2004-2017 Ryan Parman, Sam Sneddon, Ryan McCue 39 * @author Ryan Parman 40 * @author Sam Sneddon 41 * @author Ryan McCue 42 * @link http://simplepie.org/ SimplePie 43 * @license http://www.opensource.org/licenses/bsd-license.php BSD License 44 */ 3 // SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue 4 // SPDX-License-Identifier: BSD-3-Clause 5 6 declare(strict_types=1); 45 7 46 8 use SimplePie\SimplePie as NamespacedSimplePie; … … 50 12 // @trigger_error(sprintf('Using the "SimplePie" class is deprecated since SimplePie 1.7.0, use "SimplePie\SimplePie" instead.'), \E_USER_DEPRECATED); 51 13 14 /** @phpstan-ignore-next-line */ 52 15 if (\false) { 53 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\SimplePie" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Author.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 use SimplePie\Author; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Author" class is deprecated since SimplePie 1.7.0, use "SimplePie\Author" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Author" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Cache.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 use SimplePie\Cache; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Cache" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Cache/Base.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 use SimplePie\Cache\Base; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Cache_Base" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Base" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Base" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Cache/DB.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 use SimplePie\Cache\DB; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Cache_DB" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\DB" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\DB" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Cache/File.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 use SimplePie\Cache\File; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Cache_File" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\File" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\File" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Cache/Memcache.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 use SimplePie\Cache\Memcache; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Cache_Memcache" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Memcache" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Memcache" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Cache/Memcached.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 use SimplePie\Cache\Memcached; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Cache_Memcached" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Memcached" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Memcached" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Cache/MySQL.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 use SimplePie\Cache\MySQL; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Cache_MySQL" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\MySQL" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\MySQL" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Cache/Redis.php
r59141 r60771 1 1 <?php 2 2 3 /** 4 * SimplePie Redis Cache Extension 5 * 6 * @package SimplePie 7 * @author Jan Kozak <galvani78@gmail.com> 8 * @link http://galvani.cz/ 9 * @license http://www.opensource.org/licenses/bsd-license.php BSD License 10 * @version 0.2.9 11 */ 3 // SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue 4 // SPDX-License-Identifier: BSD-3-Clause 5 6 declare(strict_types=1); 12 7 13 8 use SimplePie\Cache\Redis; … … 17 12 // @trigger_error(sprintf('Using the "SimplePie_Cache_Redis" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Redis" instead.'), \E_USER_DEPRECATED); 18 13 14 /** @phpstan-ignore-next-line */ 19 15 if (\false) { 20 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Redis" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Caption.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 use SimplePie\Caption; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Caption" class is deprecated since SimplePie 1.7.0, use "SimplePie\Caption" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Caption" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Category.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 use SimplePie\Category; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Category" class is deprecated since SimplePie 1.7.0, use "SimplePie\Category" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Category" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Content/Type/Sniffer.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 use SimplePie\Content\Type\Sniffer; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Content_Type_Sniffer" class is deprecated since SimplePie 1.7.0, use "SimplePie\Content\Type\Sniffer" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Content\Type\Sniffer" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Copyright.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 use SimplePie\Copyright; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Copyright" class is deprecated since SimplePie 1.7.0, use "SimplePie\Copyright" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Copyright" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Core.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 /** … … 49 12 * 50 13 * @deprecated Use {@see SimplePie} directly 51 * @package SimplePie52 * @subpackage API53 14 */ 54 15 class SimplePie_Core extends SimplePie -
trunk/src/wp-includes/SimplePie/library/SimplePie/Credit.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 use SimplePie\Credit; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Credit" class is deprecated since SimplePie 1.7.0, use "SimplePie\Credit" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Credit" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Decode/HTML/Entities.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 … … 50 13 * 51 14 * @deprecated Use DOMDocument instead! 52 * @package SimplePie53 15 */ 54 16 class SimplePie_Decode_HTML_Entities … … 84 46 * @param string $data Input data 85 47 */ 86 public function __construct( $data)48 public function __construct(string $data) 87 49 { 88 50 $this->data = $data; … … 97 59 public function parse() 98 60 { 99 while (($this->position = strpos($this->data, '&', $this->position)) !== false) { 61 while (($position = strpos($this->data, '&', $this->position)) !== false) { 62 $this->position = $position; 100 63 $this->consume(); 101 64 $this->entity(); … … 109 72 * 110 73 * @access private 111 * @return mixedThe next byte, or false, if there is no more data74 * @return string|false The next byte, or false, if there is no more data 112 75 */ 113 76 public function consume() … … 126 89 * @access private 127 90 * @param string $chars Characters to consume 128 * @return mixedA series of characters that match the range, or false129 */ 130 public function consume_range( $chars)91 * @return string|false A series of characters that match the range, or false 92 */ 93 public function consume_range(string $chars) 131 94 { 132 95 if ($len = strspn($this->data, $chars, $this->position)) { … … 144 107 * 145 108 * @access private 109 * @return void 146 110 */ 147 111 public function unconsume() … … 155 119 * 156 120 * @access private 121 * @return void 157 122 */ 158 123 public function entity() … … 188 153 189 154 if ($hex) { 190 $codepoint = hexdec($codepoint); 155 // Cap to PHP_INT_MAX to ensure consistent behaviour if $codepoint is so large 156 // it cannot fit into int – just casting float to int might return junk (e.g. a negative number). 157 // If it is so large, `Misc::codepoint_to_utf8` will just return a replacement character. 158 $codepoint = (int) min(hexdec($codepoint), \PHP_INT_MAX); 191 159 } else { 192 $codepoint = intval($codepoint); 160 // Casting string to int caps at PHP_INT_MAX automatically. 161 $codepoint = (int) $codepoint; 193 162 } 194 163 … … 580 549 581 550 for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++) { 582 $consumed = substr($this->consumed, 1); 551 // Cast for PHPStan on PHP < 8.0: We consumed as per the loop condition, 552 // so `$this->consumed` is non-empty and the substr offset is valid. 553 $consumed = (string) substr($this->consumed, 1); 583 554 if (isset($entities[$consumed])) { 584 555 $match = $consumed; -
trunk/src/wp-includes/SimplePie/library/SimplePie/Enclosure.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 use SimplePie\Enclosure; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Enclosure" class is deprecated since SimplePie 1.7.0, use "SimplePie\Enclosure" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Enclosure" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Exception.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 use SimplePie\Exception as SimplePieException; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Exception" class is deprecated since SimplePie 1.7.0, use "SimplePie\Exception" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Exception" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/File.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 use SimplePie\File; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_File" class is deprecated since SimplePie 1.7.0, use "SimplePie\File" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\File" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/HTTP/Parser.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 use SimplePie\HTTP\Parser; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_HTTP_Parser" class is deprecated since SimplePie 1.7.0, use "SimplePie\HTTP\Parser" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 /** @deprecated since SimplePie 1.7.0, use "SimplePie\HTTP\Parser" instead */ 16 /** 17 * @deprecated since SimplePie 1.7.0, use "SimplePie\HTTP\Parser" instead 18 * @template Psr7Compatible of bool 19 * @extends Parser<Psr7Compatible> 20 */ 53 21 class SimplePie_HTTP_Parser extends Parser 54 22 { -
trunk/src/wp-includes/SimplePie/library/SimplePie/IRI.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 use SimplePie\IRI; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_IRI" class is deprecated since SimplePie 1.7.0, use "SimplePie\IRI" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\IRI" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Item.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 use SimplePie\Item; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Item" class is deprecated since SimplePie 1.7.0, use "SimplePie\Item" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Item" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Locator.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 use SimplePie\Locator; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Locator" class is deprecated since SimplePie 1.7.0, use "SimplePie\Locator" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Locator" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Misc.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 use SimplePie\Misc; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Misc" class is deprecated since SimplePie 1.7.0, use "SimplePie\Misc" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Misc" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Net/IPv6.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 use SimplePie\Net\IPv6; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Net_IPv6" class is deprecated since SimplePie 1.7.0, use "SimplePie\Net\IPv6" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Net\IPv6" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Parse/Date.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 use SimplePie\Parse\Date; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Parse_Date" class is deprecated since SimplePie 1.7.0, use "SimplePie\Parse\Date" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Parse\Date" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Parser.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 use SimplePie\Parser; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Parser" class is deprecated since SimplePie 1.7.0, use "SimplePie\Parser" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Parser" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Rating.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 use SimplePie\Rating; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Rating" class is deprecated since SimplePie 1.7.0, use "SimplePie\Rating" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Rating" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Registry.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 use SimplePie\Registry; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Registry" class is deprecated since SimplePie 1.7.0, use "SimplePie\Registry" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Registry" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Restriction.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 use SimplePie\Restriction; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Restriction" class is deprecated since SimplePie 1.7.0, use "SimplePie\Restriction" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Restriction" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/Sanitize.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 use SimplePie\Sanitize; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Sanitize" class is deprecated since SimplePie 1.7.0, use "SimplePie\Sanitize" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Sanitize" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/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 use SimplePie\Source; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_Source" class is deprecated since SimplePie 1.7.0, use "SimplePie\Source" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Source" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/XML/Declaration/Parser.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 use SimplePie\XML\Declaration\Parser; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_XML_Declaration_Parser" class is deprecated since SimplePie 1.7.0, use "SimplePie\XML\Declaration\Parser" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\XML\Declaration\Parser" instead */ -
trunk/src/wp-includes/SimplePie/library/SimplePie/gzdecode.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 use SimplePie\Gzdecode; … … 49 12 // @trigger_error(sprintf('Using the "SimplePie_gzdecode" class is deprecated since SimplePie 1.7.0, use "SimplePie\Gzdecode" instead.'), \E_USER_DEPRECATED); 50 13 14 /** @phpstan-ignore-next-line */ 51 15 if (\false) { 52 16 /** @deprecated since SimplePie 1.7.0, use "SimplePie\Gzdecode" instead */ -
trunk/src/wp-includes/SimplePie/src/Author.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_author_class()} 53 *54 * @package SimplePie55 * @subpackage API56 16 */ 57 17 class Author … … 60 20 * Author's name 61 21 * 62 * @var string22 * @var ?string 63 23 * @see get_name() 64 24 */ … … 68 28 * Author's link 69 29 * 70 * @var string30 * @var ?string 71 31 * @see get_link() 72 32 */ … … 76 36 * Author's email address 77 37 * 78 * @var string38 * @var ?string 79 39 * @see get_email() 80 40 */ … … 83 43 /** 84 44 * Constructor, used to input the data 85 *86 * @param string $name87 * @param string $link88 * @param string $email89 45 */ 90 public function __construct($name = null, $link = null, $email = null) 91 { 46 public function __construct( 47 ?string $name = null, 48 ?string $link = null, 49 ?string $email = null 50 ) { 92 51 $this->name = $name; 93 52 $this->link = $link; -
trunk/src/wp-includes/SimplePie/src/Cache.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; … … 54 17 * via {@see register()} 55 18 * 56 * @package SimplePie57 * @subpackage Caching58 19 * @deprecated since SimplePie 1.8.0, use "SimplePie\SimplePie::set_cache()" instead 59 20 */ … … 65 26 * These receive 3 parameters to their constructor, as documented in 66 27 * {@see register()} 67 * @var array 28 * @var array<string, class-string<Base>> 68 29 */ 69 30 protected static $handlers = [ 70 'mysql' => 'SimplePie\Cache\MySQL',71 'memcache' => 'SimplePie\Cache\Memcache',72 'memcached' => 'SimplePie\Cache\Memcached',73 'redis' => 'SimplePie\Cache\Redis'31 'mysql' => Cache\MySQL::class, 32 'memcache' => Cache\Memcache::class, 33 'memcached' => Cache\Memcached::class, 34 'redis' => Cache\Redis::class, 74 35 ]; 75 36 … … 89 50 * @return Base Type of object depends on scheme of `$location` 90 51 */ 91 public static function get_handler( $location,$filename, $extension)52 public static function get_handler(string $location, string $filename, $extension) 92 53 { 93 54 $type = explode(':', $location, 2); … … 105 66 * 106 67 * @deprecated since SimplePie 1.3.1, use {@see get_handler()} instead 68 * @param string $location 69 * @param string $filename 70 * @param Base::TYPE_FEED|Base::TYPE_IMAGE $extension 71 * @return Base 107 72 */ 108 public function create( $location,$filename, $extension)73 public function create(string $location, string $filename, $extension) 109 74 { 110 75 trigger_error('Cache::create() has been replaced with Cache::get_handler() since SimplePie 1.3.1, use the registry system instead.', \E_USER_DEPRECATED); … … 118 83 * @param string $type DSN type to register for 119 84 * @param class-string<Base> $class Name of handler class. Must implement Base 85 * @return void 120 86 */ 121 public static function register( $type, $class)87 public static function register(string $type, $class) 122 88 { 123 89 self::$handlers[$type] = $class; … … 128 94 * 129 95 * @param string $url 130 * @return array 96 * @return array<string, mixed> 131 97 */ 132 public static function parse_URL( $url)98 public static function parse_URL(string $url) 133 99 { 134 $params = parse_url($url); 135 $params['extras'] = []; 100 $parsedUrl = parse_url($url); 101 102 if ($parsedUrl === false) { 103 return []; 104 } 105 106 $params = array_merge($parsedUrl, ['extras' => []]); 136 107 if (isset($params['query'])) { 137 108 parse_str($params['query'], $params['extras']); -
trunk/src/wp-includes/SimplePie/src/Cache/Base.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\Cache; … … 51 14 * to implement this interface. 52 15 * 53 * @package SimplePie54 * @subpackage Caching55 16 * @deprecated since SimplePie 1.8.0, use "Psr\SimpleCache\CacheInterface" instead 56 17 */ … … 78 39 * @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data 79 40 */ 80 public function __construct( $location,$name, $type);41 public function __construct(string $location, string $name, $type); 81 42 82 43 /** 83 44 * Save data to the cache 84 45 * 85 * @param array |\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property46 * @param array<mixed>|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property 86 47 * @return bool Successfulness 87 48 */ … … 91 52 * Retrieve the data saved to the cache 92 53 * 93 * @return array Data for SimplePie::$data54 * @return array<mixed> Data for SimplePie::$data 94 55 */ 95 56 public function load(); -
trunk/src/wp-includes/SimplePie/src/Cache/BaseDataCache.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-2022 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\Cache; … … 50 13 * Adapter for deprecated \SimplePie\Cache\Base implementations 51 14 * 52 * @package SimplePie53 * @subpackage Caching54 15 * @internal 55 16 */ … … 115 76 * 116 77 * @param string $key The key of the item to store. 117 * @param array $value The value of the item to store, must be serializable.78 * @param array<mixed> $value The value of the item to store, must be serializable. 118 79 * @param null|int $ttl Optional. The TTL value of this item. If no value is sent and 119 80 * the driver supports TTL then the library may set a default value -
trunk/src/wp-includes/SimplePie/src/Cache/CallableNameFilter.php
r59141 r60771 1 1 <?php 2 /** 3 * SimplePie 4 * 5 * A PHP-Based RSS and Atom Feed Framework. 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 * 8 * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without modification, are 12 * permitted provided that the following conditions are met: 13 * 14 * * Redistributions of source code must retain the above copyright notice, this list of 15 * conditions and the following disclaimer. 16 * 17 * * Redistributions in binary form must reproduce the above copyright notice, this list 18 * of conditions and the following disclaimer in the documentation and/or other materials 19 * provided with the distribution. 20 * 21 * * Neither the name of the SimplePie Team nor the names of its contributors may be used 22 * to endorse or promote products derived from this software without specific prior 23 * written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS 26 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 27 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS 28 * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 32 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 * POSSIBILITY OF SUCH DAMAGE. 34 * 35 * @package SimplePie 36 * @copyright 2004-2022 Ryan Parman, Sam Sneddon, Ryan McCue 37 * @author Ryan Parman 38 * @author Sam Sneddon 39 * @author Ryan McCue 40 * @link http://simplepie.org/ SimplePie 41 * @license http://www.opensource.org/licenses/bsd-license.php BSD License 42 */ 2 3 // SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue 4 // SPDX-License-Identifier: BSD-3-Clause 5 6 declare(strict_types=1); 43 7 44 8 namespace SimplePie\Cache; … … 46 10 /** 47 11 * Creating a cache filename with callables 48 *49 * @package SimplePie50 * @subpackage Caching51 12 */ 52 13 final class CallableNameFilter implements NameFilter 53 14 { 54 15 /** 55 * @var callable 16 * @var callable(string): string 56 17 */ 57 18 private $callable; 58 19 20 /** 21 * @param callable(string): string $callable 22 */ 59 23 public function __construct(callable $callable) 60 24 { … … 79 43 * minimum. 80 44 * 81 * @param string $name The name for the cache will be most lik ly an url with query string45 * @param string $name The name for the cache will be most likely an url with query string 82 46 * 83 47 * @return string the new cache name -
trunk/src/wp-includes/SimplePie/src/Cache/DB.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\Cache; 9 10 use SimplePie\Item; 46 11 47 12 /** 48 13 * Base class for database-based caches 49 14 * 50 * @package SimplePie51 * @subpackage Caching52 15 * @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead 53 16 */ … … 60 23 * 61 24 * @param \SimplePie\SimplePie $data 62 * @return array First item is the serialized data for storage, second item is the unique ID for this item25 * @return array{string, array<string, Item>} First item is the serialized data for storage, second item is the unique ID for this item 63 26 */ 64 protected static function prepare_simplepie_object_for_cache( $data)27 protected static function prepare_simplepie_object_for_cache(\SimplePie\SimplePie $data) 65 28 { 66 29 $items = $data->get_items(); -
trunk/src/wp-includes/SimplePie/src/Cache/DataCache.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-2022 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\Cache; … … 56 19 * methods of \Psr\SimpleCache\CacheInterface. 57 20 * 58 * @package SimplePie59 * @subpackage Caching60 21 * @internal 61 22 */ … … 89 50 * 90 51 * @param string $key The key of the item to store. 91 * @param array $value The value of the item to store, must be serializable.52 * @param array<mixed> $value The value of the item to store, must be serializable. 92 53 * @param null|int $ttl Optional. The TTL value of this item. If no value is sent and 93 54 * the driver supports TTL then the library may set a default value -
trunk/src/wp-includes/SimplePie/src/Cache/File.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\Cache; … … 48 11 * Caches data to the filesystem 49 12 * 50 * @package SimplePie51 * @subpackage Caching52 13 * @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead 53 14 */ … … 90 51 * @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data 91 52 */ 92 public function __construct( $location,$name, $type)53 public function __construct(string $location, string $name, $type) 93 54 { 94 55 $this->location = $location; … … 101 62 * Save data to the cache 102 63 * 103 * @param array |\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property64 * @param array<mixed>|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property 104 65 * @return bool Successfulness 105 66 */ … … 120 81 * Retrieve the data saved to the cache 121 82 * 122 * @return array Data for SimplePie::$data83 * @return array<mixed>|false Data for SimplePie::$data 123 84 */ 124 85 public function load() 125 86 { 126 87 if (file_exists($this->name) && is_readable($this->name)) { 127 return unserialize( file_get_contents($this->name));88 return unserialize((string) file_get_contents($this->name)); 128 89 } 129 90 return false; … … 133 94 * Retrieve the last modified time for the cache 134 95 * 135 * @return int Timestamp96 * @return int|false Timestamp 136 97 */ 137 98 public function mtime() -
trunk/src/wp-includes/SimplePie/src/Cache/Memcache.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\Cache; … … 56 19 * prefixed with `sp_` and data will expire after 3600 seconds 57 20 * 58 * @package SimplePie59 * @subpackage Caching60 21 * @uses Memcache 61 22 * @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead … … 66 27 * Memcache instance 67 28 * 68 * @var Memcache29 * @var NativeMemcache 69 30 */ 70 31 protected $cache; … … 73 34 * Options 74 35 * 75 * @var array 36 * @var array<string, mixed> 76 37 */ 77 38 protected $options; … … 91 52 * @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data 92 53 */ 93 public function __construct( $location,$name, $type)54 public function __construct(string $location, string $name, $type) 94 55 { 95 56 $this->options = [ … … 112 73 * Save data to the cache 113 74 * 114 * @param array |\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property75 * @param array<mixed>|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property 115 76 * @return bool Successfulness 116 77 */ … … 126 87 * Retrieve the data saved to the cache 127 88 * 128 * @return array Data for SimplePie::$data89 * @return array<mixed>|false Data for SimplePie::$data 129 90 */ 130 91 public function load() … … 141 102 * Retrieve the last modified time for the cache 142 103 * 143 * @return int Timestamp104 * @return int|false Timestamp 144 105 */ 145 106 public function mtime() -
trunk/src/wp-includes/SimplePie/src/Cache/Memcached.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-FileCopyrightText: 2015 Paul L. McNeely 5 // SPDX-License-Identifier: BSD-3-Clause 6 7 declare(strict_types=1); 44 8 45 9 namespace SimplePie\Cache; … … 56 20 * prefixed with `sp_` and data will expire after 3600 seconds 57 21 * 58 * @package SimplePie59 * @subpackage Caching60 * @author Paul L. McNeely61 22 * @uses Memcached 62 23 * @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead … … 72 33 /** 73 34 * Options 74 * @var array 35 * @var array<string, mixed> 75 36 */ 76 37 protected $options; … … 88 49 * @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data 89 50 */ 90 public function __construct( $location,$name, $type)51 public function __construct(string $location, string $name, $type) 91 52 { 92 53 $this->options = [ … … 108 69 /** 109 70 * Save data to the cache 110 * @param array |\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property71 * @param array<mixed>|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property 111 72 * @return bool Successfulness 112 73 */ … … 122 83 /** 123 84 * Retrieve the data saved to the cache 124 * @return array Data for SimplePie::$data85 * @return array<mixed>|false Data for SimplePie::$data 125 86 */ 126 87 public function load() … … 165 126 /** 166 127 * Set the last modified time and data to NativeMemcached 128 * @param string|false $data 167 129 * @return bool Success status 168 130 */ 169 private function setData($data) 131 private function setData($data): bool 170 132 { 171 133 if ($data !== false) { -
trunk/src/wp-includes/SimplePie/src/Cache/MySQL.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\Cache; … … 54 17 * `root` and the password `password`. All tables will be prefixed with `sp_` 55 18 * 56 * @package SimplePie57 * @subpackage Caching58 19 * @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead 59 20 */ … … 63 24 * PDO instance 64 25 * 65 * @var \PDO 26 * @var \PDO|null 66 27 */ 67 28 protected $mysql; … … 70 31 * Options 71 32 * 72 * @var array 33 * @var array<string, mixed> 73 34 */ 74 35 protected $options; … … 88 49 * @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data 89 50 */ 90 public function __construct( $location,$name, $type)51 public function __construct(string $location, string $name, $type) 91 52 { 92 53 $this->options = [ … … 148 109 * Save data to the cache 149 110 * 150 * @param array |\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property111 * @param array<string>|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property 151 112 * @return bool Successfulness 152 113 */ … … 269 230 * Retrieve the data saved to the cache 270 231 * 271 * @return array Data for SimplePie::$data232 * @return array<string>|false Data for SimplePie::$data 272 233 */ 273 234 public function load() … … 311 272 if ($query->execute()) { 312 273 while ($row = $query->fetchColumn()) { 313 $feed['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['entry'][] = unserialize( $row);274 $feed['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['entry'][] = unserialize((string) $row); 314 275 } 315 276 } else { … … 326 287 * Retrieve the last modified time for the cache 327 288 * 328 * @return int Timestamp289 * @return int|false Timestamp 329 290 */ 330 291 public function mtime() … … 337 298 $query->bindValue(':id', $this->id); 338 299 if ($query->execute() && ($time = $query->fetchColumn())) { 339 return $time;300 return (int) $time; 340 301 } 341 302 -
trunk/src/wp-includes/SimplePie/src/Cache/NameFilter.php
r59141 r60771 1 1 <?php 2 /** 3 * SimplePie 4 * 5 * A PHP-Based RSS and Atom Feed Framework. 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 * 8 * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without modification, are 12 * permitted provided that the following conditions are met: 13 * 14 * * Redistributions of source code must retain the above copyright notice, this list of 15 * conditions and the following disclaimer. 16 * 17 * * Redistributions in binary form must reproduce the above copyright notice, this list 18 * of conditions and the following disclaimer in the documentation and/or other materials 19 * provided with the distribution. 20 * 21 * * Neither the name of the SimplePie Team nor the names of its contributors may be used 22 * to endorse or promote products derived from this software without specific prior 23 * written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS 26 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 27 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS 28 * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 32 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 * POSSIBILITY OF SUCH DAMAGE. 34 * 35 * @package SimplePie 36 * @copyright 2004-2022 Ryan Parman, Sam Sneddon, Ryan McCue 37 * @author Ryan Parman 38 * @author Sam Sneddon 39 * @author Ryan McCue 40 * @link http://simplepie.org/ SimplePie 41 * @license http://www.opensource.org/licenses/bsd-license.php BSD License 42 */ 2 3 // SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue 4 // SPDX-License-Identifier: BSD-3-Clause 5 6 declare(strict_types=1); 43 7 44 8 namespace SimplePie\Cache; … … 46 10 /** 47 11 * Interface for creating a cache filename 48 *49 * @package SimplePie50 * @subpackage Caching51 12 */ 52 13 interface NameFilter … … 69 30 * minimum. 70 31 * 71 * @param string $name The name for the cache will be most lik ly an url with query string32 * @param string $name The name for the cache will be most likely an url with query string 72 33 * 73 34 * @return string the new cache name -
trunk/src/wp-includes/SimplePie/src/Cache/Psr16.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-2022 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\Cache; … … 47 10 use Psr\SimpleCache\CacheInterface; 48 11 use Psr\SimpleCache\InvalidArgumentException; 12 use Throwable; 49 13 50 14 /** 51 15 * Caches data into a PSR-16 cache implementation 52 16 * 53 * @package SimplePie54 * @subpackage Caching55 17 * @internal 56 18 */ … … 87 49 * @return array|mixed The value of the item from the cache, or $default in case of cache miss. 88 50 * 89 * @throws InvalidArgumentException 51 * @throws InvalidArgumentException&Throwable 90 52 * MUST be thrown if the $key string is not a legal value. 91 53 */ … … 110 72 * 111 73 * @param string $key The key of the item to store. 112 * @param array $value The value of the item to store, must be serializable.74 * @param array<mixed> $value The value of the item to store, must be serializable. 113 75 * @param null|int $ttl Optional. The TTL value of this item. If no value is sent and 114 76 * the driver supports TTL then the library may set a default value … … 117 79 * @return bool True on success and false on failure. 118 80 * 119 * @throws InvalidArgumentException 81 * @throws InvalidArgumentException&Throwable 120 82 * MUST be thrown if the $key string is not a legal value. 121 83 */ … … 137 99 * @return bool True if the item was successfully removed. False if there was an error. 138 100 * 139 * @throws InvalidArgumentException 101 * @throws InvalidArgumentException&Throwable 140 102 * MUST be thrown if the $key string is not a legal value. 141 103 */ -
trunk/src/wp-includes/SimplePie/src/Cache/Redis.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-FileCopyrightText: 2015 Jan Kozak <galvani78@gmail.com> 5 // SPDX-License-Identifier: BSD-3-Clause 6 7 declare(strict_types=1); 44 8 45 9 namespace SimplePie\Cache; … … 56 20 * prefixed with `simple_primary-` and data will expire after 3600 seconds 57 21 * 58 * @package SimplePie59 * @subpackage Caching60 22 * @uses Redis 61 23 * @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead … … 73 35 * Options 74 36 * 75 * @var array 37 * @var array<string, mixed> 76 38 */ 77 39 protected $options; … … 89 51 * @param string $location Location string (from SimplePie::$cache_location) 90 52 * @param string $name Unique ID for the cache 91 * @param Base::TYPE_FEED|Base::TYPE_IMAGE $typeEither TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data53 * @param Base::TYPE_FEED|Base::TYPE_IMAGE|array<string, mixed>|null $options Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data 92 54 */ 93 public function __construct( $location,$name, $options = null)55 public function __construct(string $location, string $name, $options = null) 94 56 { 95 57 //$this->cache = \flow\simple\cache\Redis::getRedisClientInstance(); … … 119 81 /** 120 82 * @param NativeRedis $cache 83 * @return void 121 84 */ 122 85 public function setRedisClient(NativeRedis $cache) … … 128 91 * Save data to the cache 129 92 * 130 * @param array |\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property93 * @param array<mixed>|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property 131 94 * @return bool Successfulness 132 95 */ … … 147 110 * Retrieve the data saved to the cache 148 111 * 149 * @return array Data for SimplePie::$data112 * @return array<mixed>|false Data for SimplePie::$data 150 113 */ 151 114 public function load() … … 162 125 * Retrieve the last modified time for the cache 163 126 * 164 * @return int Timestamp127 * @return int|false Timestamp 165 128 */ 166 129 public function mtime() -
trunk/src/wp-includes/SimplePie/src/Caption.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\SimplePie::set_caption_class()} 53 *54 * @package SimplePie55 * @subpackage API56 16 */ 57 17 class Caption … … 60 20 * Content type 61 21 * 62 * @var string22 * @var ?string 63 23 * @see get_type() 64 24 */ … … 68 28 * Language 69 29 * 70 * @var string30 * @var ?string 71 31 * @see get_language() 72 32 */ … … 76 36 * Start time 77 37 * 78 * @var string38 * @var ?string 79 39 * @see get_starttime() 80 40 */ … … 84 44 * End time 85 45 * 86 * @var string46 * @var ?string 87 47 * @see get_endtime() 88 48 */ … … 92 52 * Caption text 93 53 * 94 * @var string54 * @var ?string 95 55 * @see get_text() 96 56 */ … … 103 63 * properties and their accessors 104 64 */ 105 public function __construct($type = null, $lang = null, $startTime = null, $endTime = null, $text = null) 106 { 65 public function __construct( 66 ?string $type = null, 67 ?string $lang = null, 68 ?string $startTime = null, 69 ?string $endTime = null, 70 ?string $text = null 71 ) { 107 72 $this->type = $type; 108 73 $this->lang = $lang; -
trunk/src/wp-includes/SimplePie/src/Category.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\SimplePie::set_category_class()} 53 *54 * @package SimplePie55 * @subpackage API56 16 */ 57 17 class Category … … 100 60 * @param string|null $type 101 61 */ 102 public function __construct( $term = null, $scheme = null, $label = null,$type = null)62 public function __construct(?string $term = null, ?string $scheme = null, ?string $label = null, ?string $type = null) 103 63 { 104 64 $this->term = $term; … … 145 105 * @return string|null 146 106 */ 147 public function get_label( $strict = false)107 public function get_label(bool $strict = false) 148 108 { 149 109 if ($this->label === null && $strict !== true) { -
trunk/src/wp-includes/SimplePie/src/Content/Type/Sniffer.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\Content\Type; 9 10 use InvalidArgumentException; 11 use SimplePie\File; 12 use SimplePie\HTTP\Response; 46 13 47 14 /** … … 55 22 * 56 23 * This class can be overloaded with {@see \SimplePie\SimplePie::set_content_type_sniffer_class()} 57 *58 * @package SimplePie59 * @subpackage HTTP60 24 */ 61 25 class Sniffer … … 64 28 * File object 65 29 * 66 * @var \SimplePie\File30 * @var File|Response 67 31 */ 68 32 public $file; … … 71 35 * Create an instance of the class with the input file 72 36 * 73 * @param Sniffer $file Input file 74 */ 75 public function __construct($file) 76 { 37 * @param File|Response $file Input file 38 */ 39 public function __construct(/* File */ $file) 40 { 41 if (!is_object($file) || !$file instanceof Response) { 42 // For BC we're asking for `File`, but internally we accept every `Response` implementation 43 throw new InvalidArgumentException(sprintf( 44 '%s(): Argument #1 ($file) must be of type %s', 45 __METHOD__, 46 File::class 47 ), 1); 48 } 49 77 50 $this->file = $file; 78 51 } … … 85 58 public function get_type() 86 59 { 87 if (isset($this->file->headers['content-type'])) { 88 if (!isset($this->file->headers['content-encoding']) 89 && ($this->file->headers['content-type'] === 'text/plain' 90 || $this->file->headers['content-type'] === 'text/plain; charset=ISO-8859-1' 91 || $this->file->headers['content-type'] === 'text/plain; charset=iso-8859-1' 92 || $this->file->headers['content-type'] === 'text/plain; charset=UTF-8')) { 60 $content_type = $this->file->has_header('content-type') ? $this->file->get_header_line('content-type') : null; 61 $content_encoding = $this->file->has_header('content-encoding') ? $this->file->get_header_line('content-encoding') : null; 62 if ($content_type !== null) { 63 if ($content_encoding === null 64 && ($content_type === 'text/plain' 65 || $content_type === 'text/plain; charset=ISO-8859-1' 66 || $content_type === 'text/plain; charset=iso-8859-1' 67 || $content_type === 'text/plain; charset=UTF-8')) { 93 68 return $this->text_or_binary(); 94 69 } 95 70 96 if (($pos = strpos($ this->file->headers['content-type'], ';')) !== false) {97 $official = substr($ this->file->headers['content-type'], 0, $pos);71 if (($pos = strpos($content_type, ';')) !== false) { 72 $official = substr($content_type, 0, $pos); 98 73 } else { 99 $official = $ this->file->headers['content-type'];74 $official = $content_type; 100 75 } 101 76 $official = trim(strtolower($official)); … … 131 106 public function text_or_binary() 132 107 { 133 if (substr($this->file->body, 0, 2) === "\xFE\xFF" 134 || substr($this->file->body, 0, 2) === "\xFF\xFE" 135 || substr($this->file->body, 0, 4) === "\x00\x00\xFE\xFF" 136 || substr($this->file->body, 0, 3) === "\xEF\xBB\xBF") { 108 $body = $this->file->get_body_content(); 109 110 if (substr($body, 0, 2) === "\xFE\xFF" 111 || substr($body, 0, 2) === "\xFF\xFE" 112 || substr($body, 0, 4) === "\x00\x00\xFE\xFF" 113 || substr($body, 0, 3) === "\xEF\xBB\xBF") { 137 114 return 'text/plain'; 138 } elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/', $ this->file->body)) {115 } elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/', $body)) { 139 116 return 'application/octet-stream'; 140 117 } … … 150 127 public function unknown() 151 128 { 152 $ws = strspn($this->file->body, "\x09\x0A\x0B\x0C\x0D\x20"); 153 if (strtolower(substr($this->file->body, $ws, 14)) === '<!doctype html' 154 || strtolower(substr($this->file->body, $ws, 5)) === '<html' 155 || strtolower(substr($this->file->body, $ws, 7)) === '<script') { 129 $body = $this->file->get_body_content(); 130 131 $ws = strspn($body, "\x09\x0A\x0B\x0C\x0D\x20"); 132 if (strtolower(substr($body, $ws, 14)) === '<!doctype html' 133 || strtolower(substr($body, $ws, 5)) === '<html' 134 || strtolower(substr($body, $ws, 7)) === '<script') { 156 135 return 'text/html'; 157 } elseif (substr($ this->file->body, 0, 5) === '%PDF-') {136 } elseif (substr($body, 0, 5) === '%PDF-') { 158 137 return 'application/pdf'; 159 } elseif (substr($ this->file->body, 0, 11) === '%!PS-Adobe-') {138 } elseif (substr($body, 0, 11) === '%!PS-Adobe-') { 160 139 return 'application/postscript'; 161 } elseif (substr($ this->file->body, 0, 6) === 'GIF87a'162 || substr($ this->file->body, 0, 6) === 'GIF89a') {140 } elseif (substr($body, 0, 6) === 'GIF87a' 141 || substr($body, 0, 6) === 'GIF89a') { 163 142 return 'image/gif'; 164 } elseif (substr($ this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") {143 } elseif (substr($body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") { 165 144 return 'image/png'; 166 } elseif (substr($ this->file->body, 0, 3) === "\xFF\xD8\xFF") {145 } elseif (substr($body, 0, 3) === "\xFF\xD8\xFF") { 167 146 return 'image/jpeg'; 168 } elseif (substr($ this->file->body, 0, 2) === "\x42\x4D") {147 } elseif (substr($body, 0, 2) === "\x42\x4D") { 169 148 return 'image/bmp'; 170 } elseif (substr($ this->file->body, 0, 4) === "\x00\x00\x01\x00") {149 } elseif (substr($body, 0, 4) === "\x00\x00\x01\x00") { 171 150 return 'image/vnd.microsoft.icon'; 172 151 } … … 178 157 * Sniff images 179 158 * 180 * @return string Actual Content-Type159 * @return string|false Actual Content-Type 181 160 */ 182 161 public function image() 183 162 { 184 if (substr($this->file->body, 0, 6) === 'GIF87a' 185 || substr($this->file->body, 0, 6) === 'GIF89a') { 163 $body = $this->file->get_body_content(); 164 165 if (substr($body, 0, 6) === 'GIF87a' 166 || substr($body, 0, 6) === 'GIF89a') { 186 167 return 'image/gif'; 187 } elseif (substr($ this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") {168 } elseif (substr($body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") { 188 169 return 'image/png'; 189 } elseif (substr($ this->file->body, 0, 3) === "\xFF\xD8\xFF") {170 } elseif (substr($body, 0, 3) === "\xFF\xD8\xFF") { 190 171 return 'image/jpeg'; 191 } elseif (substr($ this->file->body, 0, 2) === "\x42\x4D") {172 } elseif (substr($body, 0, 2) === "\x42\x4D") { 192 173 return 'image/bmp'; 193 } elseif (substr($ this->file->body, 0, 4) === "\x00\x00\x01\x00") {174 } elseif (substr($body, 0, 4) === "\x00\x00\x01\x00") { 194 175 return 'image/vnd.microsoft.icon'; 195 176 } … … 205 186 public function feed_or_html() 206 187 { 207 $len = strlen($this->file->body); 208 $pos = strspn($this->file->body, "\x09\x0A\x0D\x20\xEF\xBB\xBF"); 188 $body = $this->file->get_body_content(); 189 190 $len = strlen($body); 191 $pos = strspn($body, "\x09\x0A\x0D\x20\xEF\xBB\xBF"); 209 192 210 193 while ($pos < $len) { 211 switch ($ this->file->body[$pos]) {194 switch ($body[$pos]) { 212 195 case "\x09": 213 196 case "\x0A": 214 197 case "\x0D": 215 198 case "\x20": 216 $pos += strspn($ this->file->body, "\x09\x0A\x0D\x20", $pos);199 $pos += strspn($body, "\x09\x0A\x0D\x20", $pos); 217 200 continue 2; 218 201 … … 225 208 } 226 209 227 if (substr($ this->file->body, $pos, 3) === '!--') {210 if (substr($body, $pos, 3) === '!--') { 228 211 $pos += 3; 229 if ($pos < $len && ($pos = strpos($ this->file->body, '-->', $pos)) !== false) {212 if ($pos < $len && ($pos = strpos($body, '-->', $pos)) !== false) { 230 213 $pos += 3; 231 214 } else { 232 215 return 'text/html'; 233 216 } 234 } elseif (substr($ this->file->body, $pos, 1) === '!') {235 if ($pos < $len && ($pos = strpos($ this->file->body, '>', $pos)) !== false) {217 } elseif (substr($body, $pos, 1) === '!') { 218 if ($pos < $len && ($pos = strpos($body, '>', $pos)) !== false) { 236 219 $pos++; 237 220 } else { 238 221 return 'text/html'; 239 222 } 240 } elseif (substr($ this->file->body, $pos, 1) === '?') {241 if ($pos < $len && ($pos = strpos($ this->file->body, '?>', $pos)) !== false) {223 } elseif (substr($body, $pos, 1) === '?') { 224 if ($pos < $len && ($pos = strpos($body, '?>', $pos)) !== false) { 242 225 $pos += 2; 243 226 } else { 244 227 return 'text/html'; 245 228 } 246 } elseif (substr($ this->file->body, $pos, 3) === 'rss'247 || substr($ this->file->body, $pos, 7) === 'rdf:RDF') {229 } elseif (substr($body, $pos, 3) === 'rss' 230 || substr($body, $pos, 7) === 'rdf:RDF') { 248 231 return 'application/rss+xml'; 249 } elseif (substr($ this->file->body, $pos, 4) === 'feed') {232 } elseif (substr($body, $pos, 4) === 'feed') { 250 233 return 'application/atom+xml'; 251 234 } else { -
trunk/src/wp-includes/SimplePie/src/Copyright.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\SimplePie::set_copyright_class()} 53 *54 * @package SimplePie55 * @subpackage API56 16 */ 57 17 class Copyright … … 60 20 * Copyright URL 61 21 * 62 * @var string22 * @var ?string 63 23 * @see get_url() 64 24 */ … … 68 28 * Attribution 69 29 * 70 * @var string30 * @var ?string 71 31 * @see get_attribution() 72 32 */ … … 79 39 * properties and their accessors 80 40 */ 81 public function __construct($url = null, $label = null) 82 { 41 public function __construct( 42 ?string $url = null, 43 ?string $label = null 44 ) { 83 45 $this->url = $url; 84 46 $this->label = $label; -
trunk/src/wp-includes/SimplePie/src/Credit.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\SimplePie::set_credit_class()} 53 *54 * @package SimplePie55 * @subpackage API56 16 */ 57 17 class Credit … … 60 20 * Credited role 61 21 * 62 * @var string22 * @var ?string 63 23 * @see get_role() 64 24 */ … … 68 28 * Organizational scheme 69 29 * 70 * @var string30 * @var ?string 71 31 * @see get_scheme() 72 32 */ … … 76 36 * Credited name 77 37 * 78 * @var string38 * @var ?string 79 39 * @see get_name() 80 40 */ … … 87 47 * properties and their accessors 88 48 */ 89 public function __construct($role = null, $scheme = null, $name = null) 90 { 49 public function __construct( 50 ?string $role = null, 51 ?string $scheme = null, 52 ?string $name = null 53 ) { 91 54 $this->role = $role; 92 55 $this->scheme = $scheme; -
trunk/src/wp-includes/SimplePie/src/Enclosure.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\SimplePie::set_enclosure_class()} 53 *54 * @package SimplePie55 * @subpackage API56 16 */ 57 17 class Enclosure 58 18 { 59 19 /** 60 * @var string20 * @var ?string 61 21 * @see get_bitrate() 62 22 */ … … 64 24 65 25 /** 66 * @var array26 * @var Caption[]|null 67 27 * @see get_captions() 68 28 */ … … 70 30 71 31 /** 72 * @var array32 * @var Category[]|null 73 33 * @see get_categories() 74 34 */ … … 76 36 77 37 /** 78 * @var int38 * @var ?int 79 39 * @see get_channels() 80 40 */ … … 82 42 83 43 /** 84 * @var \SimplePie\Copyright44 * @var ?Copyright 85 45 * @see get_copyright() 86 46 */ … … 88 48 89 49 /** 90 * @var array50 * @var Credit[]|null 91 51 * @see get_credits() 92 52 */ … … 94 54 95 55 /** 96 * @var string56 * @var ?string 97 57 * @see get_description() 98 58 */ … … 100 60 101 61 /** 102 * @var int62 * @var ?int 103 63 * @see get_duration() 104 64 */ … … 106 66 107 67 /** 108 * @var string68 * @var ?string 109 69 * @see get_expression() 110 70 */ … … 112 72 113 73 /** 114 * @var string74 * @var ?string 115 75 * @see get_framerate() 116 76 */ … … 118 78 119 79 /** 120 * @var string80 * @var ?string 121 81 * @see get_handler() 122 82 */ … … 124 84 125 85 /** 126 * @var array86 * @var string[]|null 127 87 * @see get_hashes() 128 88 */ … … 130 90 131 91 /** 132 * @var string92 * @var ?string 133 93 * @see get_height() 134 94 */ … … 142 102 143 103 /** 144 * @var array104 * @var string[]|null 145 105 * @see get_keywords() 146 106 */ … … 148 108 149 109 /** 150 * @var string110 * @var ?string 151 111 * @see get_language() 152 112 */ … … 154 114 155 115 /** 156 * @var string116 * @var ?int 157 117 * @see get_length() 158 118 */ … … 160 120 161 121 /** 162 * @var string122 * @var ?string 163 123 * @see get_link() 164 124 */ … … 166 126 167 127 /** 168 * @var string128 * @var ?string 169 129 * @see get_medium() 170 130 */ … … 172 132 173 133 /** 174 * @var string134 * @var ?string 175 135 * @see get_player() 176 136 */ … … 178 138 179 139 /** 180 * @var array140 * @var Rating[]|null 181 141 * @see get_ratings() 182 142 */ … … 184 144 185 145 /** 186 * @var array146 * @var ?Restriction[] 187 147 * @see get_restrictions() 188 148 */ … … 190 150 191 151 /** 192 * @var string152 * @var ?string 193 153 * @see get_sampling_rate() 194 154 */ … … 196 156 197 157 /** 198 * @var array158 * @var string[]|null 199 159 * @see get_thumbnails() 200 160 */ … … 202 162 203 163 /** 204 * @var string164 * @var ?string 205 165 * @see get_title() 206 166 */ … … 208 168 209 169 /** 210 * @var string170 * @var ?string 211 171 * @see get_type() 212 172 */ … … 214 174 215 175 /** 216 * @var string176 * @var ?string 217 177 * @see get_width() 218 178 */ … … 225 185 * properties and their accessors 226 186 * 227 * @uses idna_convert If available, this will convert an IDN 228 */ 229 public function __construct($link = null, $type = null, $length = null, $javascript = null, $bitrate = null, $captions = null, $categories = null, $channels = null, $copyright = null, $credits = null, $description = null, $duration = null, $expression = null, $framerate = null, $hashes = null, $height = null, $keywords = null, $lang = null, $medium = null, $player = null, $ratings = null, $restrictions = null, $samplingrate = null, $thumbnails = null, $title = null, $width = null) 230 { 187 * @uses idn_to_ascii If available, this will convert an IDN 188 * 189 * @param null $javascript 190 * @param Caption[]|null $captions 191 * @param Category[]|null $categories 192 * @param Credit[]|null $credits 193 * @param string[]|null $hashes 194 * @param string[]|null $keywords 195 * @param Rating[]|null $ratings 196 * @param Restriction[]|null $restrictions 197 * @param string[]|null $thumbnails 198 */ 199 public function __construct( 200 ?string $link = null, 201 ?string $type = null, 202 ?int $length = null, 203 $javascript = null, 204 ?string $bitrate = null, 205 ?array $captions = null, 206 ?array $categories = null, 207 ?int $channels = null, 208 ?Copyright $copyright = null, 209 ?array $credits = null, 210 ?string $description = null, 211 ?int $duration = null, 212 ?string $expression = null, 213 ?string $framerate = null, 214 ?array $hashes = null, 215 ?string $height = null, 216 ?array $keywords = null, 217 ?string $lang = null, 218 ?string $medium = null, 219 ?string $player = null, 220 ?array $ratings = null, 221 ?array $restrictions = null, 222 ?string $samplingrate = null, 223 ?array $thumbnails = null, 224 ?string $title = null, 225 ?string $width = null 226 ) { 231 227 $this->bitrate = $bitrate; 232 228 $this->captions = $captions; … … 255 251 $this->width = $width; 256 252 257 if (class_exists('idna_convert')) { 258 $idn = new \idna_convert(); 259 $parsed = \SimplePie\Misc::parse_url($link); 260 $this->link = \SimplePie\Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']); 253 if (function_exists('idn_to_ascii')) { 254 $parsed = \SimplePie\Misc::parse_url($link ?? ''); 255 if ($parsed['authority'] !== '' && !ctype_print($parsed['authority'])) { 256 $authority = (string) \idn_to_ascii($parsed['authority'], \IDNA_NONTRANSITIONAL_TO_ASCII, \INTL_IDNA_VARIANT_UTS46); 257 $this->link = \SimplePie\Misc::compress_parse_url($parsed['scheme'], $authority, $parsed['path'], $parsed['query'], $parsed['fragment']); 258 } 261 259 } 262 260 $this->handler = $this->get_handler(); // Needs to load last … … 294 292 * @return \SimplePie\Caption|null 295 293 */ 296 public function get_caption( $key = 0)294 public function get_caption(int $key = 0) 297 295 { 298 296 $captions = $this->get_captions(); … … 307 305 * Get all captions 308 306 * 309 * @return array|null Array of {@see \SimplePie\Caption} objects307 * @return Caption[]|null 310 308 */ 311 309 public function get_captions() … … 324 322 * @return \SimplePie\Category|null 325 323 */ 326 public function get_category( $key = 0)324 public function get_category(int $key = 0) 327 325 { 328 326 $categories = $this->get_categories(); … … 337 335 * Get all categories 338 336 * 339 * @return array|null Array of {@see \SimplePie\Category} objects337 * @return \SimplePie\Category[]|null 340 338 */ 341 339 public function get_categories() … … 382 380 * @return \SimplePie\Credit|null 383 381 */ 384 public function get_credit( $key = 0)382 public function get_credit(int $key = 0) 385 383 { 386 384 $credits = $this->get_credits(); … … 395 393 * Get all credits 396 394 * 397 * @return array|null Array of {@see \SimplePie\Credit} objects395 * @return Credit[]|null 398 396 */ 399 397 public function get_credits() … … 426 424 * @return string|int|null 'hh:mm:ss' string if `$convert` was specified, otherwise integer (or null if none found) 427 425 */ 428 public function get_duration( $convert = false)426 public function get_duration(bool $convert = false) 429 427 { 430 428 if ($this->duration !== null) { … … 501 499 * @return string|null Hash as per `media:hash`, prefixed with "$algo:" 502 500 */ 503 public function get_hash( $key = 0)501 public function get_hash(int $key = 0) 504 502 { 505 503 $hashes = $this->get_hashes(); … … 514 512 * Get all credits 515 513 * 516 * @return array|null Array of strings, see {@see get_hash()}514 * @return string[]|null Array of strings, see {@see get_hash()} 517 515 */ 518 516 public function get_hashes() … … 560 558 * @return string|null 561 559 */ 562 public function get_keyword( $key = 0)560 public function get_keyword(int $key = 0) 563 561 { 564 562 $keywords = $this->get_keywords(); … … 573 571 * Get all keywords 574 572 * 575 * @return array|null Array of strings573 * @return string[]|null 576 574 */ 577 575 public function get_keywords() … … 587 585 * Get length 588 586 * 589 * @return float Length in bytes587 * @return ?int Length in bytes 590 588 */ 591 589 public function get_length() … … 648 646 * @return \SimplePie\Rating|null 649 647 */ 650 public function get_rating( $key = 0)648 public function get_rating(int $key = 0) 651 649 { 652 650 $ratings = $this->get_ratings(); … … 661 659 * Get all ratings 662 660 * 663 * @return array|null Array of {@see \SimplePie\Rating} objects661 * @return Rating[]|null 664 662 */ 665 663 public function get_ratings() … … 678 676 * @return \SimplePie\Restriction|null 679 677 */ 680 public function get_restriction( $key = 0)678 public function get_restriction(int $key = 0) 681 679 { 682 680 $restrictions = $this->get_restrictions(); … … 691 689 * Get all restrictions 692 690 * 693 * @return array|null Array of {@see \SimplePie\Restriction} objects691 * @return Restriction[]|null 694 692 */ 695 693 public function get_restrictions() … … 737 735 * @return string|null Thumbnail URL 738 736 */ 739 public function get_thumbnail( $key = 0)737 public function get_thumbnail(int $key = 0) 740 738 { 741 739 $thumbnails = $this->get_thumbnails(); … … 750 748 * Get all thumbnails 751 749 * 752 * @return array|null Array of thumbnail URLs750 * @return string[]|null Array of thumbnail URLs 753 751 */ 754 752 public function get_thumbnails() … … 809 807 * @deprecated Use the second parameter to {@see embed} instead 810 808 * 811 * @param array |string $options See first parameter to {@see embed}809 * @param array<string, mixed>|string $options See first parameter to {@see embed} 812 810 * @return string HTML string to output 813 811 */ … … 858 856 * 859 857 * @todo If the dimensions for media:content are defined, use them when width/height are set to 'auto'. 860 * @param array |string $options Comma-separated key:value list, or array858 * @param array<string, mixed>|string $options Comma-separated key:value list, or array 861 859 * @param bool $native Use `<embed>` 862 860 * @return string HTML string to output 863 861 */ 864 public function embed($options = '', $native = false)862 public function embed($options = '', bool $native = false) 865 863 { 866 864 // Set up defaults … … 934 932 } 935 933 936 $mime = explode('/', $type, 2);934 $mime = explode('/', (string) $type, 2); 937 935 $mime = $mime[0]; 938 936 … … 995 993 // Preferred handler for MP3 file types. 996 994 elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== '')) { 997 $height += 20; 995 if (is_numeric($height)) { 996 $height += 20; 997 } 998 998 999 if ($native) { 999 1000 $embed .= "<embed src=\"$mediaplayer\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" quality=\"high\" width=\"$width\" height=\"$height\" wmode=\"transparent\" flashvars=\"file=" . rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) . "&autostart=false&repeat=$loop&showdigits=true&showfsbutton=false\"></embed>"; … … 1006 1007 // Only handle MP3's if the Flash Media Player is not present. 1007 1008 elseif ($handler === 'quicktime' || ($handler === 'mp3' && $mediaplayer === '')) { 1008 $height += 16; 1009 if (is_numeric($height)) { 1010 $height += 16; 1011 } 1012 1009 1013 if ($native) { 1010 1014 if ($placeholder !== '') { … … 1020 1024 // Windows Media 1021 1025 elseif ($handler === 'wmedia') { 1022 $height += 45; 1026 if (is_numeric($height)) { 1027 $height += 45; 1028 } 1029 1023 1030 if ($native) { 1024 1031 $embed .= "<embed type=\"application/x-mplayer2\" src=\"" . $this->get_link() . "\" autosize=\"1\" width=\"$width\" height=\"$height\" showcontrols=\"1\" showstatusbar=\"0\" showdisplay=\"0\" autostart=\"0\"></embed>"; … … 1045 1052 * @see get_type() 1046 1053 * @param bool $find_handler Internal use only, use {@see get_handler()} instead 1047 * @return string MIME type1048 */ 1049 public function get_real_type( $find_handler = false)1054 * @return string|null MIME type 1055 */ 1056 public function get_real_type(bool $find_handler = false) 1050 1057 { 1051 1058 // Mime-types by handler. … … 1056 1063 $types_mp3 = ['audio/mp3', 'audio/x-mp3', 'audio/mpeg', 'audio/x-mpeg']; // MP3 1057 1064 1058 if ($this->get_type() !== null) { 1059 $type = strtolower($this->type); 1060 } else { 1061 $type = null; 1065 $type = $this->get_type(); 1066 if ($type !== null) { 1067 $type = strtolower($type); 1062 1068 } 1063 1069 … … 1115 1121 break; 1116 1122 1117 // Video mime-types1118 1123 case '3gp': 1119 1124 case '3gpp': 1125 // Video mime-types 1120 1126 $type = 'video/3gpp'; 1121 1127 break; … … 1178 1184 break; 1179 1185 1186 case 'spl': 1180 1187 // Flash mime-types 1181 case 'spl':1182 1188 $type = 'application/futuresplash'; 1183 1189 break; -
trunk/src/wp-includes/SimplePie/src/Exception.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; … … 49 12 /** 50 13 * General SimplePie exception class 51 *52 * @package SimplePie53 14 */ 54 15 class Exception extends NativeException -
trunk/src/wp-includes/SimplePie/src/File.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; 9 10 use SimplePie\HTTP\Response; 46 11 47 12 /** … … 52 17 * This class can be overloaded with {@see \SimplePie\SimplePie::set_file_class()} 53 18 * 54 * @package SimplePie55 * @subpackage HTTP56 19 * @todo Move to properly supporting RFC2616 (HTTP/1.1) 57 20 */ 58 class File 21 class File implements Response 59 22 { 23 /** 24 * @var string The final URL after following all redirects 25 * @deprecated Use `get_final_requested_uri()` method. 26 */ 60 27 public $url; 28 29 /** 30 * @var ?string User agent to use in requests 31 * @deprecated Set the user agent in constructor. 32 */ 61 33 public $useragent; 34 35 /** @var bool */ 62 36 public $success = true; 37 38 /** @var array<string, non-empty-array<string>> Canonical representation of headers */ 39 private $parsed_headers = []; 40 /** @var array<string, string> Last known value of $headers property (used to detect external modification) */ 41 private $last_headers = []; 42 /** 43 * @var array<string, string> Headers as string for BC 44 * @deprecated Use `get_headers()` method. 45 */ 63 46 public $headers = []; 47 48 /** 49 * @var ?string Body of the HTTP response 50 * @deprecated Use `get_body_content()` method. 51 */ 64 52 public $body; 53 54 /** 55 * @var int Status code of the HTTP response 56 * @deprecated Use `get_status_code()` method. 57 */ 65 58 public $status_code = 0; 59 60 /** @var non-negative-int Number of redirect that were already performed during this request sequence. */ 66 61 public $redirects = 0; 62 63 /** @var ?string */ 67 64 public $error; 65 66 /** 67 * @var int-mask-of<SimplePie::FILE_SOURCE_*> Bit mask representing the method used to fetch the file and whether it is a local file or remote file obtained over HTTP. 68 * @deprecated Backend is implementation detail which you should not care about; to see if the file was retrieved over HTTP, check if `get_final_requested_uri()` with `Misc::is_remote_uri()`. 69 */ 68 70 public $method = \SimplePie\SimplePie::FILE_SOURCE_NONE; 71 72 /** 73 * @var string The permanent URL or the resource (first URL after the prefix of (only) permanent redirects) 74 * @deprecated Use `get_permanent_uri()` method. 75 */ 69 76 public $permanent_url; 70 71 public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false, $curl_options = []) 72 { 73 if (class_exists('idna_convert')) { 74 $idn = new \idna_convert(); 77 /** @var bool Whether the permanent URL is still writeable (prefix of permanent redirects has not ended) */ 78 private $permanentUrlMutable = true; 79 80 /** 81 * @param string $url 82 * @param int $timeout 83 * @param int $redirects 84 * @param ?array<string, string> $headers 85 * @param ?string $useragent 86 * @param bool $force_fsockopen 87 * @param array<int, mixed> $curl_options 88 */ 89 public function __construct(string $url, int $timeout = 10, int $redirects = 5, ?array $headers = null, ?string $useragent = null, bool $force_fsockopen = false, array $curl_options = []) 90 { 91 if (function_exists('idn_to_ascii')) { 75 92 $parsed = \SimplePie\Misc::parse_url($url); 76 $url = \SimplePie\Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], null); 93 if ($parsed['authority'] !== '' && !ctype_print($parsed['authority'])) { 94 $authority = (string) \idn_to_ascii($parsed['authority'], \IDNA_NONTRANSITIONAL_TO_ASCII, \INTL_IDNA_VARIANT_UTS46); 95 $url = \SimplePie\Misc::compress_parse_url($parsed['scheme'], $authority, $parsed['path'], $parsed['query'], null); 96 } 77 97 } 78 98 $this->url = $url; 79 $this->permanent_url = $url; 99 if ($this->permanentUrlMutable) { 100 $this->permanent_url = $url; 101 } 80 102 $this->useragent = $useragent; 81 103 if (preg_match('/^http(s)?:\/\//i', $url)) { 82 104 if ($useragent === null) { 83 $useragent = ini_get('user_agent');105 $useragent = (string) ini_get('user_agent'); 84 106 $this->useragent = $useragent; 85 107 } … … 94 116 $headers2[] = "$key: $value"; 95 117 } 118 if (isset($curl_options[CURLOPT_HTTPHEADER])) { 119 if (is_array($curl_options[CURLOPT_HTTPHEADER])) { 120 $headers2 = array_merge($headers2, $curl_options[CURLOPT_HTTPHEADER]); 121 } 122 unset($curl_options[CURLOPT_HTTPHEADER]); 123 } 96 124 if (version_compare(\SimplePie\Misc::get_curl_version(), '7.10.5', '>=')) { 97 125 curl_setopt($fp, CURLOPT_ENCODING, ''); … … 110 138 } 111 139 112 $ this->headers = curl_exec($fp);113 if (curl_errno($fp) === 23 || curl_errno($fp) === 61) {140 $responseHeaders = curl_exec($fp); 141 if (curl_errno($fp) === CURLE_WRITE_ERROR || curl_errno($fp) === CURLE_BAD_CONTENT_ENCODING) { 114 142 curl_setopt($fp, CURLOPT_ENCODING, 'none'); 115 $ this->headers = curl_exec($fp);143 $responseHeaders = curl_exec($fp); 116 144 } 117 145 $this->status_code = curl_getinfo($fp, CURLINFO_HTTP_CODE); … … 124 152 $this->url = $info['url']; 125 153 } 126 curl_close($fp); 127 $this->headers = \SimplePie\HTTP\Parser::prepareHeaders($this->headers, $info['redirect_count'] + 1); 128 $parser = new \SimplePie\HTTP\Parser($this->headers); 154 // For PHPStan: We already checked that error did not occur. 155 assert(is_array($info) && $info['redirect_count'] >= 0); 156 if (\PHP_VERSION_ID < 80000) { 157 curl_close($fp); 158 } 159 $responseHeaders = \SimplePie\HTTP\Parser::prepareHeaders((string) $responseHeaders, $info['redirect_count'] + 1); 160 $parser = new \SimplePie\HTTP\Parser($responseHeaders, true); 129 161 if ($parser->parse()) { 130 $this-> headers = $parser->headers;131 $this->body = trim($parser->body);162 $this->set_headers($parser->headers); 163 $this->body = $parser->body; 132 164 $this->status_code = $parser->status_code; 133 if ((in_array($this->status_code, [300, 301, 302, 303, 307]) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location'])&& $this->redirects < $redirects) {165 if ((in_array($this->status_code, [300, 301, 302, 303, 307]) || $this->status_code > 307 && $this->status_code < 400) && ($locationHeader = $this->get_header_line('location')) !== '' && $this->redirects < $redirects) { 134 166 $this->redirects++; 135 $location = \SimplePie\Misc::absolutize_url($this->headers['location'], $url); 136 $previousStatusCode = $this->status_code; 167 $location = \SimplePie\Misc::absolutize_url($locationHeader, $url); 168 if ($location === false) { 169 $this->error = "Invalid redirect location, trying to base “{$locationHeader}” onto “{$url}”"; 170 $this->success = false; 171 return; 172 } 173 $this->permanentUrlMutable = $this->permanentUrlMutable && ($this->status_code == 301 || $this->status_code == 308); 137 174 $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen, $curl_options); 138 $this->permanent_url = ($previousStatusCode == 301) ? $location : $url;139 175 return; 140 176 } … … 143 179 } else { 144 180 $this->method = \SimplePie\SimplePie::FILE_SOURCE_REMOTE | \SimplePie\SimplePie::FILE_SOURCE_FSOCKOPEN; 145 $url_parts = parse_url($url); 181 if (($url_parts = parse_url($url)) === false) { 182 throw new \InvalidArgumentException('Malformed URL: ' . $url); 183 } 184 if (!isset($url_parts['host'])) { 185 throw new \InvalidArgumentException('Missing hostname: ' . $url); 186 } 146 187 $socket_host = $url_parts['host']; 147 188 if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') { 148 $socket_host = "ssl://$url_parts[host]";189 $socket_host = 'ssl://' . $socket_host; 149 190 $url_parts['port'] = 443; 150 191 } … … 185 226 $info = stream_get_meta_data($fp); 186 227 187 $ this->headers = '';228 $responseHeaders = ''; 188 229 while (!$info['eof'] && !$info['timed_out']) { 189 $ this->headers .= fread($fp, 1160);230 $responseHeaders .= fread($fp, 1160); 190 231 $info = stream_get_meta_data($fp); 191 232 } 192 233 if (!$info['timed_out']) { 193 $parser = new \SimplePie\HTTP\Parser($ this->headers);234 $parser = new \SimplePie\HTTP\Parser($responseHeaders, true); 194 235 if ($parser->parse()) { 195 $this-> headers = $parser->headers;236 $this->set_headers($parser->headers); 196 237 $this->body = $parser->body; 197 238 $this->status_code = $parser->status_code; 198 if ((in_array($this->status_code, [300, 301, 302, 303, 307]) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location'])&& $this->redirects < $redirects) {239 if ((in_array($this->status_code, [300, 301, 302, 303, 307]) || $this->status_code > 307 && $this->status_code < 400) && ($locationHeader = $this->get_header_line('location')) !== '' && $this->redirects < $redirects) { 199 240 $this->redirects++; 200 $location = \SimplePie\Misc::absolutize_url($this->headers['location'], $url); 201 $previousStatusCode = $this->status_code; 241 $location = \SimplePie\Misc::absolutize_url($locationHeader, $url); 242 $this->permanentUrlMutable = $this->permanentUrlMutable && ($this->status_code == 301 || $this->status_code == 308); 243 if ($location === false) { 244 $this->error = "Invalid redirect location, trying to base “{$locationHeader}” onto “{$url}”"; 245 $this->success = false; 246 return; 247 } 202 248 $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen, $curl_options); 203 $this->permanent_url = ($previousStatusCode == 301) ? $location : $url;204 249 return; 205 250 } 206 if ( isset($this->headers['content-encoding'])) {251 if (($contentEncodingHeader = $this->get_header_line('content-encoding')) !== '') { 207 252 // Hey, we act dumb elsewhere, so let's do that here too 208 switch (strtolower(trim($ this->headers['content-encoding'], "\x09\x0A\x0D\x20"))) {253 switch (strtolower(trim($contentEncodingHeader, "\x09\x0A\x0D\x20"))) { 209 254 case 'gzip': 210 255 case 'x-gzip': 211 $decoder = new \SimplePie\Gzdecode($this->body); 212 if (!$decoder->parse()) { 256 if (($decompressed = gzdecode($this->body)) === false) { 213 257 $this->error = 'Unable to decode HTTP "gzip" stream'; 214 258 $this->success = false; 215 259 } else { 216 $this->body = trim($decoder->data);260 $this->body = $decompressed; 217 261 } 218 262 break; … … 223 267 } elseif (($decompressed = gzuncompress($this->body)) !== false) { 224 268 $this->body = $decompressed; 225 } elseif ( function_exists('gzdecode') &&($decompressed = gzdecode($this->body)) !== false) {269 } elseif (($decompressed = gzdecode($this->body)) !== false) { 226 270 $this->body = $decompressed; 227 271 } else { … … 246 290 } else { 247 291 $this->method = \SimplePie\SimplePie::FILE_SOURCE_LOCAL | \SimplePie\SimplePie::FILE_SOURCE_FILE_GET_CONTENTS; 248 if (empty($url) || !($this->body = trim(file_get_contents($url)))) { 249 $this->error = 'file_get_contents could not read the file'; 292 if (empty($url) || !is_readable($url) || false === $filebody = file_get_contents($url)) { 293 $this->body = ''; 294 $this->error = sprintf('file "%s" is not readable', $url); 250 295 $this->success = false; 296 } else { 297 $this->body = $filebody; 298 $this->status_code = 200; 251 299 } 252 300 } 301 if ($this->success) { 302 assert($this->body !== null); // For PHPStan 303 // Leading whitespace may cause XML parsing errors (XML declaration cannot be preceded by anything other than BOM) so we trim it. 304 // Note that unlike built-in `trim` function’s default settings, we do not trim `\x00` to avoid breaking characters in UTF-16 or UTF-32 encoded strings. 305 // We also only do that when the whitespace is followed by `<`, so that we do not break e.g. UTF-16LE encoded whitespace like `\n\x00` in half. 306 $this->body = preg_replace('/^[ \n\r\t\v]+</', '<', $this->body); 307 } 308 } 309 310 public function get_permanent_uri(): string 311 { 312 return (string) $this->permanent_url; 313 } 314 315 public function get_final_requested_uri(): string 316 { 317 return (string) $this->url; 318 } 319 320 public function get_status_code(): int 321 { 322 return (int) $this->status_code; 323 } 324 325 public function get_headers(): array 326 { 327 $this->maybe_update_headers(); 328 return $this->parsed_headers; 329 } 330 331 public function has_header(string $name): bool 332 { 333 $this->maybe_update_headers(); 334 return $this->get_header($name) !== []; 335 } 336 337 public function get_header(string $name): array 338 { 339 $this->maybe_update_headers(); 340 return $this->parsed_headers[strtolower($name)] ?? []; 341 } 342 343 public function with_header(string $name, $value) 344 { 345 $this->maybe_update_headers(); 346 $new = clone $this; 347 348 $newHeader = [ 349 strtolower($name) => (array) $value, 350 ]; 351 $new->set_headers($newHeader + $this->get_headers()); 352 353 return $new; 354 } 355 356 public function get_header_line(string $name): string 357 { 358 $this->maybe_update_headers(); 359 return implode(', ', $this->get_header($name)); 360 } 361 362 public function get_body_content(): string 363 { 364 return (string) $this->body; 365 } 366 367 /** 368 * Check if the $headers property was changed and update the internal state accordingly. 369 */ 370 private function maybe_update_headers(): void 371 { 372 if ($this->headers !== $this->last_headers) { 373 $this->parsed_headers = array_map( 374 function (string $header_line): array { 375 if (strpos($header_line, ',') === false) { 376 return [$header_line]; 377 } else { 378 return array_map('trim', explode(',', $header_line)); 379 } 380 }, 381 $this->headers 382 ); 383 } 384 $this->last_headers = $this->headers; 385 } 386 387 /** 388 * Sets headers internally. 389 * 390 * @param array<string, non-empty-array<string>> $headers 391 */ 392 private function set_headers(array $headers): void 393 { 394 $this->parsed_headers = $headers; 395 $this->headers = self::flatten_headers($headers); 396 $this->last_headers = $this->headers; 397 } 398 399 /** 400 * Converts PSR-7 compatible headers into a legacy format. 401 * 402 * @param array<string, non-empty-array<string>> $headers 403 * 404 * @return array<string, string> 405 */ 406 private function flatten_headers(array $headers): array 407 { 408 return array_map(function (array $values): string { 409 return implode(',', $values); 410 }, $headers); 411 } 412 413 /** 414 * Create a File instance from another Response 415 * 416 * For BC reasons in some places there MUST be a `File` instance 417 * instead of a `Response` implementation 418 * 419 * @see Locator::__construct() 420 * @internal 421 */ 422 final public static function fromResponse(Response $response): self 423 { 424 $headers = []; 425 426 foreach ($response->get_headers() as $name => $header) { 427 $headers[$name] = implode(', ', $header); 428 } 429 430 /** @var File */ 431 $file = (new \ReflectionClass(File::class))->newInstanceWithoutConstructor(); 432 433 $file->url = $response->get_final_requested_uri(); 434 $file->useragent = null; 435 $file->headers = $headers; 436 $file->body = $response->get_body_content(); 437 $file->status_code = $response->get_status_code(); 438 $file->permanent_url = $response->get_permanent_uri(); 439 440 return $file; 253 441 } 254 442 } -
trunk/src/wp-includes/SimplePie/src/Gzdecode.php
r59142 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; … … 48 11 * Decode 'gzip' encoded HTTP data 49 12 * 50 * @package SimplePie51 * @subpackage HTTP52 13 * @link http://www.gzip.org/format.txt 14 * @link https://www.php.net/manual/en/function.gzdecode.php 15 * @deprecated since SimplePie 1.9.0, use `gzdecode` function instead. 53 16 */ 54 17 class Gzdecode … … 180 143 * @param mixed $value 181 144 */ 182 public function __set( $name, $value)145 public function __set(string $name, $value) 183 146 { 184 147 throw new Exception("Cannot write property $name"); … … 190 153 * @param string $data 191 154 */ 192 public function __construct( $data)155 public function __construct(string $data) 193 156 { 194 157 $this->compressed_data = $data; … … 225 188 $mtime = substr($this->compressed_data, $this->position, 4); 226 189 // Reverse the string if we're on a big-endian arch because l is the only signed long and is machine endianness 227 if (current( unpack('S', "\x00\x01")) === 1) {190 if (current((array) unpack('S', "\x00\x01")) === 1) { 228 191 $mtime = strrev($mtime); 229 192 } 230 $this->MTIME = current( unpack('l', $mtime));193 $this->MTIME = current((array) unpack('l', $mtime)); 231 194 $this->position += 4; 232 195 … … 249 212 250 213 // Get the length of the extra field 251 $len = current( unpack('v', substr($this->compressed_data, $this->position, 2)));214 $len = current((array) unpack('v', substr($this->compressed_data, $this->position, 2))); 252 215 $this->position += 2; 253 216 … … 301 264 if ($this->compressed_size >= $this->min_compressed_size) { 302 265 // Read the CRC 303 $crc = current( unpack('v', substr($this->compressed_data, $this->position, 2)));266 $crc = current((array) unpack('v', substr($this->compressed_data, $this->position, 2))); 304 267 305 268 // Check the CRC matches … … 315 278 316 279 // Decompress the actual data 317 if (($this->data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false) { 318 return false; 319 } 320 280 if (($data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false) { 281 return false; 282 } 283 284 $this->data = $data; 321 285 $this->position = $this->compressed_size - 8; 322 286 323 287 // Check CRC of data 324 $crc = current( unpack('V', substr($this->compressed_data, $this->position, 4)));288 $crc = current((array) unpack('V', substr($this->compressed_data, $this->position, 4))); 325 289 $this->position += 4; 326 290 /*if (extension_loaded('hash') && sprintf('%u', current(unpack('V', hash('crc32b', $this->data)))) !== sprintf('%u', $crc)) … … 330 294 331 295 // Check ISIZE of data 332 $isize = current( unpack('V', substr($this->compressed_data, $this->position, 4)));296 $isize = current((array) unpack('V', substr($this->compressed_data, $this->position, 4))); 333 297 $this->position += 4; 334 298 if (sprintf('%u', strlen($this->data) & 0xFFFFFFFF) !== sprintf('%u', $isize)) { -
trunk/src/wp-includes/SimplePie/src/HTTP/Parser.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\HTTP; … … 47 10 /** 48 11 * HTTP Response Parser 49 * 50 * @package SimplePie 51 * @subpackage HTTP 12 * @template Psr7Compatible of bool 52 13 */ 53 14 class Parser … … 75 36 76 37 /** 38 * @var Psr7Compatible whether headers are compatible with PSR-7 format. 39 */ 40 private $psr7Compatible; 41 42 /** 77 43 * Key/value pairs of the headers 78 44 * 79 * @var array45 * @var (Psr7Compatible is true ? array<string, non-empty-array<string>> : array<string, string>) 80 46 */ 81 47 public $headers = []; … … 145 111 146 112 /** 147 * Name of the he daer currently being parsed113 * Name of the header currently being parsed 148 114 * 149 115 * @var string … … 152 118 153 119 /** 154 * Value of the he daer currently being parsed120 * Value of the header currently being parsed 155 121 * 156 122 * @var string … … 162 128 * 163 129 * @param string $data Input data 164 */ 165 public function __construct($data) 130 * @param Psr7Compatible $psr7Compatible Whether the data types are in format compatible with PSR-7. 131 */ 132 public function __construct(string $data, bool $psr7Compatible = false) 166 133 { 167 134 $this->data = $data; 168 135 $this->data_length = strlen($this->data); 136 $this->psr7Compatible = $psr7Compatible; 169 137 } 170 138 … … 185 153 } 186 154 187 $this->http_version = ''; 155 // Reset the parser state. 156 $this->http_version = 0.0; 188 157 $this->status_code = 0; 189 158 $this->reason = ''; … … 219 188 /** 220 189 * Parse the HTTP version 190 * @return void 221 191 */ 222 192 protected function http_version() … … 224 194 if (strpos($this->data, "\x0A") !== false && strtoupper(substr($this->data, 0, 5)) === 'HTTP/') { 225 195 $len = strspn($this->data, '0123456789.', 5); 226 $ this->http_version = substr($this->data, 5, $len);196 $http_version = substr($this->data, 5, $len); 227 197 $this->position += 5 + $len; 228 if (substr_count($ this->http_version, '.') <= 1) {229 $this->http_version = (float) $ this->http_version;198 if (substr_count($http_version, '.') <= 1) { 199 $this->http_version = (float) $http_version; 230 200 $this->position += strspn($this->data, "\x09\x20", $this->position); 231 201 $this->state = self::STATE_STATUS; … … 240 210 /** 241 211 * Parse the status code 212 * @return void 242 213 */ 243 214 protected function status() … … 254 225 /** 255 226 * Parse the reason phrase 227 * @return void 256 228 */ 257 229 protected function reason() … … 263 235 } 264 236 237 private function add_header(string $name, string $value): void 238 { 239 if ($this->psr7Compatible) { 240 // For PHPStan: should be enforced by template parameter but PHPStan is not smart enough. 241 /** @var array<string, non-empty-array<string>> */ 242 $headers = &$this->headers; 243 $headers[$name][] = $value; 244 } else { 245 // For PHPStan: should be enforced by template parameter but PHPStan is not smart enough. 246 /** @var array<string, string>) */ 247 $headers = &$this->headers; 248 $headers[$name] .= ', ' . $value; 249 } 250 } 251 252 private function replace_header(string $name, string $value): void 253 { 254 if ($this->psr7Compatible) { 255 // For PHPStan: should be enforced by template parameter but PHPStan is not smart enough. 256 /** @var array<string, non-empty-array<string>> */ 257 $headers = &$this->headers; 258 $headers[$name] = [$value]; 259 } else { 260 // For PHPStan: should be enforced by template parameter but PHPStan is not smart enough. 261 /** @var array<string, string>) */ 262 $headers = &$this->headers; 263 $headers[$name] = $value; 264 } 265 } 266 265 267 /** 266 268 * Deal with a new line, shifting data around as needed 269 * @return void 267 270 */ 268 271 protected function new_line() … … 273 276 // We should only use the last Content-Type header. c.f. issue #1 274 277 if (isset($this->headers[$this->name]) && $this->name !== 'content-type') { 275 $this-> headers[$this->name] .= ', ' . $this->value;278 $this->add_header($this->name, $this->value); 276 279 } else { 277 $this-> headers[$this->name] = $this->value;280 $this->replace_header($this->name, $this->value); 278 281 } 279 282 } … … 293 296 /** 294 297 * Parse a header name 298 * @return void 295 299 */ 296 300 protected function name() … … 313 317 /** 314 318 * Parse LWS, replacing consecutive LWS characters with a single space 319 * @return void 315 320 */ 316 321 protected function linear_whitespace() … … 329 334 /** 330 335 * See what state to move to while within non-quoted header values 336 * @return void 331 337 */ 332 338 protected function value() … … 363 369 /** 364 370 * Parse a header value while outside quotes 371 * @return void 365 372 */ 366 373 protected function value_char() … … 374 381 /** 375 382 * See what state to move to while within quoted header values 383 * @return void 376 384 */ 377 385 protected function quote() … … 405 413 /** 406 414 * Parse a header value while within quotes 415 * @return void 407 416 */ 408 417 protected function quote_char() … … 416 425 /** 417 426 * Parse an escaped character within quotes 427 * @return void 418 428 */ 419 429 protected function quote_escaped() … … 426 436 /** 427 437 * Parse the body 438 * @return void 428 439 */ 429 440 protected function body() … … 440 451 /** 441 452 * Parsed a "Transfer-Encoding: chunked" body 453 * @return void 442 454 */ 443 455 protected function chunked() … … 460 472 461 473 $length = hexdec(trim($matches[1])); 474 // For PHPStan: this will only be float when larger than PHP_INT_MAX. 475 // But even on 32-bit systems, it would mean 2GiB chunk, which sounds unlikely. 476 \assert(\is_int($length), "Length needs to be shorter than PHP_INT_MAX"); 462 477 if ($length === 0) { 463 478 // Ignore trailer headers … … 486 501 * 487 502 * @param string $headers Raw headers 488 * @param integer $countRedirection count. Default to 1.503 * @param non-negative-int $count Redirection count. Default to 1. 489 504 * 490 505 * @return string 491 506 */ 492 public static function prepareHeaders( $headers,$count = 1)507 public static function prepareHeaders(string $headers, int $count = 1) 493 508 { 494 509 $data = explode("\r\n\r\n", $headers, $count); -
trunk/src/wp-includes/SimplePie/src/IRI.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-FileCopyrightText: 2008 Steve Minutillo 5 // SPDX-License-Identifier: BSD-3-Clause 6 7 declare(strict_types=1); 44 8 45 9 namespace SimplePie; … … 48 12 * IRI parser/serialiser/normaliser 49 13 * 50 * @package SimplePie 51 * @subpackage HTTP 52 * @author Sam Sneddon 53 * @author Steve Minutillo 54 * @author Ryan McCue 55 * @copyright 2007-2012 Sam Sneddon, Steve Minutillo, Ryan McCue 56 * @license http://www.opensource.org/licenses/bsd-license.php 14 * @property ?string $scheme 15 * @property ?string $userinfo 16 * @property ?string $host 17 * @property ?int $port 18 * @property-write int|string|null $port 19 * @property ?string $authority 20 * @property string $path 21 * @property ?string $query 22 * @property ?string $fragment 57 23 */ 58 24 class IRI … … 61 27 * Scheme 62 28 * 29 * @var ?string 30 */ 31 protected $scheme = null; 32 33 /** 34 * User Information 35 * 36 * @var ?string 37 */ 38 protected $iuserinfo = null; 39 40 /** 41 * ihost 42 * 43 * @var ?string 44 */ 45 protected $ihost = null; 46 47 /** 48 * Port 49 * 50 * @var ?int 51 */ 52 protected $port = null; 53 54 /** 55 * ipath 56 * 63 57 * @var string 64 58 */ 65 protected $scheme = null;66 67 /**68 * User Information69 *70 * @var string71 */72 protected $iuserinfo = null;73 74 /**75 * ihost76 *77 * @var string78 */79 protected $ihost = null;80 81 /**82 * Port83 *84 * @var string85 */86 protected $port = null;87 88 /**89 * ipath90 *91 * @var string92 */93 59 protected $ipath = ''; 94 60 … … 96 62 * iquery 97 63 * 98 * @var string64 * @var ?string 99 65 */ 100 66 protected $iquery = null; … … 103 69 * ifragment 104 70 * 105 * @var string71 * @var ?string 106 72 */ 107 73 protected $ifragment = null; … … 112 78 * Each key is the scheme, each value is an array with each key as the IRI 113 79 * part and value as the default value for that part. 80 * 81 * @var array<string, array<string, mixed>> 114 82 */ 115 83 protected $normalization = [ … … 140 108 public function __toString() 141 109 { 142 return $this->get_iri();110 return (string) $this->get_iri(); 143 111 } 144 112 … … 148 116 * @param string $name Property name 149 117 * @param mixed $value Property value 150 */ 151 public function __set($name, $value) 152 { 153 if (method_exists($this, 'set_' . $name)) { 154 call_user_func([$this, 'set_' . $name], $value); 118 * @return void 119 */ 120 public function __set(string $name, $value) 121 { 122 $callable = [$this, 'set_' . $name]; 123 if (is_callable($callable)) { 124 call_user_func($callable, $value); 155 125 } elseif ( 156 126 $name === 'iauthority' … … 171 141 * @return mixed 172 142 */ 173 public function __get( $name)143 public function __get(string $name) 174 144 { 175 145 // isset() returns false for null, we don't want to do that … … 188 158 } 189 159 // host -> ihost 190 elseif ( ($prop = 'i' . $name) && array_key_exists($prop, $props)) {160 elseif (array_key_exists($prop = 'i' . $name, $props)) { 191 161 $name = $prop; 192 162 $return = $this->$prop; … … 214 184 * @return bool 215 185 */ 216 public function __isset( $name)186 public function __isset(string $name) 217 187 { 218 188 return method_exists($this, 'get_' . $name) || isset($this->$name); … … 223 193 * 224 194 * @param string $name Property name 225 */ 226 public function __unset($name) 227 { 228 if (method_exists($this, 'set_' . $name)) { 229 call_user_func([$this, 'set_' . $name], ''); 195 * @return void 196 */ 197 public function __unset(string $name) 198 { 199 $callable = [$this, 'set_' . $name]; 200 if (is_callable($callable)) { 201 call_user_func($callable, ''); 230 202 } 231 203 } … … 234 206 * Create a new IRI object, from a specified string 235 207 * 236 * @param string $iri237 */ 238 public function __construct( $iri = null)208 * @param string|null $iri 209 */ 210 public function __construct(?string $iri = null) 239 211 { 240 212 $this->set_iri($iri); … … 243 215 /** 244 216 * Clean up 217 * @return void 245 218 */ 246 219 public function __destruct() … … 322 295 * 323 296 * @param string $iri 324 * @return array 325 */ 326 protected function parse_iri($iri) 297 * @return array{ 298 * scheme: string|null, 299 * authority: string|null, 300 * path: string, 301 * query: string|null, 302 * fragment: string|null, 303 * }|false 304 */ 305 protected function parse_iri(string $iri) 327 306 { 328 307 $iri = trim($iri, "\x20\x09\x0A\x0C\x0D"); 329 if (preg_match('/^((?P<scheme>[^:\/?#]+):)?(\/\/(?P<authority>[^\/?#]*))?(?P<path>[^?#]*)(\?(?P<query>[^#]*))?(#(?P<fragment>.*))?$/', $iri, $match)) { 330 if ($match[1] === '') { 331 $match['scheme'] = null; 332 } 333 if (!isset($match[3]) || $match[3] === '') { 334 $match['authority'] = null; 335 } 336 if (!isset($match[5])) { 337 $match['path'] = ''; 338 } 339 if (!isset($match[6]) || $match[6] === '') { 340 $match['query'] = null; 341 } 342 if (!isset($match[8]) || $match[8] === '') { 343 $match['fragment'] = null; 344 } 308 if (preg_match('/^(?:(?P<scheme>[^:\/?#]+):)?(:?\/\/(?P<authority>[^\/?#]*))?(?P<path>[^?#]*)(?:\?(?P<query>[^#]*))?(?:#(?P<fragment>.*))?$/', $iri, $match, \PREG_UNMATCHED_AS_NULL)) { 309 // TODO: Remove once we require PHP ≥ 7.4. 310 $match['query'] = $match['query'] ?? null; 311 $match['fragment'] = $match['fragment'] ?? null; 345 312 return $match; 346 313 } … … 356 323 * @return string 357 324 */ 358 protected function remove_dot_segments( $input)325 protected function remove_dot_segments(string $input) 359 326 { 360 327 $output = ''; … … 405 372 * @return string 406 373 */ 407 protected function replace_invalid_with_pct_encoding( $string, $extra_chars,$iprivate = false)374 protected function replace_invalid_with_pct_encoding(string $string, string $extra_chars, bool $iprivate = false) 408 375 { 409 376 // Normalize as many pct-encoded sections as possible 410 377 $string = preg_replace_callback('/(?:%[A-Fa-f0-9]{2})+/', [$this, 'remove_iunreserved_percent_encoded'], $string); 378 \assert(\is_string($string), "For PHPStan: Should not occur, the regex is valid"); 411 379 412 380 // Replace invalid percent characters 413 381 $string = preg_replace('/%(?![A-Fa-f0-9]{2})/', '%25', $string); 382 \assert(\is_string($string), "For PHPStan: Should not occur, the regex is valid"); 414 383 415 384 // Add unreserved and % to $extra_chars (the latter is safe because all … … 526 495 * encoded characters in iunreserved 527 496 * 528 * @param array $match PCRE match497 * @param array{string} $match PCRE match, a capture group #0 consisting of a sequence of valid percent-encoded bytes 529 498 * @return string Replacement 530 499 */ 531 protected function remove_iunreserved_percent_encoded( $match)500 protected function remove_iunreserved_percent_encoded(array $match) 532 501 { 533 502 // As we just have valid percent encoded sequences we can just explode … … 632 601 } else { 633 602 for ($j = $start; $j <= $i; $j++) { 634 $string .= chr(hexdec($bytes[$j])); 603 // Cast for PHPStan, this will always be a number between 0 and 0xFF so hexdec will return int. 604 $string .= chr((int) hexdec($bytes[$j])); 635 605 } 636 606 } … … 649 619 } 650 620 621 /** 622 * @return void 623 */ 651 624 protected function scheme_normalization() 652 625 { … … 709 682 * are any invalid characters). 710 683 * 711 * @param string $iri684 * @param string|null $iri 712 685 * @return bool 713 686 */ 714 public function set_iri( $iri,$clear_cache = false)687 public function set_iri(?string $iri, bool $clear_cache = false) 715 688 { 716 689 static $cache; 717 690 if ($clear_cache) { 718 691 $cache = null; 719 return ;692 return false; 720 693 } 721 694 if (!$cache) { … … 769 742 * any invalid characters). 770 743 * 771 * @param string $scheme744 * @param string|null $scheme 772 745 * @return bool 773 746 */ 774 public function set_scheme( $scheme)747 public function set_scheme(?string $scheme) 775 748 { 776 749 if ($scheme === null) { … … 789 762 * any invalid characters). 790 763 * 791 * @param string $authority764 * @param string|null $authority 792 765 * @return bool 793 766 */ 794 public function set_authority( $authority,$clear_cache = false)767 public function set_authority(?string $authority, bool $clear_cache = false) 795 768 { 796 769 static $cache; 797 770 if ($clear_cache) { 798 771 $cache = null; 799 return ;772 return false; 800 773 } 801 774 if (!$cache) { … … 821 794 $remaining = $authority; 822 795 if (($iuserinfo_end = strrpos($remaining, '@')) !== false) { 823 $iuserinfo = substr($remaining, 0, $iuserinfo_end); 796 // Cast for PHPStan on PHP < 8.0. It does not detect that 797 // the range is not flipped so substr cannot return false. 798 $iuserinfo = (string) substr($remaining, 0, $iuserinfo_end); 824 799 $remaining = substr($remaining, $iuserinfo_end + 1); 825 800 } else { … … 827 802 } 828 803 if (($port_start = strpos($remaining, ':', intval(strpos($remaining, ']')))) !== false) { 829 if (($port = substr($remaining, $port_start + 1)) === false) { 804 $port = substr($remaining, $port_start + 1); 805 if ($port === false) { 830 806 $port = null; 831 807 } … … 852 828 * Set the iuserinfo. 853 829 * 854 * @param string $iuserinfo830 * @param string|null $iuserinfo 855 831 * @return bool 856 832 */ 857 public function set_userinfo( $iuserinfo)833 public function set_userinfo(?string $iuserinfo) 858 834 { 859 835 if ($iuserinfo === null) { … … 871 847 * any invalid characters). 872 848 * 873 * @param string $ihost849 * @param string|null $ihost 874 850 * @return bool 875 851 */ 876 public function set_host( $ihost)852 public function set_host(?string $ihost) 877 853 { 878 854 if ($ihost === null) { … … 915 891 * any invalid characters). 916 892 * 917 * @param string $port893 * @param string|int|null $port 918 894 * @return bool 919 895 */ … … 923 899 $this->port = null; 924 900 return true; 925 } elseif (strspn( $port, '0123456789') === strlen($port)) {901 } elseif (strspn((string) $port, '0123456789') === strlen((string) $port)) { 926 902 $this->port = (int) $port; 927 903 $this->scheme_normalization(); … … 936 912 * Set the ipath. 937 913 * 938 * @param string $ipath914 * @param string|null $ipath 939 915 * @return bool 940 916 */ 941 public function set_path( $ipath,$clear_cache = false)917 public function set_path(?string $ipath, bool $clear_cache = false) 942 918 { 943 919 static $cache; 944 920 if ($clear_cache) { 945 921 $cache = null; 946 return ;922 return false; 947 923 } 948 924 if (!$cache) { … … 969 945 * Set the iquery. 970 946 * 971 * @param string $iquery947 * @param string|null $iquery 972 948 * @return bool 973 949 */ 974 public function set_query( $iquery)950 public function set_query(?string $iquery) 975 951 { 976 952 if ($iquery === null) { … … 986 962 * Set the ifragment. 987 963 * 988 * @param string $ifragment964 * @param string|null $ifragment 989 965 * @return bool 990 966 */ 991 public function set_fragment( $ifragment)967 public function set_fragment(?string $ifragment) 992 968 { 993 969 if ($ifragment === null) { … … 1003 979 * Convert an IRI to a URI (or parts thereof) 1004 980 * 981 * @param string $string 1005 982 * @return string 1006 983 */ 1007 public function to_uri( $string)984 public function to_uri(string $string) 1008 985 { 1009 986 static $non_ascii; … … 1026 1003 * Get the complete IRI 1027 1004 * 1028 * @return string 1005 * @return string|false 1029 1006 */ 1030 1007 public function get_iri() … … 1063 1040 public function get_uri() 1064 1041 { 1065 return $this->to_uri( $this->get_iri());1042 return $this->to_uri((string) $this->get_iri()); 1066 1043 } 1067 1044 … … 1069 1046 * Get the complete iauthority 1070 1047 * 1071 * @return string1048 * @return ?string 1072 1049 */ 1073 1050 protected function get_iauthority() … … 1093 1070 * Get the complete authority 1094 1071 * 1095 * @return string1072 * @return ?string 1096 1073 */ 1097 1074 protected function get_authority() -
trunk/src/wp-includes/SimplePie/src/Item.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\SimplePie::set_item_class()} 53 *54 * @package \SimplePie\SimplePie55 * @subpackage API56 16 */ 57 17 class Item implements RegistryAware … … 69 29 * 70 30 * @access private 71 * @var array 31 * @var array<string, mixed> 72 32 */ 73 33 public $data = []; … … 82 42 83 43 /** 44 * @var Sanitize|null 45 */ 46 private $sanitize = null; 47 48 /** 84 49 * Create a new item object 85 50 * … … 88 53 * 89 54 * @param \SimplePie\SimplePie $feed Parent feed 90 * @param array $data Raw data91 */ 92 public function __construct( $feed,$data)55 * @param array<string, mixed> $data Raw data 56 */ 57 public function __construct(\SimplePie\SimplePie $feed, array $data) 93 58 { 94 59 $this->feed = $feed; … … 103 68 * @since 1.3 104 69 * @param \SimplePie\Registry $registry 105 */ 106 public function set_registry(\SimplePie\Registry $registry)/* : void */ 70 * @return void 71 */ 72 public function set_registry(\SimplePie\Registry $registry) 107 73 { 108 74 $this->registry = $registry; … … 141 107 * @param string $namespace The URL of the XML namespace of the elements you're trying to access 142 108 * @param string $tag Tag name 143 * @return array 144 */ 145 public function get_item_tags( $namespace,$tag)109 * @return array<array<string, mixed>>|null 110 */ 111 public function get_item_tags(string $namespace, string $tag) 146 112 { 147 113 if (isset($this->data['child'][$namespace][$tag])) { … … 153 119 154 120 /** 121 * Get base URL of the item itself. 122 * Returns `<xml:base>` or feed base URL. 123 * Similar to `Item::get_base()` but can safely be used during initialisation methods 124 * such as `Item::get_links()` (`Item::get_base()` and `Item::get_links()` call each-other) 125 * and is not affected by enclosures. 126 * 127 * @param array<string, mixed> $element 128 * @see get_base 129 */ 130 private function get_own_base(array $element = []): string 131 { 132 if (!empty($element['xml_base_explicit']) && isset($element['xml_base'])) { 133 return $element['xml_base']; 134 } 135 return $this->feed->get_base(); 136 } 137 138 /** 155 139 * Get the base URL value. 156 * Uses `<xml:base>`, or item link, or feed base URL.157 * 158 * @param array $element140 * Uses `<xml:base>`, or item link, or enclosure link, or feed base URL. 141 * 142 * @param array<string, mixed> $element 159 143 * @return string 160 144 */ 161 public function get_base( $element = [])145 public function get_base(array $element = []) 162 146 { 163 147 if (!empty($element['xml_base_explicit']) && isset($element['xml_base'])) { … … 177 161 * @see \SimplePie\SimplePie::sanitize() 178 162 * @param string $data Data to sanitize 179 * @param int $type One of the \SimplePie\SimplePie::CONSTRUCT_* constants163 * @param int-mask-of<SimplePie::CONSTRUCT_*> $type 180 164 * @param string $base Base URL to resolve URLs against 181 165 * @return string Sanitized data 182 166 */ 183 public function sanitize($data, $type, $base = '') 184 { 167 public function sanitize(string $data, int $type, string $base = '') 168 { 169 // This really returns string|false but changing encoding is uncommon and we are going to deprecate it, so let’s just lie to PHPStan in the interest of cleaner annotations. 185 170 return $this->feed->sanitize($data, $type, $base); 186 171 } … … 210 195 * 211 196 * @since Beta 2 212 * @param bool ean$hash Should we force using a hash instead of the supplied ID?197 * @param bool $hash Should we force using a hash instead of the supplied ID? 213 198 * @param string|false $fn User-supplied function to generate an hash 214 199 * @return string|null 215 200 */ 216 public function get_id( $hash = false, $fn = 'md5')201 public function get_id(bool $hash = false, $fn = 'md5') 217 202 { 218 203 if (!$hash) { … … 287 272 * 288 273 * @since 0.8 289 * @param bool ean$description_only Should we avoid falling back to the content?274 * @param bool $description_only Should we avoid falling back to the content? 290 275 * @return string|null 291 276 */ 292 public function get_description( $description_only = false)277 public function get_description(bool $description_only = false) 293 278 { 294 279 if (($tags = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'summary')) && … … 337 322 * 338 323 * @since 1.0 339 * @param bool ean$content_only Should we avoid falling back to the description?324 * @param bool $content_only Should we avoid falling back to the description? 340 325 * @return string|null 341 326 */ 342 public function get_content( $content_only = false)327 public function get_content(bool $content_only = false) 343 328 { 344 329 if (($tags = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'content')) && … … 364 349 * 365 350 * 366 * @return array |null351 * @return array{url: string, height?: string, width?: string, time?: string}|null 367 352 */ 368 353 public function get_thumbnail() … … 391 376 * @return \SimplePie\Category|null 392 377 */ 393 public function get_category( $key = 0)378 public function get_category(int $key = 0) 394 379 { 395 380 $categories = $this->get_categories(); … … 463 448 * @return \SimplePie\Author|null 464 449 */ 465 public function get_author( $key = 0)450 public function get_author(int $key = 0) 466 451 { 467 452 $authors = $this->get_authors(); … … 480 465 * @return \SimplePie\Author|null 481 466 */ 482 public function get_contributor( $key = 0)467 public function get_contributor(int $key = 0) 483 468 { 484 469 $contributors = $this->get_contributors(); … … 509 494 } 510 495 if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'])) { 511 $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])); 496 $uri = $contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]; 497 $uri = $this->sanitize($uri['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($uri)); 512 498 } 513 499 if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'])) { … … 526 512 } 527 513 if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'])) { 528 $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])); 514 $url = $contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]; 515 $url = $this->sanitize($url['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($url)); 529 516 } 530 517 if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'])) { … … 562 549 } 563 550 if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'])) { 564 $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])); 551 $uri = $author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]; 552 $uri = $this->sanitize($uri['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($uri)); 565 553 } 566 554 if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'])) { … … 579 567 } 580 568 if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'])) { 581 $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])); 569 $url = $author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]; 570 $url = $this->sanitize($url['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($url)); 582 571 } 583 572 if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'])) { … … 618 607 * 619 608 * @since 1.1 620 * @return string 609 * @return string|null 621 610 */ 622 611 public function get_copyright() … … 645 634 * 646 635 * @param string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data) 647 * @return int|string|null648 */ 649 public function get_date( $date_format = 'j F Y, g:i a')636 * @return ($date_format is 'U' ? ?int : ?string) 637 */ 638 public function get_date(string $date_format = 'j F Y, g:i a') 650 639 { 651 640 if (!isset($this->data['date'])) { … … 676 665 } 677 666 if ($this->data['date']) { 678 $date_format = (string) $date_format;679 667 switch ($date_format) { 680 668 case '': … … 701 689 * 702 690 * @param string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data) 703 * @return int|string|null704 */ 705 public function get_updated_date( $date_format = 'j F Y, g:i a')691 * @return ($date_format is 'U' ? ?int : ?string) 692 */ 693 public function get_updated_date(string $date_format = 'j F Y, g:i a') 706 694 { 707 695 if (!isset($this->data['updated'])) { … … 718 706 } 719 707 if ($this->data['updated']) { 720 $date_format = (string) $date_format;721 708 switch ($date_format) { 722 709 case '': … … 745 732 * 746 733 * @param string $date_format Supports any PHP date format from {@see http://php.net/strftime} (empty for the raw data) 747 * @return int|string|null 748 */ 749 public function get_local_date($date_format = '%c') 750 { 751 if (!$date_format) { 752 return $this->sanitize($this->get_date(''), \SimplePie\SimplePie::CONSTRUCT_TEXT); 734 * @return string|null|false see `strftime` for when this can return `false` 735 */ 736 public function get_local_date(string $date_format = '%c') 737 { 738 if ($date_format === '') { 739 if (($raw_date = $this->get_date('')) === null) { 740 return null; 741 } 742 743 return $this->sanitize($raw_date, \SimplePie\SimplePie::CONSTRUCT_TEXT); 753 744 } elseif (($date = $this->get_date('U')) !== null && $date !== false) { 754 745 return strftime($date_format, $date); … … 763 754 * @see get_date 764 755 * @param string $date_format Supports any PHP date format from {@see http://php.net/date} 765 * @return int|string|null766 */ 767 public function get_gmdate( $date_format = 'j F Y, g:i a')756 * @return string|null 757 */ 758 public function get_gmdate(string $date_format = 'j F Y, g:i a') 768 759 { 769 760 $date = $this->get_date('U'); … … 780 771 * @see get_updated_date 781 772 * @param string $date_format Supports any PHP date format from {@see http://php.net/date} 782 * @return int|string|null783 */ 784 public function get_updated_gmdate( $date_format = 'j F Y, g:i a')773 * @return string|null 774 */ 775 public function get_updated_gmdate(string $date_format = 'j F Y, g:i a') 785 776 { 786 777 $date = $this->get_updated_date('U'); … … 823 814 * @return string|null Link URL 824 815 */ 825 public function get_link( $key = 0,$rel = 'alternate')816 public function get_link(int $key = 0, string $rel = 'alternate') 826 817 { 827 818 $links = $this->get_links($rel); … … 840 831 * @since Beta 2 841 832 * @param string $rel The relationship of links to return 842 * @return array |null Links found for the item (strings)843 */ 844 public function get_links( $rel = 'alternate')833 * @return array<string>|null Links found for the item (strings) 834 */ 835 public function get_links(string $rel = 'alternate') 845 836 { 846 837 if (!isset($this->data['links'])) { … … 849 840 if (isset($link['attribs']['']['href'])) { 850 841 $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; 851 $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_ base($link));842 $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($link)); 852 843 } 853 844 } … … 855 846 if (isset($link['attribs']['']['href'])) { 856 847 $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; 857 $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_ base($link));848 $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($link)); 858 849 } 859 850 } 860 851 if ($links = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_10, 'link')) { 861 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_ base($links[0]));852 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($links[0])); 862 853 } 863 854 if ($links = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_090, 'link')) { 864 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_ base($links[0]));855 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($links[0])); 865 856 } 866 857 if ($links = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'link')) { 867 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_ base($links[0]));858 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($links[0])); 868 859 } 869 860 if ($links = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'guid')) { 870 861 if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true') { 871 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_ base($links[0]));862 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($links[0])); 872 863 } 873 864 } … … 882 873 $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] = &$this->data['links'][$key]; 883 874 } 884 } elseif (substr( $key, 0, 41) === \SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY) {885 $this->data['links'][substr( $key, 41)] = &$this->data['links'][$key];875 } elseif (substr((string) $key, 0, 41) === \SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY) { 876 $this->data['links'][substr((string) $key, 41)] = &$this->data['links'][$key]; 886 877 } 887 878 $this->data['links'][$key] = array_unique($this->data['links'][$key]); … … 905 896 * @return \SimplePie\Enclosure|null 906 897 */ 907 public function get_enclosure( $key = 0, $prefer = null)898 public function get_enclosure(int $key = 0) 908 899 { 909 900 $enclosures = $this->get_enclosures(); … … 945 936 $player_parent = null; 946 937 $ratings_parent = null; 947 $restrictions_parent = null;938 $restrictions_parent = []; 948 939 $thumbnails_parent = null; 949 940 $title_parent = null; … … 1140 1131 1141 1132 // DURATION 1142 if ($duration_parent = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'duration')) { 1133 $duration_tags = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'duration'); 1134 if ($duration_tags !== null) { 1143 1135 $seconds = null; 1144 1136 $minutes = null; 1145 1137 $hours = null; 1146 if (isset($duration_parent[0]['data'])) { 1147 $temp = explode(':', $this->sanitize($duration_parent[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT)); 1148 if (sizeof($temp) > 0) { 1149 $seconds = (int) array_pop($temp); 1150 } 1151 if (sizeof($temp) > 0) { 1138 if (isset($duration_tags[0]['data'])) { 1139 $temp = explode(':', $this->sanitize($duration_tags[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT)); 1140 $seconds = (int) array_pop($temp); 1141 if (count($temp) > 0) { 1152 1142 $minutes = (int) array_pop($temp); 1153 1143 $seconds += $minutes * 60; 1154 1144 } 1155 if ( sizeof($temp) > 0) {1145 if (count($temp) > 0) { 1156 1146 $hours = (int) array_pop($temp); 1157 1147 $seconds += $hours * 3600; … … 1237 1227 if ($player_parent = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_MEDIARSS, 'player')) { 1238 1228 if (isset($player_parent[0]['attribs']['']['url'])) { 1239 $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI );1229 $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($player_parent[0])); 1240 1230 } 1241 1231 } elseif ($player_parent = $parent->get_channel_tags(\SimplePie\SimplePie::NAMESPACE_MEDIARSS, 'player')) { 1242 1232 if (isset($player_parent[0]['attribs']['']['url'])) { 1243 $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI );1233 $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($player_parent[0])); 1244 1234 } 1245 1235 } … … 1316 1306 } elseif ($restrictions = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'block')) { 1317 1307 foreach ($restrictions as $restriction) { 1318 $restriction_relationship = 'allow';1308 $restriction_relationship = Restriction::RELATIONSHIP_ALLOW; 1319 1309 $restriction_type = null; 1320 1310 $restriction_value = 'itunes'; 1321 1311 if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') { 1322 $restriction_relationship = 'deny';1312 $restriction_relationship = Restriction::RELATIONSHIP_DENY; 1323 1313 } 1324 1314 $restrictions_parent[] = $this->registry->create(Restriction::class, [$restriction_relationship, $restriction_type, $restriction_value]); … … 1342 1332 } elseif ($restrictions = $parent->get_channel_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'block')) { 1343 1333 foreach ($restrictions as $restriction) { 1344 $restriction_relationship = 'allow';1334 $restriction_relationship = Restriction::RELATIONSHIP_ALLOW; 1345 1335 $restriction_type = null; 1346 1336 $restriction_value = 'itunes'; 1347 1337 if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') { 1348 $restriction_relationship = 'deny';1338 $restriction_relationship = Restriction::RELATIONSHIP_DENY; 1349 1339 } 1350 1340 $restrictions_parent[] = $this->registry->create(Restriction::class, [$restriction_relationship, $restriction_type, $restriction_value]); 1351 1341 } 1352 1342 } 1353 if ( is_array($restrictions_parent)) {1343 if (count($restrictions_parent) > 0) { 1354 1344 $restrictions_parent = array_values(array_unique($restrictions_parent)); 1355 1345 } else { 1356 $restrictions_parent = [new \SimplePie\Restriction( 'allow', null, 'default')];1346 $restrictions_parent = [new \SimplePie\Restriction(Restriction::RELATIONSHIP_ALLOW, null, 'default')]; 1357 1347 } 1358 1348 … … 1361 1351 foreach ($thumbnails as $thumbnail) { 1362 1352 if (isset($thumbnail['attribs']['']['url'])) { 1363 $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI );1353 $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($thumbnail)); 1364 1354 } 1365 1355 } … … 1367 1357 foreach ($thumbnails as $thumbnail) { 1368 1358 if (isset($thumbnail['attribs']['']['url'])) { 1369 $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI );1359 $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($thumbnail)); 1370 1360 } 1371 1361 } … … 1491 1481 $width = $this->sanitize($content['attribs']['']['width'], \SimplePie\SimplePie::CONSTRUCT_TEXT); 1492 1482 } 1493 $url = $this->sanitize($content['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI );1483 $url = $this->sanitize($content['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($content)); 1494 1484 1495 1485 // Checking the other optional media: elements. Priority: media:content, media:group, item, channel … … 1750 1740 // PLAYER 1751 1741 if (isset($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'])) { 1752 $player = $this->sanitize($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI); 1742 $playerElem = $content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0]; 1743 $player = $this->sanitize($playerElem['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($playerElem)); 1753 1744 } elseif (isset($group['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'])) { 1754 $player = $this->sanitize($group['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI); 1745 $playerElem = $group['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0]; 1746 $player = $this->sanitize($playerElem['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($playerElem)); 1755 1747 } else { 1756 1748 $player = $player_parent; … … 1842 1834 if (isset($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['thumbnail'])) { 1843 1835 foreach ($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) { 1844 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI );1836 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($thumbnail)); 1845 1837 } 1846 1838 if (is_array($thumbnails)) { … … 1849 1841 } elseif (isset($group['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['thumbnail'])) { 1850 1842 foreach ($group['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) { 1851 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI );1843 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($thumbnail)); 1852 1844 } 1853 1845 if (is_array($thumbnails)) { … … 1947 1939 } 1948 1940 if (isset($content['attribs']['']['url'])) { 1949 $url = $this->sanitize($content['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI );1941 $url = $this->sanitize($content['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($content)); 1950 1942 } 1951 1943 // Checking the other optional media: elements. Priority: media:content, media:group, item, channel … … 2102 2094 if (isset($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'])) { 2103 2095 if (isset($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'])) { 2104 $player = $this->sanitize($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI); 2096 $playerElem = $content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0]; 2097 $player = $this->sanitize($playerElem['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($playerElem)); 2105 2098 } 2106 2099 } else { … … 2158 2151 foreach ($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) { 2159 2152 if (isset($thumbnail['attribs']['']['url'])) { 2160 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI );2153 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($thumbnail)); 2161 2154 } 2162 2155 } … … 2198 2191 $width = null; 2199 2192 2200 $url = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_ base($link));2193 $url = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($link)); 2201 2194 if (isset($link['attribs']['']['type'])) { 2202 2195 $type = $this->sanitize($link['attribs']['']['type'], \SimplePie\SimplePie::CONSTRUCT_TEXT); … … 2234 2227 $width = null; 2235 2228 2236 $url = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_ base($link));2229 $url = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($link)); 2237 2230 if (isset($link['attribs']['']['type'])) { 2238 2231 $type = $this->sanitize($link['attribs']['']['type'], \SimplePie\SimplePie::CONSTRUCT_TEXT); … … 2265 2258 $width = null; 2266 2259 2267 $url = $this->sanitize($enclosure['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_ base($enclosure));2268 $url = $this-> feed->sanitize->https_url($url);2260 $url = $this->sanitize($enclosure['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($enclosure)); 2261 $url = $this->get_sanitize()->https_url($url); 2269 2262 if (isset($enclosure['attribs']['']['type'])) { 2270 2263 $type = $this->sanitize($enclosure['attribs']['']['type'], \SimplePie\SimplePie::CONSTRUCT_TEXT); … … 2279 2272 } 2280 2273 2281 if ( sizeof($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width)) {2274 if (count($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $samplingrate || $thumbnails_parent || $title_parent || $width)) { 2282 2275 // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor 2283 2276 $this->data['enclosures'][] = $this->registry->create(Enclosure::class, [$url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width]); … … 2303 2296 * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo 2304 2297 * @link http://www.georss.org/ GeoRSS 2305 * @return string|null2298 * @return float|null 2306 2299 */ 2307 2300 public function get_latitude() … … 2326 2319 * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo 2327 2320 * @link http://www.georss.org/ GeoRSS 2328 * @return string|null2321 * @return float|null 2329 2322 */ 2330 2323 public function get_longitude() … … 2355 2348 return null; 2356 2349 } 2350 2351 public function set_sanitize(Sanitize $sanitize): void 2352 { 2353 $this->sanitize = $sanitize; 2354 } 2355 2356 protected function get_sanitize(): Sanitize 2357 { 2358 if ($this->sanitize === null) { 2359 $this->sanitize = new Sanitize(); 2360 } 2361 2362 return $this->sanitize; 2363 } 2357 2364 } 2358 2365 -
trunk/src/wp-includes/SimplePie/src/Locator.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; 9 10 use DomDocument; 11 use Psr\Http\Client\ClientInterface; 12 use Psr\Http\Message\RequestFactoryInterface; 13 use Psr\Http\Message\UriFactoryInterface; 14 use SimplePie\HTTP\Client; 15 use SimplePie\HTTP\ClientException; 16 use SimplePie\HTTP\FileClient; 17 use SimplePie\HTTP\Psr18Client; 18 use SimplePie\HTTP\Response; 46 19 47 20 /** … … 50 23 * 51 24 * This class can be overloaded with {@see \SimplePie\SimplePie::set_locator_class()} 52 *53 * @package SimplePie54 25 */ 55 26 class Locator implements RegistryAware 56 27 { 57 public $useragent; 58 public $timeout; 28 /** @var ?string */ 29 public $useragent = null; 30 /** @var int */ 31 public $timeout = 10; 32 /** @var File */ 59 33 public $file; 34 /** @var string[] */ 60 35 public $local = []; 36 /** @var string[] */ 61 37 public $elsewhere = []; 38 /** @var array<mixed> */ 62 39 public $cached_entities = []; 40 /** @var string */ 63 41 public $http_base; 42 /** @var string */ 64 43 public $base; 44 /** @var int */ 65 45 public $base_location = 0; 46 /** @var int */ 66 47 public $checked_feeds = 0; 48 /** @var int */ 67 49 public $max_checked_feeds = 10; 50 /** @var bool */ 68 51 public $force_fsockopen = false; 52 /** @var array<int, mixed> */ 69 53 public $curl_options = []; 54 /** @var ?\DomDocument */ 70 55 public $dom; 56 /** @var ?Registry */ 71 57 protected $registry; 72 58 73 public function __construct(\SimplePie\File $file, $timeout = 10, $useragent = null, $max_checked_feeds = 10, $force_fsockopen = false, $curl_options = []) 59 /** 60 * @var Client|null 61 */ 62 private $http_client = null; 63 64 /** 65 * @param array<int, mixed> $curl_options 66 */ 67 public function __construct(File $file, int $timeout = 10, ?string $useragent = null, int $max_checked_feeds = 10, bool $force_fsockopen = false, array $curl_options = []) 74 68 { 75 69 $this->file = $file; … … 80 74 $this->curl_options = $curl_options; 81 75 82 if (class_exists('DOMDocument') && $this->file->body != '') { 76 $body = $this->file->get_body_content(); 77 78 if (class_exists('DOMDocument') && $body != '') { 83 79 $this->dom = new \DOMDocument(); 84 80 85 set_error_handler([ 'SimplePie\Misc', 'silence_errors']);81 set_error_handler([Misc::class, 'silence_errors']); 86 82 try { 87 $this->dom->loadHTML($ this->file->body);83 $this->dom->loadHTML($body); 88 84 } catch (\Throwable $ex) { 89 85 $this->dom = null; … … 95 91 } 96 92 97 public function set_registry(\SimplePie\Registry $registry)/* : void */ 93 /** 94 * Set a PSR-18 client and PSR-17 factories 95 * 96 * Allows you to use your own HTTP client implementations. 97 */ 98 final public function set_http_client( 99 ClientInterface $http_client, 100 RequestFactoryInterface $request_factory, 101 UriFactoryInterface $uri_factory 102 ): void { 103 $this->http_client = new Psr18Client($http_client, $request_factory, $uri_factory); 104 } 105 106 /** 107 * @return void 108 */ 109 public function set_registry(\SimplePie\Registry $registry) 98 110 { 99 111 $this->registry = $registry; 100 112 } 101 113 102 public function find($type = \SimplePie\SimplePie::LOCATOR_ALL, &$working = null) 103 { 114 /** 115 * @param SimplePie::LOCATOR_* $type 116 * @param array<Response>|null $working 117 * @return Response|null 118 */ 119 public function find(int $type = \SimplePie\SimplePie::LOCATOR_ALL, ?array &$working = null) 120 { 121 assert($this->registry !== null); 122 104 123 if ($this->is_feed($this->file)) { 105 124 return $this->file; 106 125 } 107 126 108 if ( $this->file->method & \SimplePie\SimplePie::FILE_SOURCE_REMOTE) {127 if (Misc::is_remote_uri($this->file->get_final_requested_uri())) { 109 128 $sniffer = $this->registry->create(Content\Type\Sniffer::class, [$this->file]); 110 129 if ($sniffer->get_type() !== 'text/html') { … … 141 160 } 142 161 143 public function is_feed($file, $check_html = false) 144 { 145 if ($file->method & \SimplePie\SimplePie::FILE_SOURCE_REMOTE) { 162 /** 163 * @return bool 164 */ 165 public function is_feed(Response $file, bool $check_html = false) 166 { 167 assert($this->registry !== null); 168 169 if (Misc::is_remote_uri($file->get_final_requested_uri())) { 146 170 $sniffer = $this->registry->create(Content\Type\Sniffer::class, [$file]); 147 171 $sniffed = $sniffer->get_type(); … … 154 178 155 179 return in_array($sniffed, $mime_types); 156 } elseif ( $file->method & \SimplePie\SimplePie::FILE_SOURCE_LOCAL) {180 } elseif (is_file($file->get_final_requested_uri())) { 157 181 return true; 158 182 } else { … … 161 185 } 162 186 187 /** 188 * @return void 189 */ 163 190 public function get_base() 164 191 { 192 assert($this->registry !== null); 193 165 194 if ($this->dom === null) { 166 195 throw new \SimplePie\Exception('DOMDocument not found, unable to use locator'); 167 196 } 168 $this->http_base = $this->file-> url;197 $this->http_base = $this->file->get_final_requested_uri(); 169 198 $this->base = $this->http_base; 170 199 $elements = $this->dom->getElementsByTagName('base'); … … 182 211 } 183 212 213 /** 214 * @return array<Response>|null 215 */ 184 216 public function autodiscovery() 185 217 { … … 197 229 } 198 230 199 protected function search_elements_by_tag($name, &$done, $feeds) 200 { 231 /** 232 * @param string[] $done 233 * @param array<string, Response> $feeds 234 * @return array<string, Response> 235 */ 236 protected function search_elements_by_tag(string $name, array &$done, array $feeds) 237 { 238 assert($this->registry !== null); 239 201 240 if ($this->dom === null) { 202 241 throw new \SimplePie\Exception('DOMDocument not found, unable to use locator'); … … 224 263 $this->checked_feeds++; 225 264 $headers = [ 226 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',265 'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER, 227 266 ]; 228 $feed = $this->registry->create(File::class, [$href, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options]); 229 if ($feed->success && ($feed->method & \SimplePie\SimplePie::FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed, true)) { 230 $feeds[$href] = $feed; 267 268 try { 269 $feed = $this->get_http_client()->request(Client::METHOD_GET, $href, $headers); 270 271 if ((!Misc::is_remote_uri($feed->get_final_requested_uri()) || ($feed->get_status_code() === 200 || $feed->get_status_code() > 206 && $feed->get_status_code() < 300)) && $this->is_feed($feed, true)) { 272 $feeds[$href] = $feed; 273 } 274 } catch (ClientException $th) { 275 // Just mark it as done and continue. 231 276 } 232 277 } … … 238 283 } 239 284 285 /** 286 * @return true|null 287 */ 240 288 public function get_links() 241 289 { 290 assert($this->registry !== null); 291 242 292 if ($this->dom === null) { 243 293 throw new \SimplePie\Exception('DOMDocument not found, unable to use locator'); … … 259 309 } 260 310 261 $current = $this->registry->call(Misc::class, 'parse_url', [$this->file-> url]);311 $current = $this->registry->call(Misc::class, 'parse_url', [$this->file->get_final_requested_uri()]); 262 312 263 313 if ($parsed['authority'] === '' || $parsed['authority'] === $current['authority']) { … … 277 327 } 278 328 279 public function get_rel_link($rel) 280 { 329 /** 330 * Extracts first `link` element with given `rel` attribute inside the `head` element. 331 * 332 * @return string|null 333 */ 334 public function get_rel_link(string $rel) 335 { 336 assert($this->registry !== null); 337 281 338 if ($this->dom === null) { 282 339 throw new \SimplePie\Exception('DOMDocument not found, unable to use '. … … 289 346 290 347 $xpath = new \DOMXpath($this->dom); 291 $query = '//a[@rel and @href] | //link[@rel and @href]'; 292 foreach ($xpath->query($query) as $link) { 348 $query = '(//head)[1]/link[@rel and @href]'; 349 /** @var \DOMNodeList<\DOMElement> */ 350 $queryResult = $xpath->query($query); 351 foreach ($queryResult as $link) { 293 352 $href = trim($link->getAttribute('href')); 294 353 $parsed = $this->registry->call(Misc::class, 'parse_url', [$href]); … … 318 377 } 319 378 } 320 return null; 321 } 322 323 public function extension(&$array) 379 380 return null; 381 } 382 383 /** 384 * @param string[] $array 385 * @return array<Response>|null 386 */ 387 public function extension(array &$array) 324 388 { 325 389 foreach ($array as $key => $value) { … … 327 391 break; 328 392 } 329 if (in_array(strtolower(strrchr($value, '.')), ['.rss', '.rdf', '.atom', '.xml'])) { 393 $extension = strrchr($value, '.'); 394 if ($extension !== false && in_array(strtolower($extension), ['.rss', '.rdf', '.atom', '.xml'])) { 330 395 $this->checked_feeds++; 331 396 332 397 $headers = [ 333 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',398 'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER, 334 399 ]; 335 $feed = $this->registry->create(File::class, [$value, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options]); 336 if ($feed->success && ($feed->method & \SimplePie\SimplePie::FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) { 337 return [$feed]; 338 } else { 339 unset($array[$key]); 340 } 341 } 342 } 343 return null; 344 } 345 346 public function body(&$array) 400 401 try { 402 $feed = $this->get_http_client()->request(Client::METHOD_GET, $value, $headers); 403 404 if ((!Misc::is_remote_uri($feed->get_final_requested_uri()) || ($feed->get_status_code() === 200 || $feed->get_status_code() > 206 && $feed->get_status_code() < 300)) && $this->is_feed($feed)) { 405 return [$feed]; 406 } 407 } catch (ClientException $th) { 408 // Just unset and continue. 409 } 410 411 unset($array[$key]); 412 } 413 } 414 return null; 415 } 416 417 /** 418 * @param string[] $array 419 * @return array<Response>|null 420 */ 421 public function body(array &$array) 347 422 { 348 423 foreach ($array as $key => $value) { … … 353 428 $this->checked_feeds++; 354 429 $headers = [ 355 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',430 'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER, 356 431 ]; 357 $feed = $this->registry->create(File::class, [$value, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen, $this->curl_options]); 358 if ($feed->success && ($feed->method & \SimplePie\SimplePie::FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) { 359 return [$feed]; 360 } else { 361 unset($array[$key]); 362 } 363 } 364 } 365 return null; 432 433 try { 434 $feed = $this->get_http_client()->request(Client::METHOD_GET, $value, $headers); 435 436 if ((!Misc::is_remote_uri($feed->get_final_requested_uri()) || ($feed->get_status_code() === 200 || $feed->get_status_code() > 206 && $feed->get_status_code() < 300)) && $this->is_feed($feed)) { 437 return [$feed]; 438 } 439 } catch (ClientException $th) { 440 // Just unset and continue. 441 } 442 443 unset($array[$key]); 444 } 445 } 446 return null; 447 } 448 449 /** 450 * Get a HTTP client 451 */ 452 private function get_http_client(): Client 453 { 454 assert($this->registry !== null); 455 456 if ($this->http_client === null) { 457 $options = [ 458 'timeout' => $this->timeout, 459 'redirects' => 5, 460 'force_fsockopen' => $this->force_fsockopen, 461 'curl_options' => $this->curl_options, 462 ]; 463 464 if ($this->useragent !== null) { 465 $options['useragent'] = $this->useragent; 466 } 467 468 return new FileClient( 469 $this->registry, 470 $options 471 ); 472 } 473 474 return $this->http_client; 366 475 } 367 476 } -
trunk/src/wp-includes/SimplePie/src/Misc.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; … … 49 12 /** 50 13 * Miscellaneous utilities 51 *52 * @package SimplePie53 14 */ 54 15 class Misc 55 16 { 17 /** @var int|null */ 56 18 private static $SIMPLEPIE_BUILD = null; 57 19 58 public static function time_hms($seconds) 20 /** 21 * @return string 22 */ 23 public static function time_hms(int $seconds) 59 24 { 60 25 $time = ''; … … 81 46 } 82 47 83 public static function absolutize_url($relative, $base) 48 /** 49 * @return string|false 50 */ 51 public static function absolutize_url(string $relative, string $base) 84 52 { 85 53 $iri = \SimplePie\IRI::absolutize(new \SimplePie\IRI($base), $relative); … … 88 56 } 89 57 return $iri->get_uri(); 58 } 59 60 /** 61 * @internal 62 */ 63 public static function is_remote_uri(string $uri): bool 64 { 65 return preg_match('/^https?:\/\//i', $uri) === 1; 90 66 } 91 67 … … 96 72 * @param string $realname Element name (including namespace prefix if applicable) 97 73 * @param string $string HTML document 98 * @return array 99 */ 100 public static function get_element( $realname,$string)74 * @return array<array{tag: string, self_closing: bool, attribs: array<string, array{data: string}>, content?: string}> 75 */ 76 public static function get_element(string $realname, string $string) 101 77 { 102 78 // trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.3, use "DOMDocument" instead.'), \E_USER_DEPRECATED); … … 117 93 $return[$i]['attribs'] = []; 118 94 if (isset($matches[$i][2][0]) && preg_match_all('/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*)(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?/', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER)) { 119 for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++) {120 if (count($attrib s[$j]) === 2) {121 $attrib s[$j][2] = $attribs[$j][1];95 foreach ($attribs as $attrib) { 96 if (count($attrib) === 2) { 97 $attrib[2] = $attrib[1]; 122 98 } 123 $return[$i]['attribs'][strtolower($attrib s[$j][1])]['data'] = Misc::entities_decode(end($attribs[$j]));99 $return[$i]['attribs'][strtolower($attrib[1])]['data'] = Misc::entities_decode(end($attrib)); 124 100 } 125 101 } … … 129 105 } 130 106 131 public static function element_implode($element) 132 { 133 $full = "<$element[tag]"; 107 /** 108 * @deprecated since SimplePie 1.9.0. If you need it, you can copy the function to your codebase. But you should consider using `DOMDocument` for any DOM wrangling. 109 * @param array{tag: string, self_closing: bool, attribs: array<string, array{data: string}>, content: string} $element 110 * @return string 111 */ 112 public static function element_implode(array $element) 113 { 114 // trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.9.'), \E_USER_DEPRECATED); 115 116 $full = "<{$element['tag']}"; 134 117 foreach ($element['attribs'] as $key => $value) { 135 118 $key = strtolower($key); … … 139 122 $full .= ' />'; 140 123 } else { 141 $full .= "> $element[content]</$element[tag]>";124 $full .= ">{$element['content']}</{$element['tag']}>"; 142 125 } 143 126 return $full; 144 127 } 145 128 146 public static function error($message, $level, $file, $line) 129 /** 130 * @param string $message 131 * @param int $level 132 * @param string $file 133 * @param int $line 134 * @return string 135 */ 136 public static function error(string $message, int $level, string $file, int $line) 147 137 { 148 138 if ((error_reporting() & $level) > 0) { … … 180 170 } 181 171 182 public static function fix_protocol($url, $http = 1) 172 /** 173 * @return string 174 */ 175 public static function fix_protocol(string $url, int $http = 1) 183 176 { 184 177 $url = Misc::normalize_url($url); … … 205 198 /** 206 199 * @deprecated since SimplePie 1.8.0, use PHP native array_replace_recursive() instead. 207 */ 208 public static function array_merge_recursive($array1, $array2) 200 * @param array<mixed> $array1 201 * @param array<mixed> $array2 202 * @return array<mixed> 203 */ 204 public static function array_merge_recursive(array $array1, array $array2) 209 205 { 210 206 foreach ($array2 as $key => $value) { … … 219 215 } 220 216 221 public static function parse_url($url) 217 /** 218 * @return array<string, string> 219 */ 220 public static function parse_url(string $url) 222 221 { 223 222 $iri = new \SimplePie\IRI($url); … … 231 230 } 232 231 233 public static function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '') 232 /** 233 * @return string 234 */ 235 public static function compress_parse_url(string $scheme = '', string $authority = '', string $path = '', string $query = '', ?string $fragment = '') 234 236 { 235 237 $iri = new \SimplePie\IRI(''); … … 242 244 } 243 245 244 public static function normalize_url($url) 246 /** 247 * @return string 248 */ 249 public static function normalize_url(string $url) 245 250 { 246 251 $iri = new \SimplePie\IRI($url); … … 248 253 } 249 254 250 public static function percent_encoding_normalization($match) 255 /** 256 * @deprecated since SimplePie 1.9.0. This functionality is part of `IRI` – if you need it standalone, consider copying the function to your codebase. 257 * @param array<int, string> $match 258 * @return string 259 */ 260 public static function percent_encoding_normalization(array $match) 251 261 { 252 262 $integer = hexdec($match[1]); 253 263 if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E) { 254 return chr($integer); 264 // Cast for PHPStan, the value would only be float when above PHP_INT_MAX, which would not go in this branch. 265 return chr((int) $integer); 255 266 } 256 267 … … 265 276 * @return string UTF-8 encoded string 266 277 */ 267 public static function windows_1252_to_utf8( $string)278 public static function windows_1252_to_utf8(string $string) 268 279 { 269 280 static $convert_table = ["\x80" => "\xE2\x82\xAC", "\x81" => "\xEF\xBF\xBD", "\x82" => "\xE2\x80\x9A", "\x83" => "\xC6\x92", "\x84" => "\xE2\x80\x9E", "\x85" => "\xE2\x80\xA6", "\x86" => "\xE2\x80\xA0", "\x87" => "\xE2\x80\xA1", "\x88" => "\xCB\x86", "\x89" => "\xE2\x80\xB0", "\x8A" => "\xC5\xA0", "\x8B" => "\xE2\x80\xB9", "\x8C" => "\xC5\x92", "\x8D" => "\xEF\xBF\xBD", "\x8E" => "\xC5\xBD", "\x8F" => "\xEF\xBF\xBD", "\x90" => "\xEF\xBF\xBD", "\x91" => "\xE2\x80\x98", "\x92" => "\xE2\x80\x99", "\x93" => "\xE2\x80\x9C", "\x94" => "\xE2\x80\x9D", "\x95" => "\xE2\x80\xA2", "\x96" => "\xE2\x80\x93", "\x97" => "\xE2\x80\x94", "\x98" => "\xCB\x9C", "\x99" => "\xE2\x84\xA2", "\x9A" => "\xC5\xA1", "\x9B" => "\xE2\x80\xBA", "\x9C" => "\xC5\x93", "\x9D" => "\xEF\xBF\xBD", "\x9E" => "\xC5\xBE", "\x9F" => "\xC5\xB8", "\xA0" => "\xC2\xA0", "\xA1" => "\xC2\xA1", "\xA2" => "\xC2\xA2", "\xA3" => "\xC2\xA3", "\xA4" => "\xC2\xA4", "\xA5" => "\xC2\xA5", "\xA6" => "\xC2\xA6", "\xA7" => "\xC2\xA7", "\xA8" => "\xC2\xA8", "\xA9" => "\xC2\xA9", "\xAA" => "\xC2\xAA", "\xAB" => "\xC2\xAB", "\xAC" => "\xC2\xAC", "\xAD" => "\xC2\xAD", "\xAE" => "\xC2\xAE", "\xAF" => "\xC2\xAF", "\xB0" => "\xC2\xB0", "\xB1" => "\xC2\xB1", "\xB2" => "\xC2\xB2", "\xB3" => "\xC2\xB3", "\xB4" => "\xC2\xB4", "\xB5" => "\xC2\xB5", "\xB6" => "\xC2\xB6", "\xB7" => "\xC2\xB7", "\xB8" => "\xC2\xB8", "\xB9" => "\xC2\xB9", "\xBA" => "\xC2\xBA", "\xBB" => "\xC2\xBB", "\xBC" => "\xC2\xBC", "\xBD" => "\xC2\xBD", "\xBE" => "\xC2\xBE", "\xBF" => "\xC2\xBF", "\xC0" => "\xC3\x80", "\xC1" => "\xC3\x81", "\xC2" => "\xC3\x82", "\xC3" => "\xC3\x83", "\xC4" => "\xC3\x84", "\xC5" => "\xC3\x85", "\xC6" => "\xC3\x86", "\xC7" => "\xC3\x87", "\xC8" => "\xC3\x88", "\xC9" => "\xC3\x89", "\xCA" => "\xC3\x8A", "\xCB" => "\xC3\x8B", "\xCC" => "\xC3\x8C", "\xCD" => "\xC3\x8D", "\xCE" => "\xC3\x8E", "\xCF" => "\xC3\x8F", "\xD0" => "\xC3\x90", "\xD1" => "\xC3\x91", "\xD2" => "\xC3\x92", "\xD3" => "\xC3\x93", "\xD4" => "\xC3\x94", "\xD5" => "\xC3\x95", "\xD6" => "\xC3\x96", "\xD7" => "\xC3\x97", "\xD8" => "\xC3\x98", "\xD9" => "\xC3\x99", "\xDA" => "\xC3\x9A", "\xDB" => "\xC3\x9B", "\xDC" => "\xC3\x9C", "\xDD" => "\xC3\x9D", "\xDE" => "\xC3\x9E", "\xDF" => "\xC3\x9F", "\xE0" => "\xC3\xA0", "\xE1" => "\xC3\xA1", "\xE2" => "\xC3\xA2", "\xE3" => "\xC3\xA3", "\xE4" => "\xC3\xA4", "\xE5" => "\xC3\xA5", "\xE6" => "\xC3\xA6", "\xE7" => "\xC3\xA7", "\xE8" => "\xC3\xA8", "\xE9" => "\xC3\xA9", "\xEA" => "\xC3\xAA", "\xEB" => "\xC3\xAB", "\xEC" => "\xC3\xAC", "\xED" => "\xC3\xAD", "\xEE" => "\xC3\xAE", "\xEF" => "\xC3\xAF", "\xF0" => "\xC3\xB0", "\xF1" => "\xC3\xB1", "\xF2" => "\xC3\xB2", "\xF3" => "\xC3\xB3", "\xF4" => "\xC3\xB4", "\xF5" => "\xC3\xB5", "\xF6" => "\xC3\xB6", "\xF7" => "\xC3\xB7", "\xF8" => "\xC3\xB8", "\xF9" => "\xC3\xB9", "\xFA" => "\xC3\xBA", "\xFB" => "\xC3\xBB", "\xFC" => "\xC3\xBC", "\xFD" => "\xC3\xBD", "\xFE" => "\xC3\xBE", "\xFF" => "\xC3\xBF"]; … … 278 289 * @param string $input Encoding of $data 279 290 * @param string $output Encoding you want 280 * @return string| booleanFalse if we can't convert it281 */ 282 public static function change_encoding( $data, $input,$output)291 * @return string|false False if we can't convert it 292 */ 293 public static function change_encoding(string $data, string $input, string $output) 283 294 { 284 295 $input = Misc::encoding($input); … … 287 298 // We fail to fail on non US-ASCII bytes 288 299 if ($input === 'US-ASCII') { 289 static $non_ascii_octe cts = '';290 if (!$non_ascii_octe cts) {300 static $non_ascii_octets = ''; 301 if (!$non_ascii_octets) { 291 302 for ($i = 0x80; $i <= 0xFF; $i++) { 292 $non_ascii_octe cts .= chr($i);303 $non_ascii_octets .= chr($i); 293 304 } 294 305 } 295 $data = substr($data, 0, strcspn($data, $non_ascii_octe cts));306 $data = substr($data, 0, strcspn($data, $non_ascii_octets)); 296 307 } 297 308 … … 317 328 } 318 329 319 protected static function change_encoding_mbstring($data, $input, $output) 330 /** 331 * @return string|false 332 */ 333 protected static function change_encoding_mbstring(string $data, string $input, string $output) 320 334 { 321 335 if ($input === 'windows-949') { … … 349 363 } 350 364 351 protected static function change_encoding_iconv($data, $input, $output) 365 /** 366 * @return string|false 367 */ 368 protected static function change_encoding_iconv(string $data, string $input, string $output) 352 369 { 353 370 return @iconv($input, $output, $data); … … 355 372 356 373 /** 357 * @param string $data358 * @param string $input359 * @param string $output360 374 * @return string|false 361 375 */ 362 protected static function change_encoding_uconverter( $data, $input,$output)376 protected static function change_encoding_uconverter(string $data, string $input, string $output) 363 377 { 364 378 return @\UConverter::transcode($data, $output, $input); … … 376 390 * @return string Standardised name 377 391 */ 378 public static function encoding( $charset)392 public static function encoding(string $charset) 379 393 { 380 394 // Normalization from UTS #22 381 switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset))) { 395 // Cast for PHPStan, the regex should not fail. 396 switch (strtolower((string) preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset))) { 382 397 case 'adobestandardencoding': 383 398 case 'csadobestandardencoding': … … 1688 1703 } 1689 1704 1705 /** 1706 * @return string 1707 */ 1690 1708 public static function get_curl_version() 1691 1709 { 1692 1710 if (is_array($curl = curl_version())) { 1693 1711 $curl = $curl['version']; 1694 } elseif (substr($curl, 0, 5) === 'curl/') {1695 $curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5));1696 } elseif (substr($curl, 0, 8) === 'libcurl/') {1697 $curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8));1698 1712 } else { 1699 $curl = 0;1713 $curl = '0'; 1700 1714 } 1701 1715 return $curl; … … 1705 1719 * Strip HTML comments 1706 1720 * 1721 * @deprecated since SimplePie 1.9.0. If you need it, you can copy the function to your codebase. But you should consider using `DOMDocument` for any DOM wrangling. 1707 1722 * @param string $data Data to strip comments from 1708 1723 * @return string Comment stripped string 1709 1724 */ 1710 public static function strip_comments($data) 1711 { 1725 public static function strip_comments(string $data) 1726 { 1727 // trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.9.'), \E_USER_DEPRECATED); 1728 1712 1729 $output = ''; 1713 1730 while (($start = strpos($data, '<!--')) !== false) { … … 1722 1739 } 1723 1740 1724 public static function parse_date($dt) 1741 /** 1742 * @return int|false 1743 */ 1744 public static function parse_date(string $dt) 1725 1745 { 1726 1746 $parser = \SimplePie\Parse\Date::get(); … … 1735 1755 * @return string Output data 1736 1756 */ 1737 public static function entities_decode( $data)1757 public static function entities_decode(string $data) 1738 1758 { 1739 1759 // trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.3, use "DOMDocument" instead.'), \E_USER_DEPRECATED); … … 1746 1766 * Remove RFC822 comments 1747 1767 * 1748 * @param string $data Data to strip comments from 1768 * @deprecated since SimplePie 1.9.0. If you need it, consider copying the function to your codebase. 1769 * @param string $string Data to strip comments from 1749 1770 * @return string Comment stripped string 1750 1771 */ 1751 public static function uncomment_rfc822($string) 1752 { 1753 $string = (string) $string; 1772 public static function uncomment_rfc822(string $string) 1773 { 1774 // trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.9.'), \E_USER_DEPRECATED); 1775 1754 1776 $position = 0; 1755 1777 $length = strlen($string); … … 1792 1814 } 1793 1815 1794 public static function parse_mime($mime) 1816 /** 1817 * @return string 1818 */ 1819 public static function parse_mime(string $mime) 1795 1820 { 1796 1821 if (($pos = strpos($mime, ';')) === false) { … … 1801 1826 } 1802 1827 1803 public static function atom_03_construct_type($attribs) 1828 /** 1829 * @param array<string, array<string, string>> $attribs 1830 * @return int-mask-of<SimplePie::CONSTRUCT_*> 1831 */ 1832 public static function atom_03_construct_type(array $attribs) 1804 1833 { 1805 1834 if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode'])) === 'base64') { … … 1830 1859 } 1831 1860 1832 public static function atom_10_construct_type($attribs) 1861 /** 1862 * @param array<string, array<string, string>> $attribs 1863 * @return int-mask-of<SimplePie::CONSTRUCT_*> 1864 */ 1865 public static function atom_10_construct_type(array $attribs) 1833 1866 { 1834 1867 if (isset($attribs['']['type'])) { … … 1850 1883 } 1851 1884 1852 public static function atom_10_content_construct_type($attribs) 1885 /** 1886 * @param array<string, array<string, string>> $attribs 1887 * @return int-mask-of<SimplePie::CONSTRUCT_*> 1888 */ 1889 public static function atom_10_content_construct_type(array $attribs) 1853 1890 { 1854 1891 if (isset($attribs['']['type'])) { … … 1874 1911 } 1875 1912 1876 public static function is_isegment_nz_nc($string) 1913 /** 1914 * @return bool 1915 */ 1916 public static function is_isegment_nz_nc(string $string) 1877 1917 { 1878 1918 return (bool) preg_match('/^([A-Za-z0-9\-._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!$&\'()*+,;=@]|(%[0-9ABCDEF]{2}))+$/u', $string); 1879 1919 } 1880 1920 1881 public static function space_separated_tokens($string) 1921 /** 1922 * @return string[] 1923 */ 1924 public static function space_separated_tokens(string $string) 1882 1925 { 1883 1926 $space_characters = "\x20\x09\x0A\x0B\x0C\x0D"; … … 1902 1945 * @static 1903 1946 * @param int $codepoint Unicode codepoint 1904 * @return string UTF-8 character 1905 */ 1906 public static function codepoint_to_utf8($codepoint) 1907 { 1908 $codepoint = (int) $codepoint; 1947 * @return string|false UTF-8 character 1948 */ 1949 public static function codepoint_to_utf8(int $codepoint) 1950 { 1909 1951 if ($codepoint < 0) { 1910 1952 return false; … … 1929 1971 * array of values that have used the same name 1930 1972 * 1973 * @deprecated since SimplePie 1.9.0. If you need it, consider copying the function to your codebase. 1931 1974 * @static 1932 1975 * @param string $str The input string. 1933 * @return array 1934 */ 1935 public static function parse_str($str) 1936 { 1976 * @return array<string, array<string|null>> 1977 */ 1978 public static function parse_str(string $str) 1979 { 1980 // trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.9.'), \E_USER_DEPRECATED); 1981 1937 1982 $return = []; 1938 1983 $str = explode('&', $str); … … 1956 2001 * @param string $data XML data 1957 2002 * @param \SimplePie\Registry $registry Class registry 1958 * @return array Possible encodings1959 */ 1960 public static function xml_encoding( $data,$registry)2003 * @return array<string> Possible encodings 2004 */ 2005 public static function xml_encoding(string $data, \SimplePie\Registry $registry) 1961 2006 { 1962 2007 // UTF-32 Big Endian BOM … … 2037 2082 } 2038 2083 2084 /** 2085 * @return void 2086 */ 2039 2087 public static function output_javascript() 2040 2088 { … … 2046 2094 header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days 2047 2095 2048 $body = <<< END2096 $body = <<<JS 2049 2097 function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) { 2050 2098 if (placeholder != '') { … … 2067 2115 document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>'); 2068 2116 } 2069 END;2117 JS; 2070 2118 echo $body; 2071 2119 } … … 2076 2124 * Uses the git index if it exists, otherwise uses the modification time 2077 2125 * of the newest file. 2126 * 2127 * @return int 2078 2128 */ 2079 2129 public static function get_build() 2080 2130 { 2081 if (s tatic::$SIMPLEPIE_BUILD !== null) {2082 return s tatic::$SIMPLEPIE_BUILD;2131 if (self::$SIMPLEPIE_BUILD !== null) { 2132 return self::$SIMPLEPIE_BUILD; 2083 2133 } 2084 2134 2085 2135 $root = dirname(__FILE__, 2); 2086 2136 if (file_exists($root . '/.git/index')) { 2087 s tatic::$SIMPLEPIE_BUILD =filemtime($root . '/.git/index');2088 2089 return s tatic::$SIMPLEPIE_BUILD;2090 } elseif (file_exists($root . '/ SimplePie')) {2137 self::$SIMPLEPIE_BUILD = (int) filemtime($root . '/.git/index'); 2138 2139 return self::$SIMPLEPIE_BUILD; 2140 } elseif (file_exists($root . '/src')) { 2091 2141 $time = 0; 2092 foreach (glob($root . '/ SimplePie/*.php')as $file) {2142 foreach (glob($root . '/src/*.php') ?: [] as $file) { 2093 2143 if (($mtime = filemtime($file)) > $time) { 2094 2144 $time = $mtime; 2095 2145 } 2096 2146 } 2097 static::$SIMPLEPIE_BUILD = $time; 2098 2099 return static::$SIMPLEPIE_BUILD; 2100 } elseif (file_exists(dirname(__FILE__) . '/Core.php')) { 2101 static::$SIMPLEPIE_BUILD = filemtime(dirname(__FILE__) . '/Core.php'); 2102 2103 return static::$SIMPLEPIE_BUILD; 2104 } 2105 2106 static::$SIMPLEPIE_BUILD = filemtime(__FILE__); 2107 2108 return static::$SIMPLEPIE_BUILD; 2147 2148 self::$SIMPLEPIE_BUILD = $time; 2149 2150 return self::$SIMPLEPIE_BUILD; 2151 } 2152 2153 self::$SIMPLEPIE_BUILD = (int) filemtime(__FILE__); 2154 2155 return self::$SIMPLEPIE_BUILD; 2109 2156 } 2110 2157 … … 2121 2168 /** 2122 2169 * Format debugging information 2123 */ 2124 public static function debug(&$sp) 2170 * 2171 * @return string 2172 */ 2173 public static function debug(SimplePie &$sp) 2125 2174 { 2126 2175 $info = 'SimplePie ' . \SimplePie\SimplePie::VERSION . ' Build ' . static::get_build() . "\n"; 2127 2176 $info .= 'PHP ' . PHP_VERSION . "\n"; 2128 2177 if ($sp->error() !== null) { 2129 $info .= 'Error occurred: ' . $sp->error() . "\n"; 2178 // TODO: Remove cast with multifeeds. 2179 $info .= 'Error occurred: ' . implode(', ', (array) $sp->error()) . "\n"; 2130 2180 } else { 2131 2181 $info .= "No error found.\n"; … … 2141 2191 break; 2142 2192 case 'curl': 2143 $version = curl_version();2193 $version = (array) curl_version(); 2144 2194 $info .= ' Version ' . $version['version'] . "\n"; 2145 break;2146 case 'mbstring':2147 $info .= ' Overloading: ' . mb_get_info('func_overload') . "\n";2148 2195 break; 2149 2196 case 'iconv': … … 2161 2208 } 2162 2209 2163 public static function silence_errors($num, $str) 2210 /** 2211 * @return bool 2212 */ 2213 public static function silence_errors(int $num, string $str) 2164 2214 { 2165 2215 // No-op 2216 return true; 2166 2217 } 2167 2218 … … 2171 2222 * @return string the same URL without HTTP credentials. 2172 2223 */ 2173 public static function url_remove_credentials($url) 2174 { 2175 return preg_replace('#^(https?://)[^/:@]+:[^/:@]+@#i', '$1', $url); 2224 public static function url_remove_credentials(string $url) 2225 { 2226 // Cast for PHPStan: I do not think this can fail. 2227 // The regex is valid and there should be no backtracking. 2228 // https://github.com/phpstan/phpstan/issues/11547 2229 return (string) preg_replace('#^(https?://)[^/:@]+:[^/:@]+@#i', '$1', $url); 2176 2230 } 2177 2231 } -
trunk/src/wp-includes/SimplePie/src/Net/IPv6.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\Net; … … 48 11 * Class to validate and to work with IPv6 addresses. 49 12 * 50 * @package SimplePie51 * @subpackage HTTP52 13 * @copyright 2003-2005 The PHP Group 53 14 * @license http://www.opensource.org/licenses/bsd-license.php … … 63 24 * Uncompresses an IPv6 address 64 25 * 65 * RFC 4291 allows you to compress con cecutive zero pieces in an address to26 * RFC 4291 allows you to compress consecutive zero pieces in an address to 66 27 * '::'. This method expects a valid IPv6 address and expands the '::' to 67 28 * the required number of zero pieces. … … 78 39 * @return string The uncompressed IPv6 address 79 40 */ 80 public static function uncompress( $ip)41 public static function uncompress(string $ip) 81 42 { 82 43 $c1 = -1; … … 123 84 * Compresses an IPv6 address 124 85 * 125 * RFC 4291 allows you to compress con cecutive zero pieces in an address to86 * RFC 4291 allows you to compress consecutive zero pieces in an address to 126 87 * '::'. This method expects a valid IPv6 address and compresses consecutive 127 88 * zero pieces to '::'. … … 134 95 * @return string The compressed IPv6 address 135 96 */ 136 public static function compress( $ip)97 public static function compress(string $ip) 137 98 { 138 99 // Prepare the IP to be compressed … … 141 102 142 103 // Replace all leading zeros 143 $ip_parts[0] = preg_replace('/(^|:)0+([0-9])/', '\1\2', $ip_parts[0]);104 $ip_parts[0] = (string) preg_replace('/(^|:)0+([0-9])/', '\1\2', $ip_parts[0]); 144 105 145 106 // Find bunches of zeros … … 154 115 } 155 116 117 assert($pos !== null, 'For PHPStan: Since the regex matched, there is at least one match. And because the pattern is non-empty, the loop will always end with $pos ≥ 1.'); 156 118 $ip_parts[0] = substr_replace($ip_parts[0], '::', $pos, $max); 157 119 } … … 174 136 * 175 137 * @param string $ip An IPv6 address 176 * @return array [0] contains the IPv6 represented part, and [1] the IPv4 represented part177 */ 178 private static function split_v6_v4( $ip)138 * @return array{string, string} [0] contains the IPv6 represented part, and [1] the IPv4 represented part 139 */ 140 private static function split_v6_v4(string $ip): array 179 141 { 180 142 if (strpos($ip, '.') !== false) { 181 143 $pos = strrpos($ip, ':'); 144 assert($pos !== false, 'For PHPStan: IPv6 address must contain colon, since split_v6_v4 is only ever called after uncompress.'); 182 145 $ipv6_part = substr($ip, 0, $pos); 183 146 $ipv4_part = substr($ip, $pos + 1); … … 196 159 * @return bool true if $ip is a valid IPv6 address 197 160 */ 198 public static function check_ipv6( $ip)161 public static function check_ipv6(string $ip) 199 162 { 200 163 $ip = self::uncompress($ip); … … 222 185 // Check the value is valid 223 186 $value = hexdec($ipv6_part); 224 if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF) { 187 if ($value < 0 || $value > 0xFFFF) { 188 return false; 189 } 190 assert(is_int($value), 'For PHPStan: $value is only float when $ipv6_part > PHP_INT_MAX'); 191 if (dechex($value) !== strtolower($ipv6_part)) { 225 192 return false; 226 193 } … … 249 216 * @return bool true if $ip is a valid IPv6 address 250 217 */ 251 public static function checkIPv6( $ip)218 public static function checkIPv6(string $ip) 252 219 { 253 220 return self::check_ipv6($ip); -
trunk/src/wp-includes/SimplePie/src/Parse/Date.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\Parse; … … 47 10 /** 48 11 * Date Parser 49 *50 * @package SimplePie51 * @subpackage Parsing52 12 */ 53 13 class Date … … 65 25 * 66 26 * @access protected 67 * @var array 27 * @var array<string, int<1,7>> 68 28 */ 69 29 public $day = [ … … 170 130 * 171 131 * @access protected 172 * @var array 132 * @var array<string, int<1,12>> 173 133 */ 174 134 public $month = [ … … 202 162 'februari' => 2, 203 163 'maart' => 3, 204 'april' => 4,164 // 'april' => 4, 205 165 'mei' => 5, 206 166 'juni' => 6, 207 167 'juli' => 7, 208 168 'augustus' => 8, 209 'september' => 9,169 // 'september' => 9, 210 170 'oktober' => 10, 211 'november' => 11,212 'december' => 12,171 // 'november' => 11, 172 // 'december' => 12, 213 173 // French 214 174 'janvier' => 1, … … 226 186 // German 227 187 'januar' => 1, 228 'jan' => 1,188 // 'jan' => 1, 229 189 'februar' => 2, 230 'feb' => 2,190 // 'feb' => 2, 231 191 'märz' => 3, 232 192 'mär' => 3, 233 'april' => 4,234 'apr' => 4,235 'mai' => 5, // no short form for may236 'juni' => 6,237 'jun' => 6,238 'juli' => 7,239 'jul' => 7,240 'august' => 8,241 'aug' => 8,242 'september' => 9,243 'sep' => 9,244 'oktober' => 10,193 // 'april' => 4, 194 // 'apr' => 4, 195 // 'mai' => 5, // no short form for may 196 // 'juni' => 6, 197 // 'jun' => 6, 198 // 'juli' => 7, 199 // 'jul' => 7, 200 // 'august' => 8, 201 // 'aug' => 8, 202 // 'september' => 9, 203 // 'sep' => 9, 204 // 'oktober' => 10, 245 205 'okt' => 10, 246 'november' => 11,247 'nov' => 11,206 // 'november' => 11, 207 // 'nov' => 11, 248 208 'dezember' => 12, 249 209 'dez' => 12, … … 259 219 'settembre' => 9, 260 220 'ottobre' => 10, 261 'novembre' => 11,221 // 'novembre' => 11, 262 222 'dicembre' => 12, 263 223 // Spanish 264 224 'enero' => 1, 265 225 'febrero' => 2, 266 'marzo' => 3,226 // 'marzo' => 3, 267 227 'abril' => 4, 268 228 'mayo' => 5, 269 229 'junio' => 6, 270 230 'julio' => 7, 271 'agosto' => 8,231 // 'agosto' => 8, 272 232 'septiembre' => 9, 273 233 'setiembre' => 9, … … 299 259 'szeptember' => 9, 300 260 'október' => 10, 301 'november' => 11,302 'december' => 12,261 // 'november' => 11, 262 // 'december' => 12, 303 263 // Greek 304 264 'Ιαν' => 1, … … 352 312 * 353 313 * @access protected 354 * @var array 314 * @var array<string, int> 355 315 */ 356 316 public $timezone = [ … … 423 383 'GIT' => -32400, 424 384 'GST' => 14400, 425 'GST' => -7200,385 // 'GST' => -7200, 426 386 'GYT' => -14400, 427 387 'HAA' => -10800, … … 577 537 * 578 538 * @access private 579 * @var array 539 * @var array<string> 580 540 */ 581 541 public $built_in = []; … … 585 545 * 586 546 * @access private 587 * @var array 547 * @var array<callable(string): (int|false)> 588 548 */ 589 549 public $user = []; … … 620 580 * 621 581 * @access public 582 * @return Date 622 583 */ 623 584 public static function get() … … 636 597 * @access public 637 598 * @param string $date Date to parse 638 * @return int Timestamp corresponding to date string, or false on failure639 */ 640 public function parse( $date)599 * @return int|false Timestamp corresponding to date string, or false on failure 600 */ 601 public function parse(string $date) 641 602 { 642 603 foreach ($this->user as $method) { 643 604 if (($returned = call_user_func($method, $date)) !== false) { 644 return $returned;605 return (int) $returned; 645 606 } 646 607 } 647 608 648 609 foreach ($this->built_in as $method) { 649 if (($returned = call_user_func([$this, $method], $date)) !== false) { 610 // TODO: we should really check this in constructor but that would require private properties. 611 /** @var callable(string): (int|false) */ 612 $callable = [$this, $method]; 613 if (($returned = call_user_func($callable, $date)) !== false) { 650 614 return $returned; 651 615 } … … 661 625 * @access public 662 626 * @param callable $callback 663 */ 664 public function add_callback($callback) 627 * @return void 628 */ 629 public function add_callback(callable $callback) 665 630 { 666 if (is_callable($callback)) { 667 $this->user[] = $callback; 668 } else { 669 trigger_error('User-supplied function must be a valid callback', E_USER_WARNING); 670 } 631 $this->user[] = $callback; 671 632 } 672 633 … … 677 638 * 678 639 * @access protected 679 * @return int Timestamp 680 */ 681 public function date_w3cdtf($date) 640 * @param string $date 641 * @return int|false Timestamp 642 */ 643 public function date_w3cdtf(string $date) 682 644 { 683 645 $pcre = <<<'PCRE' … … 750 712 * 751 713 * @access protected 752 * @param string $ dataData to strip comments from714 * @param string $string Data to strip comments from 753 715 * @return string Comment stripped string 754 716 */ 755 public function remove_rfc2822_comments( $string)717 public function remove_rfc2822_comments(string $string) 756 718 { 757 $string = (string) $string;758 719 $position = 0; 759 720 $length = strlen($string); … … 800 761 * 801 762 * @access protected 802 * @return int Timestamp 803 */ 804 public function date_rfc2822($date) 763 * @param string $date 764 * @return int|false Timestamp 765 */ 766 public function date_rfc2822(string $date) 805 767 { 806 768 static $pcre; … … 835 797 */ 836 798 799 $day = (int) $match[2]; 837 800 // Find the month number 838 801 $month = $this->month[strtolower($match[3])]; 802 $year = (int) $match[4]; 803 $hour = (int) $match[5]; 804 $minute = (int) $match[6]; 805 // Second is optional, if it is empty set it to zero 806 $second = (int) $match[7]; 807 808 $tz_sign = $match[8]; 809 $tz_hour = (int) $match[9]; 810 $tz_minute = (int) $match[10]; 811 $tz_code = isset($match[11]) ? strtoupper($match[11]) : ''; 839 812 840 813 // Numeric timezone 841 if ($ match[8]!== '') {842 $timezone = $ match[9]* 3600;843 $timezone += $ match[10]* 60;844 if ($ match[8]=== '-') {814 if ($tz_sign !== '') { 815 $timezone = $tz_hour * 3600; 816 $timezone += $tz_minute * 60; 817 if ($tz_sign === '-') { 845 818 $timezone = 0 - $timezone; 846 819 } 847 820 } 848 821 // Character timezone 849 elseif (isset($this->timezone[ strtoupper($match[11])])) {850 $timezone = $this->timezone[ strtoupper($match[11])];822 elseif (isset($this->timezone[$tz_code])) { 823 $timezone = $this->timezone[$tz_code]; 851 824 } 852 825 // Assume everything else to be -0000 … … 856 829 857 830 // Deal with 2/3 digit years 858 if ($match[4] < 50) { 859 $match[4] += 2000; 860 } elseif ($match[4] < 1000) { 861 $match[4] += 1900; 862 } 863 864 // Second is optional, if it is empty set it to zero 865 if ($match[7] !== '') { 866 $second = $match[7]; 867 } else { 868 $second = 0; 869 } 870 871 return gmmktime(intval($match[5]), intval($match[6]), intval($second), intval($month), intval($match[2]), intval($match[4])) - $timezone; 831 if ($year < 50) { 832 $year += 2000; 833 } elseif ($year < 1000) { 834 $year += 1900; 835 } 836 837 return gmmktime($hour, $minute, $second, $month, $day, $year) - $timezone; 872 838 } 873 839 … … 879 845 * 880 846 * @access protected 881 * @return int Timestamp 882 */ 883 public function date_rfc850($date) 847 * @param string $date 848 * @return int|false Timestamp 849 */ 850 public function date_rfc850(string $date) 884 851 { 885 852 static $pcre; … … 906 873 */ 907 874 875 $day = (int) $match[2]; 908 876 // Month 909 877 $month = $this->month[strtolower($match[3])]; 878 $year = (int) $match[4]; 879 $hour = (int) $match[5]; 880 $minute = (int) $match[6]; 881 // Second is optional, if it is empty set it to zero 882 $second = (int) $match[7]; 883 884 $tz_code = strtoupper($match[8]); 910 885 911 886 // Character timezone 912 if (isset($this->timezone[ strtoupper($match[8])])) {913 $timezone = $this->timezone[ strtoupper($match[8])];887 if (isset($this->timezone[$tz_code])) { 888 $timezone = $this->timezone[$tz_code]; 914 889 } 915 890 // Assume everything else to be -0000 … … 919 894 920 895 // Deal with 2 digit year 921 if ($ match[4]< 50) {922 $ match[4]+= 2000;896 if ($year < 50) { 897 $year += 2000; 923 898 } else { 924 $ match[4]+= 1900;925 } 926 927 return gmmktime($ match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone;899 $year += 1900; 900 } 901 902 return gmmktime($hour, $minute, $second, $month, $day, $year) - $timezone; 928 903 } 929 904 … … 935 910 * 936 911 * @access protected 937 * @return int Timestamp 938 */ 939 public function date_asctime($date) 912 * @param string $date 913 * @return int|false Timestamp 914 */ 915 public function date_asctime(string $date) 940 916 { 941 917 static $pcre; … … 973 949 * 974 950 * @access protected 975 * @return int Timestamp 976 */ 977 public function date_strtotime($date) 951 * @param string $date 952 * @return int|false Timestamp 953 */ 954 public function date_strtotime(string $date) 978 955 { 979 956 $strtotime = strtotime($date); -
trunk/src/wp-includes/SimplePie/src/Parser.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; 46 9 47 10 use SimplePie\XML\Declaration\Parser as DeclarationParser; 11 use XMLParser; 48 12 49 13 /** … … 52 16 * 53 17 * This class can be overloaded with {@see \SimplePie\SimplePie::set_parser_class()} 54 *55 * @package SimplePie56 * @subpackage Parsing57 18 */ 58 19 class Parser implements RegistryAware 59 20 { 21 /** @var int */ 60 22 public $error_code; 23 /** @var string */ 61 24 public $error_string; 25 /** @var int */ 62 26 public $current_line; 27 /** @var int */ 63 28 public $current_column; 29 /** @var int */ 64 30 public $current_byte; 31 /** @var string */ 65 32 public $separator = ' '; 33 /** @var string[] */ 66 34 public $namespace = ['']; 35 /** @var string[] */ 67 36 public $element = ['']; 37 /** @var string[] */ 68 38 public $xml_base = ['']; 39 /** @var bool[] */ 69 40 public $xml_base_explicit = [false]; 41 /** @var string[] */ 70 42 public $xml_lang = ['']; 43 /** @var array<string, mixed> */ 71 44 public $data = []; 45 /** @var array<array<string, mixed>> */ 72 46 public $datas = [[]]; 47 /** @var int */ 73 48 public $current_xhtml_construct = -1; 49 /** @var string */ 74 50 public $encoding; 51 /** @var Registry */ 75 52 protected $registry; 76 53 77 public function set_registry(\SimplePie\Registry $registry)/* : void */ 54 /** 55 * @return void 56 */ 57 public function set_registry(\SimplePie\Registry $registry) 78 58 { 79 59 $this->registry = $registry; 80 60 } 81 61 82 public function parse(&$data, $encoding, $url = '') 62 /** 63 * @return bool 64 */ 65 public function parse(string &$data, string $encoding, string $url = '') 83 66 { 84 67 if (class_exists('DOMXpath') && function_exists('Mf2\parse')) { … … 90 73 $query = '//*[contains(concat(" ", @class, " "), " h-feed ") or '. 91 74 'contains(concat(" ", @class, " "), " h-entry ")]'; 75 /** @var \DOMNodeList<\DOMElement> $result */ 92 76 $result = $xpath->query($query); 93 77 if ($result->length !== 0) { … … 129 113 if ($declaration->parse()) { 130 114 $data = substr($data, $pos + 2); 131 $data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' ."\n". $this->declare_html_entities() . $data; 115 $data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . "\n" . 116 self::set_doctype($data); 132 117 } else { 133 118 $this->error_string = 'SimplePie bug! Please report this!'; 134 119 return false; 135 120 } 121 } else { 122 $data = self::set_doctype($data); 136 123 } 137 124 … … 142 129 $parser_check = xml_parser_create(); 143 130 xml_parse_into_struct($parser_check, '<foo>&</foo>', $values); 144 xml_parser_free($parser_check); 131 if (\PHP_VERSION_ID < 80000) { 132 xml_parser_free($parser_check); 133 } 145 134 $xml_is_sane = isset($values[0]['value']); 146 135 } … … 161 150 //Parse by chunks not to use too much memory 162 151 do { 163 $stream_data = fread($stream, 1048576); 164 if (!xml_parse($xml, $stream_data === false ? '' : $stream_data, feof($stream))) { 152 $stream_data = (string) fread($stream, 1048576); 153 154 if (!xml_parse($xml, $stream_data, feof($stream))) { 165 155 $this->error_code = xml_get_error_code($xml); 166 $this->error_string = xml_error_string($this->error_code) ;156 $this->error_string = xml_error_string($this->error_code) ?: "Unknown"; 167 157 $return = false; 168 158 break; … … 177 167 $this->current_column = xml_get_current_column_number($xml); 178 168 $this->current_byte = xml_get_current_byte_index($xml); 179 xml_parser_free($xml); 169 if (\PHP_VERSION_ID < 80000) { 170 xml_parser_free($xml); 171 } 180 172 return $return; 181 173 } … … 186 178 while (@$xml->read()) { 187 179 switch ($xml->nodeType) { 188 case constant('XMLReader::END_ELEMENT'):180 case \XMLReader::END_ELEMENT: 189 181 if ($xml->namespaceURI !== '') { 190 182 $tagName = $xml->namespaceURI . $this->separator . $xml->localName; … … 194 186 $this->tag_close(null, $tagName); 195 187 break; 196 case constant('XMLReader::ELEMENT'):188 case \XMLReader::ELEMENT: 197 189 $empty = $xml->isEmptyElement; 198 190 if ($xml->namespaceURI !== '') { … … 215 207 } 216 208 break; 217 case constant('XMLReader::TEXT'):218 219 case constant('XMLReader::CDATA'):209 case \XMLReader::TEXT: 210 211 case \XMLReader::CDATA: 220 212 $this->cdata(null, $xml->value); 221 213 break; … … 233 225 } 234 226 227 /** 228 * @return int 229 */ 235 230 public function get_error_code() 236 231 { … … 238 233 } 239 234 235 /** 236 * @return string 237 */ 240 238 public function get_error_string() 241 239 { … … 243 241 } 244 242 243 /** 244 * @return int 245 */ 245 246 public function get_current_line() 246 247 { … … 248 249 } 249 250 251 /** 252 * @return int 253 */ 250 254 public function get_current_column() 251 255 { … … 253 257 } 254 258 259 /** 260 * @return int 261 */ 255 262 public function get_current_byte() 256 263 { … … 258 265 } 259 266 267 /** 268 * @return array<string, mixed> 269 */ 260 270 public function get_data() 261 271 { … … 263 273 } 264 274 265 public function tag_open($parser, $tag, $attributes) 275 /** 276 * @param XMLParser|resource|null $parser 277 * @param array<string, string> $attributes 278 * @return void 279 */ 280 public function tag_open($parser, string $tag, array $attributes) 266 281 { 267 282 [$this->namespace[], $this->element[]] = $this->split_ns($tag); … … 280 295 } 281 296 } else { 282 $this->xml_base[] = end($this->xml_base) ;297 $this->xml_base[] = end($this->xml_base) ?: ''; 283 298 $this->xml_base_explicit[] = end($this->xml_base_explicit); 284 299 } … … 287 302 $this->xml_lang[] = $attribs[\SimplePie\SimplePie::NAMESPACE_XML]['lang']; 288 303 } else { 289 $this->xml_lang[] = end($this->xml_lang) ;304 $this->xml_lang[] = end($this->xml_lang) ?: ''; 290 305 } 291 306 … … 315 330 } 316 331 317 public function cdata($parser, $cdata) 332 /** 333 * @param XMLParser|resource|null $parser 334 * @return void 335 */ 336 public function cdata($parser, string $cdata) 318 337 { 319 338 if ($this->current_xhtml_construct >= 0) { … … 324 343 } 325 344 326 public function tag_close($parser, $tag) 345 /** 346 * @param XMLParser|resource|null $parser 347 * @return void 348 */ 349 public function tag_close($parser, string $tag) 327 350 { 328 351 if ($this->current_xhtml_construct >= 0) { … … 344 367 } 345 368 346 public function split_ns($string) 369 /** 370 * @return array{string, string} 371 */ 372 public function split_ns(string $string) 347 373 { 348 374 static $cache = []; … … 375 401 } 376 402 377 private function parse_hcard($data, $category = false) 403 /** 404 * @param array<string, mixed> $data 405 */ 406 private function parse_hcard(array $data, bool $category = false): string 378 407 { 379 408 $name = ''; … … 399 428 } 400 429 401 private function parse_microformats(&$data, $url) 402 { 430 /** 431 * @return true 432 */ 433 private function parse_microformats(string &$data, string $url): bool 434 { 435 // For PHPStan, we already check that in call site. 436 \assert(function_exists('Mf2\parse')); 437 \assert(function_exists('Mf2\fetch')); 403 438 $feed_title = ''; 404 439 $feed_author = null; … … 486 521 $author = $author_cache[$author]; 487 522 } else { 488 $mf = \Mf2\fetch($author); 489 foreach ($mf['items'] as $hcard) { 490 // Only interested in an h-card by itself in this case. 491 if (!in_array('h-card', $hcard['type'])) { 492 continue; 523 if ($mf = \Mf2\fetch($author)) { 524 foreach ($mf['items'] as $hcard) { 525 // Only interested in an h-card by itself in this case. 526 if (!in_array('h-card', $hcard['type'])) { 527 continue; 528 } 529 // It must have a url property matching what we fetched. 530 if (!isset($hcard['properties']['url']) || 531 !(in_array($author, $hcard['properties']['url']))) { 532 continue; 533 } 534 // Save parse_hcard the trouble of finding the correct url. 535 $hcard['properties']['url'][0] = $author; 536 // Cache this h-card for the next h-entry to check. 537 $author_cache[$author] = $this->parse_hcard($hcard); 538 $author = $author_cache[$author]; 539 break; 493 540 } 494 // It must have a url property matching what we fetched.495 if (!isset($hcard['properties']['url']) ||496 !(in_array($author, $hcard['properties']['url']))) {497 continue;498 }499 // Save parse_hcard the trouble of finding the correct url.500 $hcard['properties']['url'][0] = $author;501 // Cache this h-card for the next h-entry to check.502 $author_cache[$author] = $this->parse_hcard($hcard);503 $author = $author_cache[$author];504 break;505 541 } 506 542 } … … 620 656 } 621 657 622 private function declare_html_entities() 658 private static function set_doctype(string $data): string 659 { 660 // Strip DOCTYPE except if containing an [internal subset] 661 $data = preg_replace('/^\\s*<!DOCTYPE\\s[^>\\[\\]]*>\s*/', '', $data) ?? $data; 662 // Declare HTML entities only if no remaining DOCTYPE 663 $doctype = preg_match('/^\\s*<!DOCTYPE\\s/', $data) ? '' : self::declare_html_entities(); 664 return $doctype . $data; 665 } 666 667 private static function declare_html_entities(): string 623 668 { 624 669 // This is required because the RSS specification says that entity-encoded 625 670 // html is allowed, but the xml specification says they must be declared. 626 return '<!DOCTYPE html[ <!ENTITY nbsp " "> <!ENTITY iexcl "¡"> <!ENTITY cent "¢"> <!ENTITY pound "£"> <!ENTITY curren "¤"> <!ENTITY yen "¥"> <!ENTITY brvbar "¦"> <!ENTITY sect "§"> <!ENTITY uml "¨"> <!ENTITY copy "©"> <!ENTITY ordf "ª"> <!ENTITY laquo "«"> <!ENTITY not "¬"> <!ENTITY shy "­"> <!ENTITY reg "®"> <!ENTITY macr "¯"> <!ENTITY deg "°"> <!ENTITY plusmn "±"> <!ENTITY sup2 "²"> <!ENTITY sup3 "³"> <!ENTITY acute "´"> <!ENTITY micro "µ"> <!ENTITY para "¶"> <!ENTITY middot "·"> <!ENTITY cedil "¸"> <!ENTITY sup1 "¹"> <!ENTITY ordm "º"> <!ENTITY raquo "»"> <!ENTITY frac14 "¼"> <!ENTITY frac12 "½"> <!ENTITY frac34 "¾"> <!ENTITY iquest "¿"> <!ENTITY Agrave "À"> <!ENTITY Aacute "Á"> <!ENTITY Acirc "Â"> <!ENTITY Atilde "Ã"> <!ENTITY Auml "Ä"> <!ENTITY Aring "Å"> <!ENTITY AElig "Æ"> <!ENTITY Ccedil "Ç"> <!ENTITY Egrave "È"> <!ENTITY Eacute "É"> <!ENTITY Ecirc "Ê"> <!ENTITY Euml "Ë"> <!ENTITY Igrave "Ì"> <!ENTITY Iacute "Í"> <!ENTITY Icirc "Î"> <!ENTITY Iuml "Ï"> <!ENTITY ETH "Ð"> <!ENTITY Ntilde "Ñ"> <!ENTITY Ograve "Ò"> <!ENTITY Oacute "Ó"> <!ENTITY Ocirc "Ô"> <!ENTITY Otilde "Õ"> <!ENTITY Ouml "Ö"> <!ENTITY times "×"> <!ENTITY Oslash "Ø"> <!ENTITY Ugrave "Ù"> <!ENTITY Uacute "Ú"> <!ENTITY Ucirc "Û"> <!ENTITY Uuml "Ü"> <!ENTITY Yacute "Ý"> <!ENTITY THORN "Þ"> <!ENTITY szlig "ß"> <!ENTITY agrave "à"> <!ENTITY aacute "á"> <!ENTITY acirc "â"> <!ENTITY atilde "ã"> <!ENTITY auml "ä"> <!ENTITY aring "å"> <!ENTITY aelig "æ"> <!ENTITY ccedil "ç"> <!ENTITY egrave "è"> <!ENTITY eacute "é"> <!ENTITY ecirc "ê"> <!ENTITY euml "ë"> <!ENTITY igrave "ì"> <!ENTITY iacute "í"> <!ENTITY icirc "î"> <!ENTITY iuml "ï"> <!ENTITY eth "ð"> <!ENTITY ntilde "ñ"> <!ENTITY ograve "ò"> <!ENTITY oacute "ó"> <!ENTITY ocirc "ô"> <!ENTITY otilde "õ"> <!ENTITY ouml "ö"> <!ENTITY divide "÷"> <!ENTITY oslash "ø"> <!ENTITY ugrave "ù"> <!ENTITY uacute "ú"> <!ENTITY ucirc "û"> <!ENTITY uuml "ü"> <!ENTITY yacute "ý"> <!ENTITY thorn "þ"> <!ENTITY yuml "ÿ"> <!ENTITY OElig "Œ"> <!ENTITY oelig "œ"> <!ENTITY Scaron "Š"> <!ENTITY scaron "š"> <!ENTITY Yuml "Ÿ"> <!ENTITY fnof "ƒ"> <!ENTITY circ "ˆ"> <!ENTITY tilde "˜"> <!ENTITY Alpha "Α"> <!ENTITY Beta "Β"> <!ENTITY Gamma "Γ"> <!ENTITY Epsilon "Ε"> <!ENTITY Zeta "Ζ"> <!ENTITY Eta "Η"> <!ENTITY Theta "Θ"> <!ENTITY Iota "Ι"> <!ENTITY Kappa "Κ"> <!ENTITY Lambda "Λ"> <!ENTITY Mu "Μ"> <!ENTITY Nu "Ν"> <!ENTITY Xi "Ξ"> <!ENTITY Omicron "Ο"> <!ENTITY Pi "Π"> <!ENTITY Rho "Ρ"> <!ENTITY Sigma "Σ"> <!ENTITY Tau "Τ"> <!ENTITY Upsilon "Υ"> <!ENTITY Phi "Φ"> <!ENTITY Chi "Χ"> <!ENTITY Psi "Ψ"> <!ENTITY Omega "Ω"> <!ENTITY alpha "α"> <!ENTITY beta "β"> <!ENTITY gamma "γ"> <!ENTITY delta "δ"> <!ENTITY epsilon "ε"> <!ENTITY zeta "ζ"> <!ENTITY eta "η"> <!ENTITY theta "θ"> <!ENTITY iota "ι"> <!ENTITY kappa "κ"> <!ENTITY lambda "λ"> <!ENTITY mu "μ"> <!ENTITY nu "ν"> <!ENTITY xi "ξ"> <!ENTITY omicron "ο"> <!ENTITY pi "π"> <!ENTITY rho "ρ"> <!ENTITY sigmaf "ς"> <!ENTITY sigma "σ"> <!ENTITY tau "τ"> <!ENTITY upsilon "υ"> <!ENTITY phi "φ"> <!ENTITY chi "χ"> <!ENTITY psi "ψ"> <!ENTITY omega "ω"> <!ENTITY thetasym "ϑ"> <!ENTITY upsih "ϒ"> <!ENTITY piv "ϖ"> <!ENTITY ensp " "> <!ENTITY emsp " "> <!ENTITY thinsp " "> <!ENTITY zwnj "‌"> <!ENTITY zwj "‍"> <!ENTITY lrm "‎"> <!ENTITY rlm "‏"> <!ENTITY ndash "–"> <!ENTITY mdash "—"> <!ENTITY lsquo "‘"> <!ENTITY rsquo "’"> <!ENTITY sbquo "‚"> <!ENTITY ldquo "“"> <!ENTITY rdquo "”"> <!ENTITY bdquo "„"> <!ENTITY dagger "†"> <!ENTITY Dagger "‡"> <!ENTITY bull "•"> <!ENTITY hellip "…"> <!ENTITY permil "‰"> <!ENTITY prime "′"> <!ENTITY Prime "″"> <!ENTITY lsaquo "‹"> <!ENTITY rsaquo "›"> <!ENTITY oline "‾"> <!ENTITY frasl "⁄"> <!ENTITY euro "€"> <!ENTITY image "ℑ"> <!ENTITY weierp "℘"> <!ENTITY real "ℜ"> <!ENTITY trade "™"> <!ENTITY alefsym "ℵ"> <!ENTITY larr "←"> <!ENTITY uarr "↑"> <!ENTITY rarr "→"> <!ENTITY darr "↓"> <!ENTITY harr "↔"> <!ENTITY crarr "↵"> <!ENTITY lArr "⇐"> <!ENTITY uArr "⇑"> <!ENTITY rArr "⇒"> <!ENTITY dArr "⇓"> <!ENTITY hArr "⇔"> <!ENTITY forall "∀"> <!ENTITY part "∂"> <!ENTITY exist "∃"> <!ENTITY empty "∅"> <!ENTITY nabla "∇"> <!ENTITY isin "∈"> <!ENTITY notin "∉"> <!ENTITY ni "∋"> <!ENTITY prod "∏"> <!ENTITY sum "∑"> <!ENTITY minus "−"> <!ENTITY lowast "∗"> <!ENTITY radic "√"> <!ENTITY prop "∝"> <!ENTITY infin "∞"> <!ENTITY ang "∠"> <!ENTITY and "∧"> <!ENTITY or "∨"> <!ENTITY cap "∩"> <!ENTITY cup "∪"> <!ENTITY int "∫"> <!ENTITY there4 "∴"> <!ENTITY sim "∼"> <!ENTITY cong "≅"> <!ENTITY asymp "≈"> <!ENTITY ne "≠"> <!ENTITY equiv "≡"> <!ENTITY le "≤"> <!ENTITY ge "≥"> <!ENTITY sub "⊂"> <!ENTITY sup "⊃"> <!ENTITY nsub "⊄"> <!ENTITY sube "⊆"> <!ENTITY supe "⊇"> <!ENTITY oplus "⊕"> <!ENTITY otimes "⊗"> <!ENTITY perp "⊥"> <!ENTITY sdot "⋅"> <!ENTITY lceil "⌈"> <!ENTITY rceil "⌉"> <!ENTITY lfloor "⌊"> <!ENTITY rfloor "⌋"> <!ENTITY lang "〈"> <!ENTITY rang "〉"> <!ENTITY loz "◊"> <!ENTITY spades "♠"> <!ENTITY clubs "♣"> <!ENTITY hearts "♥"> <!ENTITY diams "♦"> ]>';671 return '<!DOCTYPE rss [ <!ENTITY nbsp " "> <!ENTITY iexcl "¡"> <!ENTITY cent "¢"> <!ENTITY pound "£"> <!ENTITY curren "¤"> <!ENTITY yen "¥"> <!ENTITY brvbar "¦"> <!ENTITY sect "§"> <!ENTITY uml "¨"> <!ENTITY copy "©"> <!ENTITY ordf "ª"> <!ENTITY laquo "«"> <!ENTITY not "¬"> <!ENTITY shy "­"> <!ENTITY reg "®"> <!ENTITY macr "¯"> <!ENTITY deg "°"> <!ENTITY plusmn "±"> <!ENTITY sup2 "²"> <!ENTITY sup3 "³"> <!ENTITY acute "´"> <!ENTITY micro "µ"> <!ENTITY para "¶"> <!ENTITY middot "·"> <!ENTITY cedil "¸"> <!ENTITY sup1 "¹"> <!ENTITY ordm "º"> <!ENTITY raquo "»"> <!ENTITY frac14 "¼"> <!ENTITY frac12 "½"> <!ENTITY frac34 "¾"> <!ENTITY iquest "¿"> <!ENTITY Agrave "À"> <!ENTITY Aacute "Á"> <!ENTITY Acirc "Â"> <!ENTITY Atilde "Ã"> <!ENTITY Auml "Ä"> <!ENTITY Aring "Å"> <!ENTITY AElig "Æ"> <!ENTITY Ccedil "Ç"> <!ENTITY Egrave "È"> <!ENTITY Eacute "É"> <!ENTITY Ecirc "Ê"> <!ENTITY Euml "Ë"> <!ENTITY Igrave "Ì"> <!ENTITY Iacute "Í"> <!ENTITY Icirc "Î"> <!ENTITY Iuml "Ï"> <!ENTITY ETH "Ð"> <!ENTITY Ntilde "Ñ"> <!ENTITY Ograve "Ò"> <!ENTITY Oacute "Ó"> <!ENTITY Ocirc "Ô"> <!ENTITY Otilde "Õ"> <!ENTITY Ouml "Ö"> <!ENTITY times "×"> <!ENTITY Oslash "Ø"> <!ENTITY Ugrave "Ù"> <!ENTITY Uacute "Ú"> <!ENTITY Ucirc "Û"> <!ENTITY Uuml "Ü"> <!ENTITY Yacute "Ý"> <!ENTITY THORN "Þ"> <!ENTITY szlig "ß"> <!ENTITY agrave "à"> <!ENTITY aacute "á"> <!ENTITY acirc "â"> <!ENTITY atilde "ã"> <!ENTITY auml "ä"> <!ENTITY aring "å"> <!ENTITY aelig "æ"> <!ENTITY ccedil "ç"> <!ENTITY egrave "è"> <!ENTITY eacute "é"> <!ENTITY ecirc "ê"> <!ENTITY euml "ë"> <!ENTITY igrave "ì"> <!ENTITY iacute "í"> <!ENTITY icirc "î"> <!ENTITY iuml "ï"> <!ENTITY eth "ð"> <!ENTITY ntilde "ñ"> <!ENTITY ograve "ò"> <!ENTITY oacute "ó"> <!ENTITY ocirc "ô"> <!ENTITY otilde "õ"> <!ENTITY ouml "ö"> <!ENTITY divide "÷"> <!ENTITY oslash "ø"> <!ENTITY ugrave "ù"> <!ENTITY uacute "ú"> <!ENTITY ucirc "û"> <!ENTITY uuml "ü"> <!ENTITY yacute "ý"> <!ENTITY thorn "þ"> <!ENTITY yuml "ÿ"> <!ENTITY OElig "Œ"> <!ENTITY oelig "œ"> <!ENTITY Scaron "Š"> <!ENTITY scaron "š"> <!ENTITY Yuml "Ÿ"> <!ENTITY fnof "ƒ"> <!ENTITY circ "ˆ"> <!ENTITY tilde "˜"> <!ENTITY Alpha "Α"> <!ENTITY Beta "Β"> <!ENTITY Gamma "Γ"> <!ENTITY Epsilon "Ε"> <!ENTITY Zeta "Ζ"> <!ENTITY Eta "Η"> <!ENTITY Theta "Θ"> <!ENTITY Iota "Ι"> <!ENTITY Kappa "Κ"> <!ENTITY Lambda "Λ"> <!ENTITY Mu "Μ"> <!ENTITY Nu "Ν"> <!ENTITY Xi "Ξ"> <!ENTITY Omicron "Ο"> <!ENTITY Pi "Π"> <!ENTITY Rho "Ρ"> <!ENTITY Sigma "Σ"> <!ENTITY Tau "Τ"> <!ENTITY Upsilon "Υ"> <!ENTITY Phi "Φ"> <!ENTITY Chi "Χ"> <!ENTITY Psi "Ψ"> <!ENTITY Omega "Ω"> <!ENTITY alpha "α"> <!ENTITY beta "β"> <!ENTITY gamma "γ"> <!ENTITY delta "δ"> <!ENTITY epsilon "ε"> <!ENTITY zeta "ζ"> <!ENTITY eta "η"> <!ENTITY theta "θ"> <!ENTITY iota "ι"> <!ENTITY kappa "κ"> <!ENTITY lambda "λ"> <!ENTITY mu "μ"> <!ENTITY nu "ν"> <!ENTITY xi "ξ"> <!ENTITY omicron "ο"> <!ENTITY pi "π"> <!ENTITY rho "ρ"> <!ENTITY sigmaf "ς"> <!ENTITY sigma "σ"> <!ENTITY tau "τ"> <!ENTITY upsilon "υ"> <!ENTITY phi "φ"> <!ENTITY chi "χ"> <!ENTITY psi "ψ"> <!ENTITY omega "ω"> <!ENTITY thetasym "ϑ"> <!ENTITY upsih "ϒ"> <!ENTITY piv "ϖ"> <!ENTITY ensp " "> <!ENTITY emsp " "> <!ENTITY thinsp " "> <!ENTITY zwnj "‌"> <!ENTITY zwj "‍"> <!ENTITY lrm "‎"> <!ENTITY rlm "‏"> <!ENTITY ndash "–"> <!ENTITY mdash "—"> <!ENTITY lsquo "‘"> <!ENTITY rsquo "’"> <!ENTITY sbquo "‚"> <!ENTITY ldquo "“"> <!ENTITY rdquo "”"> <!ENTITY bdquo "„"> <!ENTITY dagger "†"> <!ENTITY Dagger "‡"> <!ENTITY bull "•"> <!ENTITY hellip "…"> <!ENTITY permil "‰"> <!ENTITY prime "′"> <!ENTITY Prime "″"> <!ENTITY lsaquo "‹"> <!ENTITY rsaquo "›"> <!ENTITY oline "‾"> <!ENTITY frasl "⁄"> <!ENTITY euro "€"> <!ENTITY image "ℑ"> <!ENTITY weierp "℘"> <!ENTITY real "ℜ"> <!ENTITY trade "™"> <!ENTITY alefsym "ℵ"> <!ENTITY larr "←"> <!ENTITY uarr "↑"> <!ENTITY rarr "→"> <!ENTITY darr "↓"> <!ENTITY harr "↔"> <!ENTITY crarr "↵"> <!ENTITY lArr "⇐"> <!ENTITY uArr "⇑"> <!ENTITY rArr "⇒"> <!ENTITY dArr "⇓"> <!ENTITY hArr "⇔"> <!ENTITY forall "∀"> <!ENTITY part "∂"> <!ENTITY exist "∃"> <!ENTITY empty "∅"> <!ENTITY nabla "∇"> <!ENTITY isin "∈"> <!ENTITY notin "∉"> <!ENTITY ni "∋"> <!ENTITY prod "∏"> <!ENTITY sum "∑"> <!ENTITY minus "−"> <!ENTITY lowast "∗"> <!ENTITY radic "√"> <!ENTITY prop "∝"> <!ENTITY infin "∞"> <!ENTITY ang "∠"> <!ENTITY and "∧"> <!ENTITY or "∨"> <!ENTITY cap "∩"> <!ENTITY cup "∪"> <!ENTITY int "∫"> <!ENTITY there4 "∴"> <!ENTITY sim "∼"> <!ENTITY cong "≅"> <!ENTITY asymp "≈"> <!ENTITY ne "≠"> <!ENTITY equiv "≡"> <!ENTITY le "≤"> <!ENTITY ge "≥"> <!ENTITY sub "⊂"> <!ENTITY sup "⊃"> <!ENTITY nsub "⊄"> <!ENTITY sube "⊆"> <!ENTITY supe "⊇"> <!ENTITY oplus "⊕"> <!ENTITY otimes "⊗"> <!ENTITY perp "⊥"> <!ENTITY sdot "⋅"> <!ENTITY lceil "⌈"> <!ENTITY rceil "⌉"> <!ENTITY lfloor "⌊"> <!ENTITY rfloor "⌋"> <!ENTITY lang "〈"> <!ENTITY rang "〉"> <!ENTITY loz "◊"> <!ENTITY spades "♠"> <!ENTITY clubs "♣"> <!ENTITY hearts "♥"> <!ENTITY diams "♦"> ]>'; 627 672 } 628 673 } -
trunk/src/wp-includes/SimplePie/src/Rating.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\SimplePie::set_rating_class()} 53 *54 * @package SimplePie55 * @subpackage API56 16 */ 57 17 class Rating … … 60 20 * Rating scheme 61 21 * 62 * @var string22 * @var ?string 63 23 * @see get_scheme() 64 24 */ … … 68 28 * Rating value 69 29 * 70 * @var string30 * @var ?string 71 31 * @see get_value() 72 32 */ … … 79 39 * properties and their accessors 80 40 */ 81 public function __construct($scheme = null, $value = null) 82 { 41 public function __construct( 42 ?string $scheme = null, 43 ?string $value = null 44 ) { 83 45 $this->scheme = $scheme; 84 46 $this->value = $value; -
trunk/src/wp-includes/SimplePie/src/Registry.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; 46 9 10 use InvalidArgumentException; 47 11 use SimplePie\Content\Type\Sniffer; 48 12 use SimplePie\Parse\Date; … … 53 17 * 54 18 * Access this via {@see \SimplePie\SimplePie::get_registry()} 55 *56 * @package SimplePie57 19 */ 58 20 class Registry … … 91 53 * 92 54 * @see register() 93 * @var array 55 * @var array<string, class-string> 94 56 */ 95 57 protected $classes = []; … … 148 110 * @return bool Successfulness 149 111 */ 150 public function register( $type, $class,$legacy = false)112 public function register(string $type, $class, bool $legacy = false) 151 113 { 152 114 if (array_key_exists($type, $this->legacyTypes)) { … … 201 163 } 202 164 165 // For PHPStan: values in $default should be subtypes of keys. 166 /** @var class-string<T> */ 203 167 $class = $this->default[$type]; 204 168 205 169 if (array_key_exists($type, $this->classes)) { 170 // For PHPStan: values in $classes should be subtypes of keys. 171 /** @var class-string<T> */ 206 172 $class = $this->classes[$type]; 207 173 } … … 215 181 * @template T class-string $type 216 182 * @param class-string<T> $type 217 * @param array $parameters Parameters to pass to the constructor183 * @param array<mixed> $parameters Parameters to pass to the constructor 218 184 * @return T Instance of class 219 185 */ 220 public function &create($type, $parameters = [])186 public function &create($type, array $parameters = []) 221 187 { 222 188 $class = $this->get_class($type); 189 if ($class === null) { 190 throw new InvalidArgumentException(sprintf( 191 '%s(): Argument #1 ($type) "%s" not found in class list.', 192 __METHOD__, 193 $type 194 ), 1); 195 } 223 196 224 197 if (!method_exists($class, '__construct')) { … … 226 199 } else { 227 200 $reflector = new \ReflectionClass($class); 201 // For PHPStan: $class is T. 202 /** @var T */ 228 203 $instance = $reflector->newInstanceArgs($parameters); 229 204 } … … 235 210 $instance->set_registry($this); 236 211 } 212 237 213 return $instance; 238 214 } … … 243 219 * @param class-string $type 244 220 * @param string $method 245 * @param array $parameters221 * @param array<mixed> $parameters 246 222 * @return mixed 247 223 */ 248 public function &call($type, $method,$parameters = [])224 public function &call($type, string $method, array $parameters = []) 249 225 { 250 226 $class = $this->get_class($type); 227 if ($class === null) { 228 throw new InvalidArgumentException(sprintf( 229 '%s(): Argument #1 ($type) "%s" not found in class list.', 230 __METHOD__, 231 $type 232 ), 1); 233 } 251 234 252 235 if (in_array($class, $this->legacy)) { … … 257 240 // No longer supported as of PHP 8.0. 258 241 if ($method === 'get_handler') { 242 // Fixing this PHPStan error breaks CacheTest::testDirectOverrideLegacy() 243 /** @phpstan-ignore argument.type */ 259 244 $result = @call_user_func_array([$class, 'create'], $parameters); 260 245 return $result; … … 264 249 } 265 250 266 $result = call_user_func_array([$class, $method], $parameters); 251 $callable = [$class, $method]; 252 assert(is_callable($callable), 'For PHPstan'); 253 $result = call_user_func_array($callable, $parameters); 267 254 return $result; 268 255 } -
trunk/src/wp-includes/SimplePie/src/RegistryAware.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-2022 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; … … 49 12 * 50 13 * {@see \SimplePie\SimplePie::get_registry()} 51 *52 * @package SimplePie53 14 */ 54 15 interface RegistryAware … … 57 18 * Set the Registry into the class 58 19 * 59 * @param Registry $registry60 *61 20 * @return void 62 21 */ 63 public function set_registry(Registry $registry) /* : void */;22 public function set_registry(Registry $registry); 64 23 } -
trunk/src/wp-includes/SimplePie/src/Restriction.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\SimplePie::set_restriction_class()} 53 *54 * @package SimplePie55 * @subpackage API56 16 */ 57 17 class Restriction 58 18 { 19 public const RELATIONSHIP_ALLOW = 'allow'; 20 public const RELATIONSHIP_DENY = 'deny'; 21 59 22 /** 60 23 * Relationship ('allow'/'deny') 61 24 * 62 * @var s tring25 * @var self::RELATIONSHIP_*|null 63 26 * @see get_relationship() 64 27 */ … … 68 31 * Type of restriction 69 32 * 70 * @var string 33 * @var string|null 71 34 * @see get_type() 72 35 */ … … 76 39 * Restricted values 77 40 * 78 * @var string 41 * @var string|null 79 42 * @see get_value() 80 43 */ … … 86 49 * For documentation on all the parameters, see the corresponding 87 50 * properties and their accessors 51 * 52 * @param ?self::RELATIONSHIP_* $relationship 88 53 */ 89 public function __construct( $relationship = null, $type = null,$value = null)54 public function __construct(?string $relationship = null, ?string $type = null, ?string $value = null) 90 55 { 91 56 $this->relationship = $relationship; … … 108 73 * Get the relationship 109 74 * 110 * @return string|null Either 'allow' or 'deny'75 * @return ?self::RELATIONSHIP_* 111 76 */ 112 77 public function get_relationship() -
trunk/src/wp-includes/SimplePie/src/Sanitize.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; 46 9 10 use DOMDocument; 11 use DOMXPath; 47 12 use InvalidArgumentException; 13 use Psr\Http\Client\ClientInterface; 14 use Psr\Http\Message\RequestFactoryInterface; 15 use Psr\Http\Message\UriFactoryInterface; 48 16 use SimplePie\Cache\Base; 49 17 use SimplePie\Cache\BaseDataCache; … … 51 19 use SimplePie\Cache\DataCache; 52 20 use SimplePie\Cache\NameFilter; 21 use SimplePie\HTTP\Client; 22 use SimplePie\HTTP\ClientException; 23 use SimplePie\HTTP\FileClient; 24 use SimplePie\HTTP\Psr18Client; 53 25 54 26 /** … … 58 30 * This class can be overloaded with {@see \SimplePie\SimplePie::set_sanitize_class()} 59 31 * 60 * @package SimplePie61 32 * @todo Move to using an actual HTML parser (this will allow tags to be properly stripped, and to switch between HTML and XHTML), this will also make it easier to shorten a string while preserving HTML tags 62 33 */ … … 64 35 { 65 36 // Private vars 66 public $base; 37 /** @var string */ 38 public $base = ''; 67 39 68 40 // Options 41 /** @var bool */ 69 42 public $remove_div = true; 43 /** @var string */ 70 44 public $image_handler = ''; 45 /** @var string[] */ 71 46 public $strip_htmltags = ['base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style']; 47 /** @var bool */ 72 48 public $encode_instead_of_strip = false; 49 /** @var string[] */ 73 50 public $strip_attributes = ['bgsound', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc']; 51 /** @var string[] */ 74 52 public $rename_attributes = []; 53 /** @var array<string, array<string, string>> */ 75 54 public $add_attributes = ['audio' => ['preload' => 'none'], 'iframe' => ['sandbox' => 'allow-scripts allow-same-origin'], 'video' => ['preload' => 'none']]; 55 /** @var bool */ 76 56 public $strip_comments = false; 57 /** @var string */ 77 58 public $output_encoding = 'UTF-8'; 59 /** @var bool */ 78 60 public $enable_cache = true; 61 /** @var string */ 79 62 public $cache_location = './cache'; 63 /** @var string&(callable(string): string) */ 80 64 public $cache_name_function = 'md5'; 81 65 … … 84 68 */ 85 69 private $cache_namefilter; 70 /** @var int */ 86 71 public $timeout = 10; 72 /** @var string */ 87 73 public $useragent = ''; 74 /** @var bool */ 88 75 public $force_fsockopen = false; 89 public $replace_url_attributes = null; 76 /** @var array<string, string|string[]> */ 77 public $replace_url_attributes = []; 78 /** 79 * @var array<int, mixed> Custom curl options 80 * @see SimplePie::set_curl_options() 81 */ 82 private $curl_options = []; 83 84 /** @var Registry */ 90 85 public $registry; 91 86 … … 105 100 * Array is a tree split at DNS levels. Example: 106 101 * array('biz' => true, 'com' => array('example' => true), 'net' => array('example' => array('www' => true))) 102 * @var true|array<string, true|array<string, true|array<string, array<string, true|array<string, true|array<string, true>>>>>> 107 103 */ 108 104 public $https_domains = []; 105 106 /** 107 * @var Client|null 108 */ 109 private $http_client = null; 109 110 110 111 public function __construct() … … 114 115 } 115 116 116 public function remove_div($enable = true) 117 /** 118 * @return void 119 */ 120 public function remove_div(bool $enable = true) 117 121 { 118 122 $this->remove_div = (bool) $enable; 119 123 } 120 124 125 /** 126 * @param string|false $page 127 * @return void 128 */ 121 129 public function set_image_handler($page = false) 122 130 { … … 124 132 $this->image_handler = (string) $page; 125 133 } else { 126 $this->image_handler = false; 127 } 128 } 129 130 public function set_registry(\SimplePie\Registry $registry)/* : void */ 134 $this->image_handler = ''; 135 } 136 } 137 138 /** 139 * @return void 140 */ 141 public function set_registry(\SimplePie\Registry $registry) 131 142 { 132 143 $this->registry = $registry; 133 144 } 134 145 135 public function pass_cache_data($enable_cache = true, $cache_location = './cache', $cache_name_function = 'md5', $cache_class = 'SimplePie\Cache', ?DataCache $cache = null) 136 { 137 if (isset($enable_cache)) { 138 $this->enable_cache = (bool) $enable_cache; 139 } 146 /** 147 * @param (string&(callable(string): string))|NameFilter $cache_name_function 148 * @param class-string<Cache> $cache_class 149 * @return void 150 */ 151 public function pass_cache_data(bool $enable_cache = true, string $cache_location = './cache', $cache_name_function = 'md5', string $cache_class = Cache::class, ?DataCache $cache = null) 152 { 153 $this->enable_cache = $enable_cache; 140 154 141 155 if ($cache_location) { 142 $this->cache_location = (string) $cache_location; 143 } 144 145 if (!is_string($cache_name_function) && !is_object($cache_name_function) && !$cache_name_function instanceof NameFilter) { 156 $this->cache_location = $cache_location; 157 } 158 159 // @phpstan-ignore-next-line Enforce PHPDoc type. 160 if (!is_string($cache_name_function) && !$cache_name_function instanceof NameFilter) { 146 161 throw new InvalidArgumentException(sprintf( 147 162 '%s(): Argument #3 ($cache_name_function) must be of type %s', … … 154 169 if (is_string($cache_name_function)) { 155 170 // trigger_error(sprintf('Providing $cache_name_function as string in "%s()" is deprecated since SimplePie 1.8.0, provide as "%s" instead.', __METHOD__, NameFilter::class), \E_USER_DEPRECATED); 156 $this->cache_name_function = (string)$cache_name_function;171 $this->cache_name_function = $cache_name_function; 157 172 158 173 $cache_name_function = new CallableNameFilter($cache_name_function); … … 166 181 } 167 182 168 public function pass_file_data($file_class = 'SimplePie\File', $timeout = 10, $useragent = '', $force_fsockopen = false) 169 { 183 /** 184 * Set a PSR-18 client and PSR-17 factories 185 * 186 * Allows you to use your own HTTP client implementations. 187 */ 188 final public function set_http_client( 189 ClientInterface $http_client, 190 RequestFactoryInterface $request_factory, 191 UriFactoryInterface $uri_factory 192 ): void { 193 $this->http_client = new Psr18Client($http_client, $request_factory, $uri_factory); 194 } 195 196 /** 197 * @deprecated since SimplePie 1.9.0, use \SimplePie\Sanitize::set_http_client() instead. 198 * @param class-string<File> $file_class 199 * @param array<int, mixed> $curl_options 200 * @return void 201 */ 202 public function pass_file_data(string $file_class = File::class, int $timeout = 10, string $useragent = '', bool $force_fsockopen = false, array $curl_options = []) 203 { 204 // trigger_error(sprintf('SimplePie\Sanitize::pass_file_data() is deprecated since SimplePie 1.9.0, please use "SimplePie\Sanitize::set_http_client()" instead.'), \E_USER_DEPRECATED); 170 205 if ($timeout) { 171 $this->timeout = (string)$timeout;206 $this->timeout = $timeout; 172 207 } 173 208 174 209 if ($useragent) { 175 $this->useragent = (string)$useragent;210 $this->useragent = $useragent; 176 211 } 177 212 178 213 if ($force_fsockopen) { 179 $this->force_fsockopen = (string) $force_fsockopen; 180 } 181 } 182 214 $this->force_fsockopen = $force_fsockopen; 215 } 216 217 $this->curl_options = $curl_options; 218 // Invalidate the registered client. 219 $this->http_client = null; 220 } 221 222 /** 223 * @param string[]|string|false $tags Set a list of tags to strip, or set empty string to use default tags, or false to strip nothing. 224 * @return void 225 */ 183 226 public function strip_htmltags($tags = ['base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style']) 184 227 { … … 190 233 } 191 234 } else { 192 $this->strip_htmltags = false; 193 } 194 } 195 196 public function encode_instead_of_strip($encode = false) 197 { 198 $this->encode_instead_of_strip = (bool) $encode; 199 } 200 235 $this->strip_htmltags = []; 236 } 237 } 238 239 /** 240 * @return void 241 */ 242 public function encode_instead_of_strip(bool $encode = false) 243 { 244 $this->encode_instead_of_strip = $encode; 245 } 246 247 /** 248 * @param string[]|string $attribs 249 * @return void 250 */ 201 251 public function rename_attributes($attribs = []) 202 252 { … … 208 258 } 209 259 } else { 210 $this->rename_attributes = false; 211 } 212 } 213 260 $this->rename_attributes = []; 261 } 262 } 263 264 /** 265 * @param string[]|string $attribs 266 * @return void 267 */ 214 268 public function strip_attributes($attribs = ['bgsound', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc']) 215 269 { … … 221 275 } 222 276 } else { 223 $this->strip_attributes = false; 224 } 225 } 226 227 public function add_attributes($attribs = ['audio' => ['preload' => 'none'], 'iframe' => ['sandbox' => 'allow-scripts allow-same-origin'], 'video' => ['preload' => 'none']]) 228 { 229 if ($attribs) { 230 if (is_array($attribs)) { 231 $this->add_attributes = $attribs; 232 } else { 233 $this->add_attributes = explode(',', $attribs); 234 } 235 } else { 236 $this->add_attributes = false; 237 } 238 } 239 240 public function strip_comments($strip = false) 241 { 242 $this->strip_comments = (bool) $strip; 243 } 244 245 public function set_output_encoding($encoding = 'UTF-8') 246 { 247 $this->output_encoding = (string) $encoding; 277 $this->strip_attributes = []; 278 } 279 } 280 281 /** 282 * @param array<string, array<string, string>> $attribs 283 * @return void 284 */ 285 public function add_attributes(array $attribs = ['audio' => ['preload' => 'none'], 'iframe' => ['sandbox' => 'allow-scripts allow-same-origin'], 'video' => ['preload' => 'none']]) 286 { 287 $this->add_attributes = $attribs; 288 } 289 290 /** 291 * @return void 292 */ 293 public function strip_comments(bool $strip = false) 294 { 295 $this->strip_comments = $strip; 296 } 297 298 /** 299 * @return void 300 */ 301 public function set_output_encoding(string $encoding = 'UTF-8') 302 { 303 $this->output_encoding = $encoding; 248 304 } 249 305 … … 257 313 * 258 314 * @since 1.0 259 * @param array|null $element_attribute Element/attribute key/value pairs, null for default 260 */ 261 public function set_url_replacements($element_attribute = null) 315 * @param array<string, string|string[]>|null $element_attribute Element/attribute key/value pairs, null for default 316 * @return void 317 */ 318 public function set_url_replacements(?array $element_attribute = null) 262 319 { 263 320 if ($element_attribute === null) { … … 283 340 ]; 284 341 } 285 $this->replace_url_attributes = (array)$element_attribute;342 $this->replace_url_attributes = $element_attribute; 286 343 } 287 344 … … 290 347 * @see \SimplePie\Misc::https_url() 291 348 * Example array('biz', 'example.com', 'example.org', 'www.example.net'); 292 */ 293 public function set_https_domains($domains) 349 * 350 * @param string[] $domains list of domain names ['biz', 'example.com', 'example.org', 'www.example.net'] 351 * 352 * @return void 353 */ 354 public function set_https_domains(array $domains) 294 355 { 295 356 $this->https_domains = []; … … 297 358 $domain = trim($domain, ". \t\n\r\0\x0B"); 298 359 $segments = array_reverse(explode('.', $domain)); 360 /** @var true|array<string, true|array<string, true|array<string, array<string, true|array<string, true|array<string, true>>>>>> */ // Needed for PHPStan. 299 361 $node = &$this->https_domains; 300 362 foreach ($segments as $segment) {//Build a tree … … 313 375 /** 314 376 * Check if the domain is in the list of forced HTTPS. 315 */ 316 protected function is_https_domain($domain) 377 * 378 * @return bool 379 */ 380 protected function is_https_domain(string $domain) 317 381 { 318 382 $domain = trim($domain, '. '); … … 331 395 /** 332 396 * Force HTTPS for selected Web sites. 333 */ 334 public function https_url($url) 335 { 336 return (strtolower(substr($url, 0, 7)) === 'http://') && 337 $this->is_https_domain(parse_url($url, PHP_URL_HOST)) ? 338 substr_replace($url, 's', 4, 0) : //Add the 's' to HTTPS 339 $url; 340 } 341 342 public function sanitize($data, $type, $base = '') 397 * 398 * @return string 399 */ 400 public function https_url(string $url) 401 { 402 return ( 403 strtolower(substr($url, 0, 7)) === 'http://' 404 && ($parsed = parse_url($url, PHP_URL_HOST)) !== false // Malformed URL 405 && $parsed !== null // Missing host 406 && $this->is_https_domain($parsed) // Should be forced? 407 ) ? substr_replace($url, 's', 4, 0) // Add the 's' to HTTPS 408 : $url; 409 } 410 411 /** 412 * @param int-mask-of<SimplePie::CONSTRUCT_*> $type 413 * @param string $base 414 * @return string Sanitized data; false if output encoding is changed to something other than UTF-8 and conversion fails 415 */ 416 public function sanitize(string $data, int $type, string $base = '') 343 417 { 344 418 $data = trim($data); … … 363 437 $document->encoding = 'UTF-8'; 364 438 439 // PHPStan seems to have trouble resolving int-mask because bitwise 440 // operators are used when operators are used when passing this parameter. 441 // https://github.com/phpstan/phpstan/issues/9384 442 /** @var int-mask-of<SimplePie::CONSTRUCT_*> $type */ 365 443 $data = $this->preprocess($data, $type); 366 444 367 set_error_handler([ 'SimplePie\Misc', 'silence_errors']);445 set_error_handler([Misc::class, 'silence_errors']); 368 446 $document->loadHTML($data); 369 447 restore_error_handler(); … … 373 451 // Strip comments 374 452 if ($this->strip_comments) { 453 /** @var \DOMNodeList<\DOMComment> */ 375 454 $comments = $xpath->query('//comment()'); 376 455 377 456 foreach ($comments as $comment) { 378 $comment->parentNode->removeChild($comment); 457 $parentNode = $comment->parentNode; 458 assert($parentNode !== null, 'For PHPStan, comment must have a parent'); 459 $parentNode->removeChild($comment); 379 460 } 380 461 } … … 382 463 // Strip out HTML tags and attributes that might cause various security problems. 383 464 // Based on recommendations by Mark Pilgrim at: 384 // http ://diveintomark.org/archives/2003/06/12/how_to_consume_rss_safely465 // https://web.archive.org/web/20110902041826/http://diveintomark.org:80/archives/2003/06/12/how_to_consume_rss_safely 385 466 if ($this->strip_htmltags) { 386 467 foreach ($this->strip_htmltags as $tag) { … … 414 495 415 496 // If image handling (caching, etc.) is enabled, cache and rewrite all the image tags. 416 if ( isset($this->image_handler) && ((string) $this->image_handler)!== '' && $this->enable_cache) {497 if ($this->image_handler !== '' && $this->enable_cache) { 417 498 $images = $document->getElementsByTagName('img'); 418 499 … … 425 506 $img->setAttribute('src', $this->image_handler . $image_url); 426 507 } else { 427 $file = $this->registry->create(File::class, [$img->getAttribute('src'), $this->timeout, 5, ['X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']], $this->useragent, $this->force_fsockopen]); 428 $headers = $file->headers; 429 430 if ($file->success && ($file->method & \SimplePie\SimplePie::FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) { 431 if ($cache->set_data($image_url, ['headers' => $file->headers, 'body' => $file->body], $this->cache_duration)) { 508 try { 509 $file = $this->get_http_client()->request( 510 Client::METHOD_GET, 511 $img->getAttribute('src'), 512 ['X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']] 513 ); 514 } catch (ClientException $th) { 515 continue; 516 } 517 518 if ((!Misc::is_remote_uri($file->get_final_requested_uri()) || ($file->get_status_code() === 200 || $file->get_status_code() > 206 && $file->get_status_code() < 300))) { 519 if ($cache->set_data($image_url, ['headers' => $file->get_headers(), 'body' => $file->get_body_content()], $this->cache_duration)) { 432 520 $img->setAttribute('src', $this->image_handler . $image_url); 433 521 } else { … … 441 529 442 530 // Get content node 443 $div = $document->getElementsByTagName('body')->item(0)->firstChild; 531 $div = null; 532 if (($item = $document->getElementsByTagName('body')->item(0)) !== null) { 533 $div = $item->firstChild; 534 } 444 535 // Finally, convert to a HTML string 445 $data = trim( $document->saveHTML($div));536 $data = trim((string) $document->saveHTML($div)); 446 537 447 538 if ($this->remove_div) { 448 539 $data = preg_replace('/^<div' . \SimplePie\SimplePie::PCRE_XML_ATTRIBUTE . '>/', '', $data); 449 $data = preg_replace('/<\/div>$/', '', $data); 540 // Cast for PHPStan, it is unable to validate a non-literal regex above. 541 $data = preg_replace('/<\/div>$/', '', (string) $data); 450 542 } else { 451 543 $data = preg_replace('/^<div' . \SimplePie\SimplePie::PCRE_XML_ATTRIBUTE . '>/', '<div>', $data); 452 544 } 453 545 454 $data = str_replace('</source>', '', $data); 546 // Cast for PHPStan, it is unable to validate a non-literal regex above. 547 $data = str_replace('</source>', '', (string) $data); 455 548 } 456 549 … … 467 560 468 561 if ($this->output_encoding !== 'UTF-8') { 562 // This really returns string|false but changing encoding is uncommon and we are going to deprecate it, so let’s just lie to PHPStan in the interest of cleaner annotations. 563 /** @var string */ 469 564 $data = $this->registry->call(Misc::class, 'change_encoding', [$data, 'UTF-8', $this->output_encoding]); 470 565 } … … 473 568 } 474 569 475 protected function preprocess($html, $type) 570 /** 571 * @param int-mask-of<SimplePie::CONSTRUCT_*> $type 572 * @return string 573 */ 574 protected function preprocess(string $html, int $type) 476 575 { 477 576 $ret = ''; … … 494 593 } 495 594 496 public function replace_urls($document, $tag, $attributes) 595 /** 596 * @param array<string>|string $attributes 597 * @return void 598 */ 599 public function replace_urls(DOMDocument $document, string $tag, $attributes) 497 600 { 498 601 if (!is_array($attributes)) { … … 516 619 } 517 620 518 public function do_strip_htmltags($match) 621 /** 622 * @param array<int, string> $match 623 * @return string 624 */ 625 public function do_strip_htmltags(array $match) 519 626 { 520 627 if ($this->encode_instead_of_strip) { … … 533 640 } 534 641 535 protected function strip_tag($tag, $document, $xpath, $type) 642 /** 643 * @param int-mask-of<SimplePie::CONSTRUCT_*> $type 644 * @return void 645 */ 646 protected function strip_tag(string $tag, DOMDocument $document, DOMXPath $xpath, int $type) 536 647 { 537 648 $elements = $xpath->query('body//' . $tag); 649 650 if ($elements === false) { 651 throw new \SimplePie\Exception(sprintf( 652 '%s(): Possibly malformed expression, check argument #1 ($tag)', 653 __METHOD__ 654 ), 1); 655 } 656 538 657 if ($this->encode_instead_of_strip) { 539 658 foreach ($elements as $element) { … … 543 662 if (!in_array($tag, ['script', 'style'])) { 544 663 $text = '<' . $tag; 545 if ($element-> hasAttributes()) {664 if ($element->attributes !== null) { 546 665 $attrs = []; 547 666 foreach ($element->attributes as $name => $attr) { … … 569 688 $number = $element->childNodes->length; 570 689 for ($i = $number; $i > 0; $i--) { 571 $child = $element->childNodes->item(0); 572 $fragment->appendChild($child); 690 if (($child = $element->childNodes->item(0)) !== null) { 691 $fragment->appendChild($child); 692 } 573 693 } 574 694 … … 577 697 } 578 698 579 $element->parentNode->replaceChild($fragment, $element); 699 if (($parentNode = $element->parentNode) !== null) { 700 $parentNode->replaceChild($fragment, $element); 701 } 580 702 } 581 703 … … 583 705 } elseif (in_array($tag, ['script', 'style'])) { 584 706 foreach ($elements as $element) { 585 $element->parentNode->removeChild($element); 707 if (($parentNode = $element->parentNode) !== null) { 708 $parentNode->removeChild($element); 709 } 586 710 } 587 711 … … 592 716 $number = $element->childNodes->length; 593 717 for ($i = $number; $i > 0; $i--) { 594 $child = $element->childNodes->item(0); 595 $fragment->appendChild($child); 596 } 597 598 $element->parentNode->replaceChild($fragment, $element); 599 } 600 } 601 } 602 603 protected function strip_attr($attrib, $xpath) 718 if (($child = $element->childNodes->item(0)) !== null) { 719 $fragment->appendChild($child); 720 } 721 } 722 723 if (($parentNode = $element->parentNode) !== null) { 724 $parentNode->replaceChild($fragment, $element); 725 } 726 } 727 } 728 } 729 730 /** 731 * @return void 732 */ 733 protected function strip_attr(string $attrib, DOMXPath $xpath) 604 734 { 605 735 $elements = $xpath->query('//*[@' . $attrib . ']'); 606 736 737 if ($elements === false) { 738 throw new \SimplePie\Exception(sprintf( 739 '%s(): Possibly malformed expression, check argument #1 ($attrib)', 740 __METHOD__ 741 ), 1); 742 } 743 744 /** @var \DOMElement $element */ 607 745 foreach ($elements as $element) { 608 746 $element->removeAttribute($attrib); … … 610 748 } 611 749 612 protected function rename_attr($attrib, $xpath) 750 /** 751 * @return void 752 */ 753 protected function rename_attr(string $attrib, DOMXPath $xpath) 613 754 { 614 755 $elements = $xpath->query('//*[@' . $attrib . ']'); 615 756 757 if ($elements === false) { 758 throw new \SimplePie\Exception(sprintf( 759 '%s(): Possibly malformed expression, check argument #1 ($attrib)', 760 __METHOD__ 761 ), 1); 762 } 763 764 /** @var \DOMElement $element */ 616 765 foreach ($elements as $element) { 617 766 $element->setAttribute('data-sanitized-' . $attrib, $element->getAttribute($attrib)); … … 620 769 } 621 770 622 protected function add_attr($tag, $valuePairs, $document) 771 /** 772 * @param array<string, string> $valuePairs 773 * @return void 774 */ 775 protected function add_attr(string $tag, array $valuePairs, DOMDocument $document) 623 776 { 624 777 $elements = $document->getElementsByTagName($tag); 778 /** @var \DOMElement $element */ 625 779 foreach ($elements as $element) { 626 780 foreach ($valuePairs as $attrib => $value) { … … 637 791 * @return DataCache 638 792 */ 639 private function get_cache( $image_url = '')793 private function get_cache(string $image_url = ''): DataCache 640 794 { 641 795 if ($this->cache === null) { … … 652 806 return $this->cache; 653 807 } 808 809 /** 810 * Get a HTTP client 811 */ 812 private function get_http_client(): Client 813 { 814 if ($this->http_client === null) { 815 $this->http_client = new FileClient( 816 $this->registry, 817 [ 818 'timeout' => $this->timeout, 819 'redirects' => 5, 820 'useragent' => $this->useragent, 821 'force_fsockopen' => $this->force_fsockopen, 822 'curl_options' => $this->curl_options, 823 ] 824 ); 825 } 826 827 return $this->http_client; 828 } 654 829 } 655 830 -
trunk/src/wp-includes/SimplePie/src/SimplePie.php
r60490 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; 46 9 47 10 use InvalidArgumentException; 11 use Psr\Http\Client\ClientInterface; 12 use Psr\Http\Message\RequestFactoryInterface; 13 use Psr\Http\Message\UriFactoryInterface; 48 14 use Psr\SimpleCache\CacheInterface; 49 15 use SimplePie\Cache\Base; … … 54 20 use SimplePie\Cache\Psr16; 55 21 use SimplePie\Content\Type\Sniffer; 22 use SimplePie\Exception as SimplePieException; 23 use SimplePie\HTTP\Client; 24 use SimplePie\HTTP\ClientException; 25 use SimplePie\HTTP\FileClient; 26 use SimplePie\HTTP\Psr18Client; 27 use SimplePie\HTTP\Response; 56 28 57 29 /** 58 30 * SimplePie 59 *60 * @package SimplePie61 * @subpackage API62 31 */ 63 32 class SimplePie … … 71 40 * SimplePie Version 72 41 */ 73 public const VERSION = '1. 8.1';42 public const VERSION = '1.9.0'; 74 43 75 44 /** … … 412 381 413 382 /** 414 * @var array Raw data 383 * @internal Default value of the HTTP Accept header when fetching/locating feeds 384 */ 385 public const DEFAULT_HTTP_ACCEPT_HEADER = 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1'; 386 387 /** 388 * @var array<string, mixed> Raw data 415 389 * @access private 416 390 */ … … 418 392 419 393 /** 420 * @var mixed Error string394 * @var string|string[]|null Error string (or array when multiple feeds are initialized) 421 395 * @access private 422 396 */ 423 public $error ;397 public $error = null; 424 398 425 399 /** … … 431 405 432 406 /** 433 * @var object Instance of \SimplePie\Sanitize (or other class)407 * @var Sanitize instance of Sanitize class 434 408 * @see SimplePie::set_sanitize_class() 435 409 * @access private … … 452 426 453 427 /** 454 * @var string Original feed URL, or new feed URL iff HTTP 301 Moved Permanently428 * @var ?string Original feed URL, or new feed URL iff HTTP 301 Moved Permanently 455 429 * @see SimplePie::subscribe_url() 456 430 * @access private … … 459 433 460 434 /** 461 * @var object Instance of \SimplePie\Fileto use as a feed435 * @var File Instance of File class to use as a feed 462 436 * @see SimplePie::set_file() 463 * @access private 464 */ 465 public $file; 466 467 /** 468 * @var string Raw feed data 437 */ 438 private $file; 439 440 /** 441 * @var string|false Raw feed data 469 442 * @see SimplePie::set_raw_data() 470 443 * @access private … … 480 453 481 454 /** 482 * @var array Custom curl options455 * @var array<int, mixed> Custom curl options 483 456 * @see SimplePie::set_curl_options() 484 457 * @access private … … 551 524 552 525 /** 553 * @var string Function that creates the cache filename526 * @var string&(callable(string): string) Function that creates the cache filename 554 527 * @see SimplePie::set_cache_name_function() 555 528 * @access private … … 573 546 574 547 /** 575 * @var intFeed Autodiscovery Level548 * @var self::LOCATOR_* Feed Autodiscovery Level 576 549 * @see SimplePie::set_autodiscovery_level() 577 550 * @access private … … 582 555 * Class registry object 583 556 * 584 * @var \SimplePie\Registry557 * @var Registry 585 558 */ 586 559 public $registry; … … 594 567 595 568 /** 596 * @var array All the feeds found during the autodiscovery process569 * @var array<Response>|null All the feeds found during the autodiscovery process 597 570 * @see SimplePie::get_all_discovered_feeds() 598 571 * @access private … … 608 581 609 582 /** 610 * @var array Stores the URLs when multiple feeds are being initialized.583 * @var array<string> Stores the URLs when multiple feeds are being initialized. 611 584 * @see SimplePie::set_feed_url() 612 585 * @access private … … 615 588 616 589 /** 617 * @var array Stores SimplePie objects when multiple feeds initialized.590 * @var array<int, static> Stores SimplePie objects when multiple feeds initialized. 618 591 * @access private 619 592 */ … … 621 594 622 595 /** 623 * @var array Stores the get_object_vars() array for use with multifeeds.596 * @var array<mixed> Stores the get_object_vars() array for use with multifeeds. 624 597 * @see SimplePie::set_feed_url() 625 598 * @access private … … 628 601 629 602 /** 630 * @var int egerStores the number of items to return per-feed with multifeeds.603 * @var int Stores the number of items to return per-feed with multifeeds. 631 604 * @see SimplePie::set_item_limit() 632 605 * @access private … … 641 614 642 615 /** 643 * @var array Stores the default attributes to be stripped by strip_attributes().616 * @var array<string> Stores the default attributes to be stripped by strip_attributes(). 644 617 * @see SimplePie::strip_attributes() 645 618 * @access private … … 648 621 649 622 /** 650 * @var array Stores the default attributes to add to different tags by add_attributes().623 * @var array<string, array<string, string>> Stores the default attributes to add to different tags by add_attributes(). 651 624 * @see SimplePie::add_attributes() 652 625 * @access private … … 655 628 656 629 /** 657 * @var array Stores the default tags to be stripped by strip_htmltags().630 * @var array<string> Stores the default tags to be stripped by strip_htmltags(). 658 631 * @see SimplePie::strip_htmltags() 659 632 * @access private … … 662 635 663 636 /** 664 * @var arrayStores the default attributes to be renamed by rename_attributes().637 * @var string[]|string Stores the default attributes to be renamed by rename_attributes(). 665 638 * @see SimplePie::rename_attributes() 666 639 * @access private … … 673 646 */ 674 647 public $enable_exceptions = false; 648 649 /** 650 * @var Client|null 651 */ 652 private $http_client = null; 653 654 /** @var bool Whether HTTP client has been injected */ 655 private $http_client_injected = false; 675 656 676 657 /** … … 699 680 700 681 // Other objects, instances created here so we can set options on them 701 $this->sanitize = new \SimplePie\Sanitize();702 $this->registry = new \SimplePie\Registry();682 $this->sanitize = new Sanitize(); 683 $this->registry = new Registry(); 703 684 704 685 if (func_num_args() > 0) { … … 722 703 /** 723 704 * Used for converting object to a string 705 * @return string 724 706 */ 725 707 public function __toString() … … 730 712 /** 731 713 * Remove items that link back to this before destroying this object 714 * @return void 732 715 */ 733 716 public function __destruct() … … 757 740 * @since 1.1 758 741 * @param bool $enable Force the given data/URL to be treated as a feed 759 */ 760 public function force_feed($enable = false) 761 { 762 $this->force_feed = (bool) $enable; 742 * @return void 743 */ 744 public function force_feed(bool $enable = false) 745 { 746 $this->force_feed = $enable; 763 747 } 764 748 … … 770 754 * over any set raw data. 771 755 * 772 * You can set multiple feeds to mash together by passing an array instead756 * Deprecated since 1.9.0: You can set multiple feeds to mash together by passing an array instead 773 757 * of a string for the $url. Remember that with each additional feed comes 774 758 * additional processing and resources. … … 776 760 * @since 1.0 Preview Release 777 761 * @see set_raw_data() 778 * @param string|array $url This is the URL (or array of URLs) that you want to parse. 762 * @param string|string[] $url This is the URL (or (deprecated) array of URLs) that you want to parse. 763 * @return void 779 764 */ 780 765 public function set_feed_url($url) … … 782 767 $this->multifeed_url = []; 783 768 if (is_array($url)) { 769 trigger_error('Fetching multiple feeds with single SimplePie instance is deprecated since SimplePie 1.9.0, create one SimplePie instance per feed and use SimplePie::merge_items to get a single list of items.', \E_USER_DEPRECATED); 784 770 foreach ($url as $value) { 785 771 $this->multifeed_url[] = $this->registry->call(Misc::class, 'fix_protocol', [$value, 1]); … … 792 778 793 779 /** 794 * Set an instance of {@see \SimplePie\File} to use as a feed 795 * 796 * @param \SimplePie\File &$file 780 * Set an instance of {@see File} to use as a feed 781 * 782 * @deprecated since SimplePie 1.9.0, use \SimplePie\SimplePie::set_http_client() or \SimplePie\SimplePie::set_raw_data() instead. 783 * 784 * @param File &$file 797 785 * @return bool True on success, false on failure 798 786 */ 799 public function set_file( &$file)800 { 801 if ($file instanceof \SimplePie\File) {802 $this->feed_url = $file->url; 803 $this->permanent_url = $this->feed_url;804 $this->file = &$file;805 return true;806 } 807 return false;787 public function set_file(File &$file) 788 { 789 // trigger_error(sprintf('SimplePie\SimplePie::set_file() is deprecated since SimplePie 1.9.0, please use "SimplePie\SimplePie::set_http_client()" or "SimplePie\SimplePie::set_raw_data()" instead.'), \E_USER_DEPRECATED); 790 791 $this->feed_url = $file->get_final_requested_uri(); 792 $this->permanent_url = $this->feed_url; 793 $this->file = &$file; 794 795 return true; 808 796 } 809 797 … … 820 808 * @param string $data RSS or Atom data as a string. 821 809 * @see set_feed_url() 822 */ 823 public function set_raw_data($data) 810 * @return void 811 */ 812 public function set_raw_data(string $data) 824 813 { 825 814 $this->raw_data = $data; 815 } 816 817 /** 818 * Set a PSR-18 client and PSR-17 factories 819 * 820 * Allows you to use your own HTTP client implementations. 821 * This will become required with SimplePie 2.0.0. 822 */ 823 final public function set_http_client( 824 ClientInterface $http_client, 825 RequestFactoryInterface $request_factory, 826 UriFactoryInterface $uri_factory 827 ): void { 828 $this->http_client = new Psr18Client($http_client, $request_factory, $uri_factory); 826 829 } 827 830 … … 834 837 * @since 1.0 Beta 3 835 838 * @param int $timeout The maximum number of seconds to spend waiting to retrieve a feed. 836 */ 837 public function set_timeout($timeout = 10) 838 { 839 * @return void 840 */ 841 public function set_timeout(int $timeout = 10) 842 { 843 if ($this->http_client_injected) { 844 throw new SimplePieException(sprintf( 845 'Using "%s()" has no effect, because you already provided a HTTP client with "%s::set_http_client()". Configure timeout in your HTTP client instead.', 846 __METHOD__, 847 self::class 848 )); 849 } 850 839 851 $this->timeout = (int) $timeout; 852 853 // Reset a possible existing FileClient, 854 // so a new client with the changed value will be created 855 if (is_object($this->http_client) && $this->http_client instanceof FileClient) { 856 $this->http_client = null; 857 } elseif (is_object($this->http_client)) { 858 // Trigger notice if a PSR-18 client was set 859 trigger_error(sprintf( 860 'Using "%s()" has no effect, because you already provided a HTTP client with "%s::set_http_client()". Configure the timeout in your HTTP client instead.', 861 __METHOD__, 862 get_class($this) 863 ), \E_USER_NOTICE); 864 } 840 865 } 841 866 … … 846 871 * 847 872 * @since 1.0 Beta 3 848 * @param array $curl_options Curl options to add to default settings 873 * @param array<int, mixed> $curl_options Curl options to add to default settings 874 * @return void 849 875 */ 850 876 public function set_curl_options(array $curl_options = []) 851 877 { 878 if ($this->http_client_injected) { 879 throw new SimplePieException(sprintf( 880 'Using "%s()" has no effect, because you already provided a HTTP client with "%s::set_http_client()". Configure custom curl options in your HTTP client instead.', 881 __METHOD__, 882 self::class 883 )); 884 } 885 852 886 $this->curl_options = $curl_options; 887 888 // Reset a possible existing FileClient, 889 // so a new client with the changed value will be created 890 if (is_object($this->http_client) && $this->http_client instanceof FileClient) { 891 $this->http_client = null; 892 } elseif (is_object($this->http_client)) { 893 // Trigger notice if a PSR-18 client was set 894 trigger_error(sprintf( 895 'Using "%s()" has no effect, because you already provided a HTTP client with "%s::set_http_client()". Configure the curl options in your HTTP client instead.', 896 __METHOD__, 897 get_class($this) 898 ), \E_USER_NOTICE); 899 } 853 900 } 854 901 … … 858 905 * @since 1.0 Beta 3 859 906 * @param bool $enable Force fsockopen() to be used 860 */ 861 public function force_fsockopen($enable = false) 862 { 863 $this->force_fsockopen = (bool) $enable; 907 * @return void 908 */ 909 public function force_fsockopen(bool $enable = false) 910 { 911 if ($this->http_client_injected) { 912 throw new SimplePieException(sprintf( 913 'Using "%s()" has no effect, because you already provided a HTTP client with "%s::set_http_client()". Configure fsockopen in your HTTP client instead.', 914 __METHOD__, 915 self::class 916 )); 917 } 918 919 $this->force_fsockopen = $enable; 920 921 // Reset a possible existing FileClient, 922 // so a new client with the changed value will be created 923 if (is_object($this->http_client) && $this->http_client instanceof FileClient) { 924 $this->http_client = null; 925 } elseif (is_object($this->http_client)) { 926 // Trigger notice if a PSR-18 client was set 927 trigger_error(sprintf( 928 'Using "%s()" has no effect, because you already provided a HTTP client with "%s::set_http_client()". Configure fsockopen in your HTTP client instead.', 929 __METHOD__, 930 get_class($this) 931 ), \E_USER_NOTICE); 932 } 864 933 } 865 934 … … 872 941 * @since 1.0 Preview Release 873 942 * @param bool $enable Enable caching 874 */ 875 public function enable_cache($enable = true) 876 { 877 $this->enable_cache = (bool) $enable; 943 * @return void 944 */ 945 public function enable_cache(bool $enable = true) 946 { 947 $this->enable_cache = $enable; 878 948 } 879 949 … … 881 951 * Set a PSR-16 implementation as cache 882 952 * 883 * @param CacheInterface $ psr16cache The PSR-16 cache implementation953 * @param CacheInterface $cache The PSR-16 cache implementation 884 954 * 885 955 * @return void … … 901 971 * 902 972 * @param bool $enable Force use of cache on fail. 903 */ 904 public function force_cache_fallback($enable = false) 973 * @return void 974 */ 975 public function force_cache_fallback(bool $enable = false) 905 976 { 906 977 // @trigger_error(sprintf('SimplePie\SimplePie::force_cache_fallback() is deprecated since SimplePie 1.8.0, expired cache will not be used anymore.'), \E_USER_DEPRECATED); 907 $this->force_cache_fallback = (bool)$enable;978 $this->force_cache_fallback = $enable; 908 979 } 909 980 … … 913 984 * 914 985 * @param int $seconds The feed content cache duration 915 */ 916 public function set_cache_duration($seconds = 3600) 917 { 918 $this->cache_duration = (int) $seconds; 986 * @return void 987 */ 988 public function set_cache_duration(int $seconds = 3600) 989 { 990 $this->cache_duration = $seconds; 919 991 } 920 992 … … 924 996 * 925 997 * @param int $seconds The autodiscovered feed URL cache duration. 926 */ 927 public function set_autodiscovery_cache_duration($seconds = 604800) 928 { 929 $this->autodiscovery_cache_duration = (int) $seconds; 998 * @return void 999 */ 1000 public function set_autodiscovery_cache_duration(int $seconds = 604800) 1001 { 1002 $this->autodiscovery_cache_duration = $seconds; 930 1003 } 931 1004 … … 933 1006 * Set the file system location where the cached files should be stored 934 1007 * 935 * @deprecated since SimplePie 1.8.0, use \SimplePie\SimplePie::set_cache() instead.1008 * @deprecated since SimplePie 1.8.0, use SimplePie::set_cache() instead. 936 1009 * 937 1010 * @param string $location The file system location. 938 */ 939 public function set_cache_location($location = './cache') 1011 * @return void 1012 */ 1013 public function set_cache_location(string $location = './cache') 940 1014 { 941 1015 // @trigger_error(sprintf('SimplePie\SimplePie::set_cache_location() is deprecated since SimplePie 1.8.0, please use "SimplePie\SimplePie::set_cache()" instead.'), \E_USER_DEPRECATED); 942 $this->cache_location = (string)$location;1016 $this->cache_location = $location; 943 1017 } 944 1018 … … 949 1023 * @return string A filename (i.e. hash, without path and without extension). 950 1024 */ 951 public function get_cache_filename( $url)1025 public function get_cache_filename(string $url) 952 1026 { 953 1027 // Append custom parameters to the URL to avoid cache pollution in case of multiple calls with different parameters. … … 957 1031 $options[CURLOPT_TIMEOUT] = $this->timeout; 958 1032 } 959 if ($this->useragent !== \SimplePie\Misc::get_default_useragent()) {1033 if ($this->useragent !== Misc::get_default_useragent()) { 960 1034 $options[CURLOPT_USERAGENT] = $this->useragent; 961 1035 } … … 977 1051 * 978 1052 * @param bool $enable Sort as reverse chronological order. 979 */ 980 public function enable_order_by_date($enable = true) 981 { 982 $this->order_by_date = (bool) $enable; 1053 * @return void 1054 */ 1055 public function enable_order_by_date(bool $enable = true) 1056 { 1057 $this->order_by_date = $enable; 983 1058 } 984 1059 … … 989 1064 * back to the normal encoding detection if the override fails 990 1065 * 991 * @param string $encoding Character encoding 1066 * @param string|false $encoding Character encoding 1067 * @return void 992 1068 */ 993 1069 public function set_input_encoding($encoding = false) … … 1003 1079 * Set how much feed autodiscovery to do 1004 1080 * 1005 * @see \SimplePie\SimplePie::LOCATOR_NONE 1006 * @see \SimplePie\SimplePie::LOCATOR_AUTODISCOVERY 1007 * @see \SimplePie\SimplePie::LOCATOR_LOCAL_EXTENSION 1008 * @see \SimplePie\SimplePie::LOCATOR_LOCAL_BODY 1009 * @see \SimplePie\SimplePie::LOCATOR_REMOTE_EXTENSION 1010 * @see \SimplePie\SimplePie::LOCATOR_REMOTE_BODY 1011 * @see \SimplePie\SimplePie::LOCATOR_ALL 1012 * @param int $level Feed Autodiscovery Level (level can be a combination of the above constants, see bitwise OR operator) 1013 */ 1014 public function set_autodiscovery_level($level = self::LOCATOR_ALL) 1015 { 1016 $this->autodiscovery = (int) $level; 1081 * @see self::LOCATOR_NONE 1082 * @see self::LOCATOR_AUTODISCOVERY 1083 * @see self::LOCATOR_LOCAL_EXTENSION 1084 * @see self::LOCATOR_LOCAL_BODY 1085 * @see self::LOCATOR_REMOTE_EXTENSION 1086 * @see self::LOCATOR_REMOTE_BODY 1087 * @see self::LOCATOR_ALL 1088 * @param self::LOCATOR_* $level Feed Autodiscovery Level (level can be a combination of the above constants, see bitwise OR operator) 1089 * @return void 1090 */ 1091 public function set_autodiscovery_level(int $level = self::LOCATOR_ALL) 1092 { 1093 $this->autodiscovery = $level; 1017 1094 } 1018 1095 … … 1021 1098 * 1022 1099 * Use this to override SimplePie's default classes 1023 * @see \SimplePie\Registry1024 1100 * 1025 1101 * @return Registry … … 1035 1111 * @deprecated since SimplePie 1.3, use {@see set_cache()} instead 1036 1112 * 1037 * @param string$class Name of custom class1038 * 1039 * @return bool eanTrue on success, false otherwise1040 */ 1041 public function set_cache_class( $class = Cache::class)1042 { 1043 //trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::set_cache()" instead.', __METHOD__), \E_USER_DEPRECATED);1113 * @param class-string<Cache> $class Name of custom class 1114 * 1115 * @return bool True on success, false otherwise 1116 */ 1117 public function set_cache_class(string $class = Cache::class) 1118 { 1119 trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::set_cache()" instead.', __METHOD__), \E_USER_DEPRECATED); 1044 1120 1045 1121 return $this->registry->register(Cache::class, $class, true); … … 1051 1127 * @deprecated since SimplePie 1.3, use {@see get_registry()} instead 1052 1128 * 1053 * @param string$class Name of custom class1054 * 1055 * @return bool eanTrue on success, false otherwise1056 */ 1057 public function set_locator_class( $class = Locator::class)1058 { 1059 //trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);1129 * @param class-string<Locator> $class Name of custom class 1130 * 1131 * @return bool True on success, false otherwise 1132 */ 1133 public function set_locator_class(string $class = Locator::class) 1134 { 1135 trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED); 1060 1136 1061 1137 return $this->registry->register(Locator::class, $class, true); … … 1067 1143 * @deprecated since SimplePie 1.3, use {@see get_registry()} instead 1068 1144 * 1069 * @param string$class Name of custom class1070 * 1071 * @return bool eanTrue on success, false otherwise1072 */ 1073 public function set_parser_class( $class = Parser::class)1074 { 1075 //trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);1145 * @param class-string<Parser> $class Name of custom class 1146 * 1147 * @return bool True on success, false otherwise 1148 */ 1149 public function set_parser_class(string $class = Parser::class) 1150 { 1151 trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED); 1076 1152 1077 1153 return $this->registry->register(Parser::class, $class, true); … … 1083 1159 * @deprecated since SimplePie 1.3, use {@see get_registry()} instead 1084 1160 * 1085 * @param string$class Name of custom class1086 * 1087 * @return bool eanTrue on success, false otherwise1088 */ 1089 public function set_file_class( $class = File::class)1090 { 1091 //trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);1161 * @param class-string<File> $class Name of custom class 1162 * 1163 * @return bool True on success, false otherwise 1164 */ 1165 public function set_file_class(string $class = File::class) 1166 { 1167 trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED); 1092 1168 1093 1169 return $this->registry->register(File::class, $class, true); … … 1099 1175 * @deprecated since SimplePie 1.3, use {@see get_registry()} instead 1100 1176 * 1101 * @param string$class Name of custom class1102 * 1103 * @return bool eanTrue on success, false otherwise1104 */ 1105 public function set_sanitize_class( $class = Sanitize::class)1106 { 1107 //trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);1177 * @param class-string<Sanitize> $class Name of custom class 1178 * 1179 * @return bool True on success, false otherwise 1180 */ 1181 public function set_sanitize_class(string $class = Sanitize::class) 1182 { 1183 trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED); 1108 1184 1109 1185 return $this->registry->register(Sanitize::class, $class, true); … … 1115 1191 * @deprecated since SimplePie 1.3, use {@see get_registry()} instead 1116 1192 * 1117 * @param string$class Name of custom class1118 * 1119 * @return bool eanTrue on success, false otherwise1120 */ 1121 public function set_item_class( $class = Item::class)1122 { 1123 //trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);1193 * @param class-string<Item> $class Name of custom class 1194 * 1195 * @return bool True on success, false otherwise 1196 */ 1197 public function set_item_class(string $class = Item::class) 1198 { 1199 trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED); 1124 1200 1125 1201 return $this->registry->register(Item::class, $class, true); … … 1131 1207 * @deprecated since SimplePie 1.3, use {@see get_registry()} instead 1132 1208 * 1133 * @param string$class Name of custom class1134 * 1135 * @return bool eanTrue on success, false otherwise1136 */ 1137 public function set_author_class( $class = Author::class)1138 { 1139 //trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);1209 * @param class-string<Author> $class Name of custom class 1210 * 1211 * @return bool True on success, false otherwise 1212 */ 1213 public function set_author_class(string $class = Author::class) 1214 { 1215 trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED); 1140 1216 1141 1217 return $this->registry->register(Author::class, $class, true); … … 1147 1223 * @deprecated since SimplePie 1.3, use {@see get_registry()} instead 1148 1224 * 1149 * @param string$class Name of custom class1150 * 1151 * @return bool eanTrue on success, false otherwise1152 */ 1153 public function set_category_class( $class = Category::class)1154 { 1155 //trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);1225 * @param class-string<Category> $class Name of custom class 1226 * 1227 * @return bool True on success, false otherwise 1228 */ 1229 public function set_category_class(string $class = Category::class) 1230 { 1231 trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED); 1156 1232 1157 1233 return $this->registry->register(Category::class, $class, true); … … 1163 1239 * @deprecated since SimplePie 1.3, use {@see get_registry()} instead 1164 1240 * 1165 * @param string$class Name of custom class1166 * 1167 * @return bool eanTrue on success, false otherwise1168 */ 1169 public function set_enclosure_class( $class = Enclosure::class)1170 { 1171 //trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);1241 * @param class-string<Enclosure> $class Name of custom class 1242 * 1243 * @return bool True on success, false otherwise 1244 */ 1245 public function set_enclosure_class(string $class = Enclosure::class) 1246 { 1247 trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED); 1172 1248 1173 1249 return $this->registry->register(Enclosure::class, $class, true); … … 1179 1255 * @deprecated since SimplePie 1.3, use {@see get_registry()} instead 1180 1256 * 1181 * @param string$class Name of custom class1182 * 1183 * @return bool eanTrue on success, false otherwise1184 */ 1185 public function set_caption_class( $class = Caption::class)1186 { 1187 //trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);1257 * @param class-string<Caption> $class Name of custom class 1258 * 1259 * @return bool True on success, false otherwise 1260 */ 1261 public function set_caption_class(string $class = Caption::class) 1262 { 1263 trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED); 1188 1264 1189 1265 return $this->registry->register(Caption::class, $class, true); … … 1195 1271 * @deprecated since SimplePie 1.3, use {@see get_registry()} instead 1196 1272 * 1197 * @param string$class Name of custom class1198 * 1199 * @return bool eanTrue on success, false otherwise1200 */ 1201 public function set_copyright_class( $class = Copyright::class)1202 { 1203 //trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);1273 * @param class-string<Copyright> $class Name of custom class 1274 * 1275 * @return bool True on success, false otherwise 1276 */ 1277 public function set_copyright_class(string $class = Copyright::class) 1278 { 1279 trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED); 1204 1280 1205 1281 return $this->registry->register(Copyright::class, $class, true); … … 1211 1287 * @deprecated since SimplePie 1.3, use {@see get_registry()} instead 1212 1288 * 1213 * @param string$class Name of custom class1214 * 1215 * @return bool eanTrue on success, false otherwise1216 */ 1217 public function set_credit_class( $class = Credit::class)1218 { 1219 //trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);1289 * @param class-string<Credit> $class Name of custom class 1290 * 1291 * @return bool True on success, false otherwise 1292 */ 1293 public function set_credit_class(string $class = Credit::class) 1294 { 1295 trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED); 1220 1296 1221 1297 return $this->registry->register(Credit::class, $class, true); … … 1227 1303 * @deprecated since SimplePie 1.3, use {@see get_registry()} instead 1228 1304 * 1229 * @param string$class Name of custom class1230 * 1231 * @return bool eanTrue on success, false otherwise1232 */ 1233 public function set_rating_class( $class = Rating::class)1234 { 1235 //trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);1305 * @param class-string<Rating> $class Name of custom class 1306 * 1307 * @return bool True on success, false otherwise 1308 */ 1309 public function set_rating_class(string $class = Rating::class) 1310 { 1311 trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED); 1236 1312 1237 1313 return $this->registry->register(Rating::class, $class, true); … … 1243 1319 * @deprecated since SimplePie 1.3, use {@see get_registry()} instead 1244 1320 * 1245 * @param string$class Name of custom class1246 * 1247 * @return bool eanTrue on success, false otherwise1248 */ 1249 public function set_restriction_class( $class = Restriction::class)1250 { 1251 //trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);1321 * @param class-string<Restriction> $class Name of custom class 1322 * 1323 * @return bool True on success, false otherwise 1324 */ 1325 public function set_restriction_class(string $class = Restriction::class) 1326 { 1327 trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED); 1252 1328 1253 1329 return $this->registry->register(Restriction::class, $class, true); … … 1259 1335 * @deprecated since SimplePie 1.3, use {@see get_registry()} instead 1260 1336 * 1261 * @param string$class Name of custom class1262 * 1263 * @return bool eanTrue on success, false otherwise1264 */ 1265 public function set_content_type_sniffer_class( $class = Sniffer::class)1266 { 1267 //trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);1337 * @param class-string<Sniffer> $class Name of custom class 1338 * 1339 * @return bool True on success, false otherwise 1340 */ 1341 public function set_content_type_sniffer_class(string $class = Sniffer::class) 1342 { 1343 trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED); 1268 1344 1269 1345 return $this->registry->register(Sniffer::class, $class, true); … … 1275 1351 * @deprecated since SimplePie 1.3, use {@see get_registry()} instead 1276 1352 * 1277 * @param string$class Name of custom class1278 * 1279 * @return bool eanTrue on success, false otherwise1280 */ 1281 public function set_source_class( $class = Source::class)1282 { 1283 //trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);1353 * @param class-string<Source> $class Name of custom class 1354 * 1355 * @return bool True on success, false otherwise 1356 */ 1357 public function set_source_class(string $class = Source::class) 1358 { 1359 trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED); 1284 1360 1285 1361 return $this->registry->register(Source::class, $class, true); … … 1290 1366 * 1291 1367 * @param string $ua New user agent string. 1292 */ 1293 public function set_useragent($ua = null) 1294 { 1368 * @return void 1369 */ 1370 public function set_useragent(?string $ua = null) 1371 { 1372 if ($this->http_client_injected) { 1373 throw new SimplePieException(sprintf( 1374 'Using "%s()" has no effect, because you already provided a HTTP client with "%s::set_http_client()". Configure user agent string in your HTTP client instead.', 1375 __METHOD__, 1376 self::class 1377 )); 1378 } 1379 1295 1380 if ($ua === null) { 1296 $ua = \SimplePie\Misc::get_default_useragent();1381 $ua = Misc::get_default_useragent(); 1297 1382 } 1298 1383 1299 1384 $this->useragent = (string) $ua; 1385 1386 // Reset a possible existing FileClient, 1387 // so a new client with the changed value will be created 1388 if (is_object($this->http_client) && $this->http_client instanceof FileClient) { 1389 $this->http_client = null; 1390 } elseif (is_object($this->http_client)) { 1391 // Trigger notice if a PSR-18 client was set 1392 trigger_error(sprintf( 1393 'Using "%s()" has no effect, because you already provided a HTTP client with "%s::set_http_client()". Configure the useragent in your HTTP client instead.', 1394 __METHOD__, 1395 get_class($this) 1396 ), \E_USER_NOTICE); 1397 } 1300 1398 } 1301 1399 … … 1317 1415 * @deprecated since SimplePie 1.8.0, use {@see set_cache_namefilter()} instead 1318 1416 * 1319 * @param mixed $function Callback function 1320 */ 1321 public function set_cache_name_function($function = 'md5') 1417 * @param (string&(callable(string): string))|null $function Callback function 1418 * @return void 1419 */ 1420 public function set_cache_name_function(?string $function = null) 1322 1421 { 1323 1422 // trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.8.0, please use "SimplePie\SimplePie::set_cache_namefilter()" instead.', __METHOD__), \E_USER_DEPRECATED); 1324 1423 1325 if (is_callable($function)) { 1326 $this->cache_name_function = $function; 1327 1328 $this->set_cache_namefilter(new CallableNameFilter($this->cache_name_function)); 1329 } 1424 if ($function === null) { 1425 $function = 'md5'; 1426 } 1427 1428 $this->cache_name_function = $function; 1429 1430 $this->set_cache_namefilter(new CallableNameFilter($this->cache_name_function)); 1330 1431 } 1331 1432 … … 1337 1438 * 1338 1439 * @param bool $set Whether to set them or not 1339 */ 1340 public function set_stupidly_fast($set = false) 1440 * @return void 1441 */ 1442 public function set_stupidly_fast(bool $set = false) 1341 1443 { 1342 1444 if ($set) { … … 1344 1446 $this->remove_div(false); 1345 1447 $this->strip_comments(false); 1346 $this->strip_htmltags( false);1347 $this->strip_attributes( false);1348 $this->add_attributes( false);1448 $this->strip_htmltags([]); 1449 $this->strip_attributes([]); 1450 $this->add_attributes([]); 1349 1451 $this->set_image_handler(false); 1350 1452 $this->set_https_domains([]); … … 1356 1458 * 1357 1459 * @param int $max Maximum number of feeds to check 1358 */ 1359 public function set_max_checked_feeds($max = 10) 1360 { 1361 $this->max_checked_feeds = (int) $max; 1362 } 1363 1364 public function remove_div($enable = true) 1460 * @return void 1461 */ 1462 public function set_max_checked_feeds(int $max = 10) 1463 { 1464 $this->max_checked_feeds = $max; 1465 } 1466 1467 /** 1468 * @return void 1469 */ 1470 public function remove_div(bool $enable = true) 1365 1471 { 1366 1472 $this->sanitize->remove_div($enable); 1367 1473 } 1368 1474 1369 public function strip_htmltags($tags = '', $encode = null) 1475 /** 1476 * @param string[]|string|false $tags Set a list of tags to strip, or set empty string to use default tags, or false to strip nothing. 1477 * @return void 1478 */ 1479 public function strip_htmltags($tags = '', ?bool $encode = null) 1370 1480 { 1371 1481 if ($tags === '') { … … 1378 1488 } 1379 1489 1380 public function encode_instead_of_strip($enable = true) 1490 /** 1491 * @return void 1492 */ 1493 public function encode_instead_of_strip(bool $enable = true) 1381 1494 { 1382 1495 $this->sanitize->encode_instead_of_strip($enable); 1383 1496 } 1384 1497 1498 /** 1499 * @param string[]|string $attribs 1500 * @return void 1501 */ 1385 1502 public function rename_attributes($attribs = '') 1386 1503 { … … 1391 1508 } 1392 1509 1510 /** 1511 * @param string[]|string $attribs 1512 * @return void 1513 */ 1393 1514 public function strip_attributes($attribs = '') 1394 1515 { … … 1399 1520 } 1400 1521 1522 /** 1523 * @param array<string, array<string, string>>|'' $attribs 1524 * @return void 1525 */ 1401 1526 public function add_attributes($attribs = '') 1402 1527 { … … 1428 1553 * 1429 1554 * @param string $encoding 1430 */ 1431 public function set_output_encoding($encoding = 'UTF-8') 1555 * @return void 1556 */ 1557 public function set_output_encoding(string $encoding = 'UTF-8') 1432 1558 { 1433 1559 $this->sanitize->set_output_encoding($encoding); 1434 1560 } 1435 1561 1436 public function strip_comments($strip = false) 1562 /** 1563 * @return void 1564 */ 1565 public function strip_comments(bool $strip = false) 1437 1566 { 1438 1567 $this->sanitize->strip_comments($strip); … … 1448 1577 * 1449 1578 * @since 1.0 1450 * @param array|null $element_attribute Element/attribute key/value pairs, null for default 1451 */ 1452 public function set_url_replacements($element_attribute = null) 1579 * @param array<string, string|string[]>|null $element_attribute Element/attribute key/value pairs, null for default 1580 * @return void 1581 */ 1582 public function set_url_replacements(?array $element_attribute = null) 1453 1583 { 1454 1584 $this->sanitize->set_url_replacements($element_attribute); … … 1457 1587 /** 1458 1588 * Set the list of domains for which to force HTTPS. 1459 * @see \SimplePie\Sanitize::set_https_domains() 1460 * @param array List of HTTPS domains. Example array('biz', 'example.com', 'example.org', 'www.example.net'). 1461 */ 1462 public function set_https_domains($domains = []) 1463 { 1464 if (is_array($domains)) { 1465 $this->sanitize->set_https_domains($domains); 1466 } 1589 * @see Sanitize::set_https_domains() 1590 * @param array<string> $domains List of HTTPS domains. Example array('biz', 'example.com', 'example.org', 'www.example.net'). 1591 * @return void 1592 */ 1593 public function set_https_domains(array $domains = []) 1594 { 1595 $this->sanitize->set_https_domains($domains); 1467 1596 } 1468 1597 … … 1470 1599 * Set the handler to enable the display of cached images. 1471 1600 * 1472 * @param string $page Web-accessible path to the handler_image.php file.1601 * @param string|false $page Web-accessible path to the handler_image.php file. 1473 1602 * @param string $qs The query string that the value should be passed to. 1474 */ 1475 public function set_image_handler($page = false, $qs = 'i') 1603 * @return void 1604 */ 1605 public function set_image_handler($page = false, string $qs = 'i') 1476 1606 { 1477 1607 if ($page !== false) { … … 1485 1615 * Set the limit for items returned per-feed with multifeeds 1486 1616 * 1487 * @param integer $limit The maximum number of items to return. 1488 */ 1489 public function set_item_limit($limit = 0) 1490 { 1491 $this->item_limit = (int) $limit; 1617 * @param int $limit The maximum number of items to return. 1618 * @return void 1619 */ 1620 public function set_item_limit(int $limit = 0) 1621 { 1622 $this->item_limit = $limit; 1492 1623 } 1493 1624 … … 1495 1626 * Enable throwing exceptions 1496 1627 * 1497 * @param boolean $enable Should we throw exceptions, or use the old-style error property? 1498 */ 1499 public function enable_exceptions($enable = true) 1628 * @param bool $enable Should we throw exceptions, or use the old-style error property? 1629 * @return void 1630 */ 1631 public function enable_exceptions(bool $enable = true) 1500 1632 { 1501 1633 $this->enable_exceptions = $enable; … … 1509 1641 * parsed, and all of that other good stuff. 1510 1642 * 1511 * @return bool eanTrue if successful, false otherwise1643 * @return bool True if successful, false otherwise 1512 1644 */ 1513 1645 public function init() … … 1524 1656 $parser_check = xml_parser_create(); 1525 1657 xml_parse_into_struct($parser_check, '<foo>&</foo>', $values); 1526 xml_parser_free($parser_check); 1658 if (\PHP_VERSION_ID < 80000) { 1659 xml_parser_free($parser_check); 1660 } 1527 1661 $xml_is_sane = isset($values[0]['value']); 1528 1662 } … … 1534 1668 // The default sanitize class gets set in the constructor, check if it has 1535 1669 // changed. 1536 if ($this->registry->get_class(Sanitize::class) !== 'SimplePie\Sanitize') {1670 if ($this->registry->get_class(Sanitize::class) !== Sanitize::class) { 1537 1671 $this->sanitize = $this->registry->create(Sanitize::class); 1538 1672 } … … 1543 1677 // Pass whatever was set with config options over to the sanitizer. 1544 1678 // Pass the classes in for legacy support; new classes should use the registry instead 1679 $cache = $this->registry->get_class(Cache::class); 1680 \assert($cache !== null, 'Cache must be defined'); 1545 1681 $this->sanitize->pass_cache_data( 1546 1682 $this->enable_cache, 1547 1683 $this->cache_location, 1548 1684 $this->cache_namefilter, 1549 $ this->registry->get_class(Cache::class),1685 $cache, 1550 1686 $this->cache 1551 1687 ); 1552 $this->sanitize->pass_file_data($this->registry->get_class(File::class), $this->timeout, $this->useragent, $this->force_fsockopen, $this->curl_options); 1688 1689 $http_client = $this->get_http_client(); 1690 1691 if ($http_client instanceof Psr18Client) { 1692 $this->sanitize->set_http_client( 1693 $http_client->getHttpClient(), 1694 $http_client->getRequestFactory(), 1695 $http_client->getUriFactory() 1696 ); 1697 } 1553 1698 1554 1699 if (!empty($this->multifeed_url)) { … … 1586 1731 } 1587 1732 1588 // Fetch the data via \SimplePie\Fileinto $this->raw_data1733 // Fetch the data into $this->raw_data 1589 1734 if (($fetched = $this->fetch_data($cache)) === true) { 1590 1735 return true; … … 1650 1795 1651 1796 // If it's parsed fine 1652 if ($parser->parse($utf8_data, 'UTF-8', $this->permanent_url )) {1797 if ($parser->parse($utf8_data, 'UTF-8', $this->permanent_url ?? '')) { 1653 1798 $this->data = $parser->get_data(); 1654 1799 if (!($this->get_type() & ~self::TYPE_NONE)) { … … 1661 1806 $this->data['headers'] = $headers; 1662 1807 } 1663 $this->data['build'] = \SimplePie\Misc::get_build();1808 $this->data['build'] = Misc::get_build(); 1664 1809 1665 1810 // Cache the file if caching is enabled 1666 1811 $this->data['cache_expiration_time'] = $this->cache_duration + time(); 1812 1667 1813 if ($cache && !$cache->set_data($this->get_cache_filename($this->feed_url), $this->data, $this->cache_duration)) { 1668 1814 trigger_error("$this->cache_location is not writable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); … … 1674 1820 1675 1821 if (isset($parser)) { 1676 // We have an error, just set \SimplePie\Misc::error to it and quit1822 // We have an error, just set Misc::error to it and quit 1677 1823 $this->error = $this->feed_url; 1678 1824 $this->error .= sprintf(' is invalid XML, likely due to invalid characters. XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column()); … … 1702 1848 1703 1849 /** 1704 * Fetch the data via \SimplePie\File1850 * Fetch the data 1705 1851 * 1706 1852 * If the data is already cached, attempt to fetch it from there instead 1853 * 1707 1854 * @param Base|DataCache|false $cache Cache handler, or false to not load from the cache 1708 * @return array |trueReturns true if the data was loaded from the cache, or an array of HTTP headers and sniffed type1855 * @return array{array<string, string>, string}|bool Returns true if the data was loaded from the cache, or an array of HTTP headers and sniffed type 1709 1856 */ 1710 1857 protected function fetch_data(&$cache) 1711 1858 { 1712 if ( is_object($cache) &&$cache instanceof Base) {1859 if ($cache instanceof Base) { 1713 1860 // @trigger_error(sprintf('Providing $cache as "\SimplePie\Cache\Base" in %s() is deprecated since SimplePie 1.8.0, please provide "\SimplePie\Cache\DataCache" implementation instead.', __METHOD__), \E_USER_DEPRECATED); 1714 1861 $cache = new BaseDataCache($cache); 1715 1862 } 1716 1863 1864 // @phpstan-ignore-next-line Enforce PHPDoc type. 1717 1865 if ($cache !== false && !$cache instanceof DataCache) { 1718 1866 throw new InvalidArgumentException(sprintf( … … 1732 1880 if (!empty($this->data)) { 1733 1881 // If the cache is for an outdated build of SimplePie 1734 if (!isset($this->data['build']) || $this->data['build'] !== \SimplePie\Misc::get_build()) {1882 if (!isset($this->data['build']) || $this->data['build'] !== Misc::get_build()) { 1735 1883 $cache->delete_data($cacheKey); 1736 1884 $this->data = []; … … 1764 1912 if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag'])) { 1765 1913 $headers = [ 1766 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',1914 'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER, 1767 1915 ]; 1768 1916 if (isset($this->data['headers']['last-modified'])) { … … 1773 1921 } 1774 1922 1775 $file = $this->registry->create(File::class, [$this->feed_url, $this->timeout / 10, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options]); 1776 $this->status_code = $file->status_code; 1777 1778 if ($file->success) { 1779 if ($file->status_code === 304) { 1780 // Set raw_data to false here too, to signify that the cache 1781 // is still valid. 1782 $this->raw_data = false; 1923 try { 1924 $file = $this->get_http_client()->request(Client::METHOD_GET, $this->feed_url, $headers); 1925 $this->status_code = $file->get_status_code(); 1926 } catch (ClientException $th) { 1927 $this->check_modified = false; 1928 $this->status_code = 0; 1929 1930 if ($this->force_cache_fallback) { 1931 $this->data['cache_expiration_time'] = $this->cache_duration + time(); 1783 1932 $cache->set_data($cacheKey, $this->data, $this->cache_duration); 1933 1784 1934 return true; 1785 1935 } 1786 } else { 1787 $this->check_modified = false; 1788 if ($this->force_cache_fallback) { 1789 $cache->set_data($cacheKey, $this->data, $this->cache_duration); 1790 return true; 1791 } 1792 1793 unset($file); 1936 1937 $failedFileReason = $th->getMessage(); 1938 } 1939 1940 if ($this->status_code === 304) { 1941 // Set raw_data to false here too, to signify that the cache 1942 // is still valid. 1943 $this->raw_data = false; 1944 $this->data['cache_expiration_time'] = $this->cache_duration + time(); 1945 $cache->set_data($cacheKey, $this->data, $this->cache_duration); 1946 1947 return true; 1794 1948 } 1795 1949 } … … 1809 1963 // If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it. 1810 1964 if (!isset($file)) { 1811 if ($this->file instanceof \SimplePie\File && $this->file->url=== $this->feed_url) {1965 if ($this->file instanceof File && $this->file->get_final_requested_uri() === $this->feed_url) { 1812 1966 $file = &$this->file; 1967 } elseif (isset($failedFileReason)) { 1968 // Do not try to fetch again if we already failed once. 1969 // If the file connection had an error, set SimplePie::error to that and quit 1970 $this->error = $failedFileReason; 1971 1972 return !empty($this->data); 1813 1973 } else { 1814 1974 $headers = [ 1815 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',1975 'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER, 1816 1976 ]; 1817 $file = $this->registry->create(File::class, [$this->feed_url, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options]); 1818 } 1819 } 1820 $this->status_code = $file->status_code; 1977 try { 1978 $file = $this->get_http_client()->request(Client::METHOD_GET, $this->feed_url, $headers); 1979 } catch (ClientException $th) { 1980 // If the file connection has an error, set SimplePie::error to that and quit 1981 $this->error = $th->getMessage(); 1982 1983 return !empty($this->data); 1984 } 1985 } 1986 } 1987 $this->status_code = $file->get_status_code(); 1821 1988 1822 1989 // If the file connection has an error, set SimplePie::error to that and quit 1823 if (! $file->success && !($file->method & self::FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code< 300))) {1824 $this->error = $file->error;1990 if (!(!Misc::is_remote_uri($file->get_final_requested_uri()) || ($file->get_status_code() === 200 || $file->get_status_code() > 206 && $file->get_status_code() < 300))) { 1991 $this->error = 'Retrieved unsupported status code "' . $this->status_code . '"'; 1825 1992 return !empty($this->data); 1826 1993 } … … 1828 1995 if (!$this->force_feed) { 1829 1996 // Check if the supplied URL is a feed, if it isn't, look for it. 1830 $locate = $this->registry->create(Locator::class, [&$file, $this->timeout, $this->useragent, $this->max_checked_feeds, $this->force_fsockopen, $this->curl_options]); 1997 $locate = $this->registry->create(Locator::class, [ 1998 (!$file instanceof File) ? File::fromResponse($file) : $file, 1999 $this->timeout, 2000 $this->useragent, 2001 $this->max_checked_feeds, 2002 $this->force_fsockopen, 2003 $this->curl_options 2004 ]); 2005 2006 $http_client = $this->get_http_client(); 2007 2008 if ($http_client instanceof Psr18Client) { 2009 $locate->set_http_client( 2010 $http_client->getHttpClient(), 2011 $http_client->getRequestFactory(), 2012 $http_client->getUriFactory() 2013 ); 2014 } 1831 2015 1832 2016 if (!$locate->is_feed($file)) { 1833 $copyStatusCode = $file-> status_code;1834 $copyContentType = $file-> headers['content-type'] ?? '';2017 $copyStatusCode = $file->get_status_code(); 2018 $copyContentType = $file->get_header_line('content-type'); 1835 2019 try { 1836 2020 $microformats = false; 1837 2021 if (class_exists('DOMXpath') && function_exists('Mf2\parse')) { 1838 2022 $doc = new \DOMDocument(); 1839 @$doc->loadHTML($file-> body);2023 @$doc->loadHTML($file->get_body_content()); 1840 2024 $xpath = new \DOMXpath($doc); 1841 2025 // Check for both h-feed and h-entry, as both a feed with no entries … … 1843 2027 $query = '//*[contains(concat(" ", @class, " "), " h-feed ") or '. 1844 2028 'contains(concat(" ", @class, " "), " h-entry ")]'; 2029 2030 /** @var \DOMNodeList<\DOMElement> $result */ 1845 2031 $result = $xpath->query($query); 1846 2032 $microformats = $result->length !== 0; … … 1853 2039 ); 1854 2040 if ($microformats) { 1855 if ($hub = $locate->get_rel_link('hub')) { 1856 $self = $locate->get_rel_link('self'); 1857 $this->store_links($file, $hub, $self); 2041 $hub = $locate->get_rel_link('hub'); 2042 $self = $locate->get_rel_link('self'); 2043 if ($hub || $self) { 2044 $file = $this->store_links($file, $hub, $self); 1858 2045 } 1859 2046 // Push the current file onto all_discovered feeds so the user can 1860 2047 // be shown this as one of the options. 1861 if ( isset($this->all_discovered_feeds)) {2048 if ($this->all_discovered_feeds !== null) { 1862 2049 $this->all_discovered_feeds[] = $file; 1863 2050 } … … 1874 2061 } 1875 2062 } 1876 } catch ( \SimplePie\Exception $e) {2063 } catch (SimplePieException $e) { 1877 2064 // We need to unset this so that if SimplePie::set_file() has been called that object is untouched 1878 2065 unset($file); … … 1886 2073 $this->data = [ 1887 2074 'url' => $this->feed_url, 1888 'feed_url' => $file-> url,1889 'build' => \SimplePie\Misc::get_build(),2075 'feed_url' => $file->get_final_requested_uri(), 2076 'build' => Misc::get_build(), 1890 2077 'cache_expiration_time' => $this->cache_duration + time(), 1891 2078 ]; … … 1896 2083 } 1897 2084 } 1898 $this->feed_url = $file-> url;2085 $this->feed_url = $file->get_final_requested_uri(); 1899 2086 $locate = null; 1900 2087 } 1901 2088 1902 $this->raw_data = $file->body; 1903 $this->permanent_url = $file->permanent_url; 1904 $headers = $file->headers; 2089 $this->raw_data = $file->get_body_content(); 2090 $this->permanent_url = $file->get_permanent_uri(); 2091 2092 $headers = []; 2093 foreach ($file->get_headers() as $key => $values) { 2094 $headers[$key] = implode(', ', $values); 2095 } 2096 1905 2097 $sniffer = $this->registry->create(Sniffer::class, [&$file]); 1906 2098 $sniffed = $sniffer->get_type(); … … 1912 2104 * Get the error message for the occurred error 1913 2105 * 1914 * @return string| arrayError message, or array of messages for multifeeds2106 * @return string|string[]|null Error message, or array of messages for multifeeds 1915 2107 */ 1916 2108 public function error() … … 1935 2127 * the data instead of printing it. 1936 2128 * 1937 * @return string| booleanRaw XML data, false if the cache is used2129 * @return string|false Raw XML data, false if the cache is used 1938 2130 */ 1939 2131 public function get_raw_data() … … 1971 2163 * 1972 2164 * @param string $mime MIME type to serve the page as 1973 */ 1974 public function handle_content_type($mime = 'text/html') 2165 * @return void 2166 */ 2167 public function handle_content_type(string $mime = 'text/html') 1975 2168 { 1976 2169 if (!headers_sent()) { … … 1988 2181 * Get the type of the feed 1989 2182 * 1990 * This returns a \SimplePie\SimplePie::TYPE_* constant, which can be tested against2183 * This returns a self::TYPE_* constant, which can be tested against 1991 2184 * using {@link http://php.net/language.operators.bitwise bitwise operators} 1992 2185 * 1993 2186 * @since 0.8 (usage changed to using constants in 1.0) 1994 * @see \SimplePie\SimplePie::TYPE_NONE Unknown.1995 * @see \SimplePie\SimplePie::TYPE_RSS_090 RSS 0.90.1996 * @see \SimplePie\SimplePie::TYPE_RSS_091_NETSCAPE RSS 0.91 (Netscape).1997 * @see \SimplePie\SimplePie::TYPE_RSS_091_USERLAND RSS 0.91 (Userland).1998 * @see \SimplePie\SimplePie::TYPE_RSS_091 RSS 0.91.1999 * @see \SimplePie\SimplePie::TYPE_RSS_092 RSS 0.92.2000 * @see \SimplePie\SimplePie::TYPE_RSS_093 RSS 0.93.2001 * @see \SimplePie\SimplePie::TYPE_RSS_094 RSS 0.94.2002 * @see \SimplePie\SimplePie::TYPE_RSS_10 RSS 1.0.2003 * @see \SimplePie\SimplePie::TYPE_RSS_20 RSS 2.0.x.2004 * @see \SimplePie\SimplePie::TYPE_RSS_RDF RDF-based RSS.2005 * @see \SimplePie\SimplePie::TYPE_RSS_SYNDICATION Non-RDF-based RSS (truly intended as syndication format).2006 * @see \SimplePie\SimplePie::TYPE_RSS_ALL Any version of RSS.2007 * @see \SimplePie\SimplePie::TYPE_ATOM_03 Atom 0.3.2008 * @see \SimplePie\SimplePie::TYPE_ATOM_10 Atom 1.0.2009 * @see \SimplePie\SimplePie::TYPE_ATOM_ALL Any version of Atom.2010 * @see \SimplePie\SimplePie::TYPE_ALL Any known/supported feed type.2011 * @return int \SimplePie\SimplePie::TYPE_*constant2187 * @see self::TYPE_NONE Unknown. 2188 * @see self::TYPE_RSS_090 RSS 0.90. 2189 * @see self::TYPE_RSS_091_NETSCAPE RSS 0.91 (Netscape). 2190 * @see self::TYPE_RSS_091_USERLAND RSS 0.91 (Userland). 2191 * @see self::TYPE_RSS_091 RSS 0.91. 2192 * @see self::TYPE_RSS_092 RSS 0.92. 2193 * @see self::TYPE_RSS_093 RSS 0.93. 2194 * @see self::TYPE_RSS_094 RSS 0.94. 2195 * @see self::TYPE_RSS_10 RSS 1.0. 2196 * @see self::TYPE_RSS_20 RSS 2.0.x. 2197 * @see self::TYPE_RSS_RDF RDF-based RSS. 2198 * @see self::TYPE_RSS_SYNDICATION Non-RDF-based RSS (truly intended as syndication format). 2199 * @see self::TYPE_RSS_ALL Any version of RSS. 2200 * @see self::TYPE_ATOM_03 Atom 0.3. 2201 * @see self::TYPE_ATOM_10 Atom 1.0. 2202 * @see self::TYPE_ATOM_ALL Any version of Atom. 2203 * @see self::TYPE_ALL Any known/supported feed type. 2204 * @return int-mask-of<self::TYPE_*> constant 2012 2205 */ 2013 2206 public function get_type() … … 2094 2287 * @return string|null 2095 2288 */ 2096 public function subscribe_url( $permanent = false)2289 public function subscribe_url(bool $permanent = false) 2097 2290 { 2098 2291 if ($permanent) { … … 2152 2345 * @param string $namespace The URL of the XML namespace of the elements you're trying to access 2153 2346 * @param string $tag Tag name 2154 * @return array 2155 */ 2156 public function get_feed_tags( $namespace,$tag)2347 * @return array<array<string, mixed>>|null 2348 */ 2349 public function get_feed_tags(string $namespace, string $tag) 2157 2350 { 2158 2351 $type = $this->get_type(); … … 2192 2385 * @param string $namespace The URL of the XML namespace of the elements you're trying to access 2193 2386 * @param string $tag Tag name 2194 * @return array 2195 */ 2196 public function get_channel_tags( $namespace,$tag)2387 * @return array<array<string, mixed>>|null 2388 */ 2389 public function get_channel_tags(string $namespace, string $tag) 2197 2390 { 2198 2391 $type = $this->get_type(); … … 2238 2431 * @param string $namespace The URL of the XML namespace of the elements you're trying to access 2239 2432 * @param string $tag Tag name 2240 * @return array 2241 */ 2242 public function get_image_tags( $namespace,$tag)2433 * @return array<array<string, mixed>>|null 2434 */ 2435 public function get_image_tags(string $namespace, string $tag) 2243 2436 { 2244 2437 $type = $this->get_type(); … … 2270 2463 * Get the base URL value from the feed 2271 2464 * 2272 * Uses `<xml:base>` if available, otherwise uses the first link in the 2273 * feed, or failing that, the URL of the feed itself. 2465 * Uses `<xml:base>` if available, 2466 * otherwise uses the first 'self' link or the first 'alternate' link of the feed, 2467 * or failing that, the URL of the feed itself. 2274 2468 * 2275 2469 * @see get_link 2276 2470 * @see subscribe_url 2277 2471 * 2278 * @param array $element2472 * @param array<string, mixed> $element 2279 2473 * @return string 2280 2474 */ 2281 public function get_base( $element = [])2475 public function get_base(array $element = []) 2282 2476 { 2283 2477 if (!empty($element['xml_base_explicit']) && isset($element['xml_base'])) { 2284 2478 return $element['xml_base']; 2285 } elseif ($this->get_link() !== null) { 2286 return $this->get_link(); 2287 } 2288 2289 return $this->subscribe_url(); 2479 } 2480 if (($link = $this->get_link(0, 'alternate')) !== null) { 2481 return $link; 2482 } 2483 if (($link = $this->get_link(0, 'self')) !== null) { 2484 return $link; 2485 } 2486 2487 return $this->subscribe_url() ?? ''; 2290 2488 } 2291 2489 … … 2294 2492 * 2295 2493 * @access private 2296 * @see \SimplePie\Sanitize::sanitize()2494 * @see Sanitize::sanitize() 2297 2495 * @param string $data Data to sanitize 2298 * @param int $type One of the \SimplePie\SimplePie::CONSTRUCT_* constants2496 * @param int-mask-of<SimplePie::CONSTRUCT_*> $type 2299 2497 * @param string $base Base URL to resolve URLs against 2300 2498 * @return string Sanitized data 2301 2499 */ 2302 public function sanitize( $data, $type,$base = '')2500 public function sanitize(string $data, int $type, string $base = '') 2303 2501 { 2304 2502 try { 2503 // This really returns string|false but changing encoding is uncommon and we are going to deprecate it, so let’s just lie to PHPStan in the interest of cleaner annotations. 2305 2504 return $this->sanitize->sanitize($data, $type, $base); 2306 } catch ( \SimplePie\Exception $e) {2505 } catch (SimplePieException $e) { 2307 2506 if (!$this->enable_exceptions) { 2308 2507 $this->error = $e->getMessage(); … … 2349 2548 * @since Unknown 2350 2549 * @param int $key The category that you want to return. Remember that arrays begin with 0, not 1 2351 * @return \SimplePie\Category|null2352 */ 2353 public function get_category( $key = 0)2550 * @return Category|null 2551 */ 2552 public function get_category(int $key = 0) 2354 2553 { 2355 2554 $categories = $this->get_categories(); … … 2367 2566 * 2368 2567 * @since Unknown 2369 * @return array |null List of {@see \SimplePie\Category} objects2568 * @return array<Category>|null List of {@see Category} objects 2370 2569 */ 2371 2570 public function get_categories() … … 2418 2617 * @since 1.1 2419 2618 * @param int $key The author that you want to return. Remember that arrays begin with 0, not 1 2420 * @return \SimplePie\Author|null2421 */ 2422 public function get_author( $key = 0)2619 * @return Author|null 2620 */ 2621 public function get_author(int $key = 0) 2423 2622 { 2424 2623 $authors = $this->get_authors(); … … 2436 2635 * 2437 2636 * @since 1.1 2438 * @return array |null List of {@see \SimplePie\Author} objects2637 * @return array<Author>|null List of {@see Author} objects 2439 2638 */ 2440 2639 public function get_authors() … … 2449 2648 } 2450 2649 if (isset($author['child'][self::NAMESPACE_ATOM_10]['uri'][0]['data'])) { 2451 $uri = $this->sanitize($author['child'][self::NAMESPACE_ATOM_10]['uri'][0]['data'], self::CONSTRUCT_IRI, $this->get_base($author['child'][self::NAMESPACE_ATOM_10]['uri'][0])); 2650 $uri = $author['child'][self::NAMESPACE_ATOM_10]['uri'][0]; 2651 $uri = $this->sanitize($uri['data'], self::CONSTRUCT_IRI, $this->get_base($uri)); 2452 2652 } 2453 2653 if (isset($author['child'][self::NAMESPACE_ATOM_10]['email'][0]['data'])) { … … 2466 2666 } 2467 2667 if (isset($author[0]['child'][self::NAMESPACE_ATOM_03]['url'][0]['data'])) { 2468 $url = $this->sanitize($author[0]['child'][self::NAMESPACE_ATOM_03]['url'][0]['data'], self::CONSTRUCT_IRI, $this->get_base($author[0]['child'][self::NAMESPACE_ATOM_03]['url'][0])); 2668 $url = $author[0]['child'][self::NAMESPACE_ATOM_03]['url'][0]; 2669 $url = $this->sanitize($url['data'], self::CONSTRUCT_IRI, $this->get_base($url)); 2469 2670 } 2470 2671 if (isset($author[0]['child'][self::NAMESPACE_ATOM_03]['email'][0]['data'])) { … … 2497 2698 * @since 1.1 2498 2699 * @param int $key The contrbutor that you want to return. Remember that arrays begin with 0, not 1 2499 * @return \SimplePie\Author|null2500 */ 2501 public function get_contributor( $key = 0)2700 * @return Author|null 2701 */ 2702 public function get_contributor(int $key = 0) 2502 2703 { 2503 2704 $contributors = $this->get_contributors(); … … 2515 2716 * 2516 2717 * @since 1.1 2517 * @return array |null List of {@see \SimplePie\Author} objects2718 * @return array<Author>|null List of {@see Author} objects 2518 2719 */ 2519 2720 public function get_contributors() … … 2528 2729 } 2529 2730 if (isset($contributor['child'][self::NAMESPACE_ATOM_10]['uri'][0]['data'])) { 2530 $uri = $this->sanitize($contributor['child'][self::NAMESPACE_ATOM_10]['uri'][0]['data'], self::CONSTRUCT_IRI, $this->get_base($contributor['child'][self::NAMESPACE_ATOM_10]['uri'][0])); 2731 $uri = $contributor['child'][self::NAMESPACE_ATOM_10]['uri'][0]; 2732 $uri = $this->sanitize($uri['data'], self::CONSTRUCT_IRI, $this->get_base($uri)); 2531 2733 } 2532 2734 if (isset($contributor['child'][self::NAMESPACE_ATOM_10]['email'][0]['data'])) { … … 2545 2747 } 2546 2748 if (isset($contributor['child'][self::NAMESPACE_ATOM_03]['url'][0]['data'])) { 2547 $url = $this->sanitize($contributor['child'][self::NAMESPACE_ATOM_03]['url'][0]['data'], self::CONSTRUCT_IRI, $this->get_base($contributor['child'][self::NAMESPACE_ATOM_03]['url'][0])); 2749 $url = $contributor['child'][self::NAMESPACE_ATOM_03]['url'][0]; 2750 $url = $this->sanitize($url['data'], self::CONSTRUCT_IRI, $this->get_base($url)); 2548 2751 } 2549 2752 if (isset($contributor['child'][self::NAMESPACE_ATOM_03]['email'][0]['data'])) { … … 2570 2773 * @return string|null Link URL 2571 2774 */ 2572 public function get_link( $key = 0,$rel = 'alternate')2775 public function get_link(int $key = 0, string $rel = 'alternate') 2573 2776 { 2574 2777 $links = $this->get_links($rel); … … 2603 2806 * @since Beta 2 2604 2807 * @param string $rel The relationship of links to return 2605 * @return array |null Links found for the feed (strings)2606 */ 2607 public function get_links( $rel = 'alternate')2808 * @return array<string>|null Links found for the feed (strings) 2809 */ 2810 public function get_links(string $rel = 'alternate') 2608 2811 { 2609 2812 if (!isset($this->data['links'])) { … … 2670 2873 } 2671 2874 2875 /** 2876 * @return ?array<Response> 2877 */ 2672 2878 public function get_all_discovered_feeds() 2673 2879 { … … 2773 2979 * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo 2774 2980 * @link http://www.georss.org/ GeoRSS 2775 * @return string|null2981 * @return float|null 2776 2982 */ 2777 2983 public function get_latitude() … … 2796 3002 * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo 2797 3003 * @link http://www.georss.org/ GeoRSS 2798 * @return string|null3004 * @return float|null 2799 3005 */ 2800 3006 public function get_longitude() … … 2943 3149 * @return int Number of items in the feed 2944 3150 */ 2945 public function get_item_quantity($max = 0) 2946 { 2947 $max = (int) $max; 3151 public function get_item_quantity(int $max = 0) 3152 { 2948 3153 $qty = count($this->get_items()); 2949 3154 if ($max === 0) { … … 2951 3156 } 2952 3157 2953 return ($qty > $max) ? $max : $qty;3158 return min($qty, $max); 2954 3159 } 2955 3160 … … 2964 3169 * @since Beta 2 2965 3170 * @param int $key The item that you want to return. Remember that arrays begin with 0, not 1 2966 * @return \SimplePie\Item|null2967 */ 2968 public function get_item( $key = 0)3171 * @return Item|null 3172 */ 3173 public function get_item(int $key = 0) 2969 3174 { 2970 3175 $items = $this->get_items(); … … 2987 3192 * @param int $start Index to start at 2988 3193 * @param int $end Number of items to return. 0 for all items after `$start` 2989 * @return \SimplePie\Item[]|null List of {@see \SimplePie\Item} objects2990 */ 2991 public function get_items( $start = 0,$end = 0)3194 * @return Item[] List of {@see Item} objects 3195 */ 3196 public function get_items(int $start = 0, int $end = 0) 2992 3197 { 2993 3198 if (!isset($this->data['items'])) { … … 3003 3208 $keys = array_keys($items); 3004 3209 foreach ($keys as $key) { 3005 $this->data['items'][] = $this-> registry->create(Item::class, [$this, $items[$key]]);3210 $this->data['items'][] = $this->make_item($items[$key]); 3006 3211 } 3007 3212 } … … 3009 3214 $keys = array_keys($items); 3010 3215 foreach ($keys as $key) { 3011 $this->data['items'][] = $this-> registry->create(Item::class, [$this, $items[$key]]);3216 $this->data['items'][] = $this->make_item($items[$key]); 3012 3217 } 3013 3218 } … … 3015 3220 $keys = array_keys($items); 3016 3221 foreach ($keys as $key) { 3017 $this->data['items'][] = $this-> registry->create(Item::class, [$this, $items[$key]]);3222 $this->data['items'][] = $this->make_item($items[$key]); 3018 3223 } 3019 3224 } … … 3021 3226 $keys = array_keys($items); 3022 3227 foreach ($keys as $key) { 3023 $this->data['items'][] = $this-> registry->create(Item::class, [$this, $items[$key]]);3228 $this->data['items'][] = $this->make_item($items[$key]); 3024 3229 } 3025 3230 } … … 3027 3232 $keys = array_keys($items); 3028 3233 foreach ($keys as $key) { 3029 $this->data['items'][] = $this-> registry->create(Item::class, [$this, $items[$key]]);3234 $this->data['items'][] = $this->make_item($items[$key]); 3030 3235 } 3031 3236 } … … 3057 3262 * 3058 3263 * @deprecated Use your own favicon handling instead 3059 */ 3060 public function set_favicon_handler($page = false, $qs = 'i') 3061 { 3062 trigger_error('Favicon handling has been removed, please use your own handling', \E_USER_DEPRECATED); 3264 * @param string|false $page 3265 * @return bool 3266 */ 3267 public function set_favicon_handler($page = false, string $qs = 'i') 3268 { 3269 trigger_error('Favicon handling has been removed since SimplePie 1.3, please use your own handling', \E_USER_DEPRECATED); 3063 3270 return false; 3064 3271 } … … 3068 3275 * 3069 3276 * @deprecated Use your own favicon handling instead 3277 * @return string|bool 3070 3278 */ 3071 3279 public function get_favicon() 3072 3280 { 3073 trigger_error('Favicon handling has been removed , please use your own handling', \E_USER_DEPRECATED);3281 trigger_error('Favicon handling has been removed since SimplePie 1.3, please use your own handling', \E_USER_DEPRECATED); 3074 3282 3075 3283 if (($url = $this->get_link()) !== null) { … … 3084 3292 * 3085 3293 * @param string $method Method name 3086 * @param array $args Arguments to the method3294 * @param array<mixed> $args Arguments to the method 3087 3295 * @return mixed 3088 3296 */ 3089 public function __call( $method,$args)3297 public function __call(string $method, array $args) 3090 3298 { 3091 3299 if (strpos($method, 'subscribe_') === 0) { 3092 trigger_error('subscribe_*() has been deprecated , implement the callback yourself', \E_USER_DEPRECATED);3300 trigger_error('subscribe_*() has been deprecated since SimplePie 1.3, implement the callback yourself', \E_USER_DEPRECATED); 3093 3301 return ''; 3094 3302 } 3095 3303 if ($method === 'enable_xml_dump') { 3096 trigger_error('enable_xml_dump() has been deprecated , use get_raw_data() instead', \E_USER_DEPRECATED);3304 trigger_error('enable_xml_dump() has been deprecated since SimplePie 1.3, use get_raw_data() instead', \E_USER_DEPRECATED); 3097 3305 return false; 3098 3306 } … … 3100 3308 $class = get_class($this); 3101 3309 $trace = debug_backtrace(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection 3102 $file = $trace[0]['file'] ;3103 $line = $trace[0]['line'] ;3310 $file = $trace[0]['file'] ?? ''; 3311 $line = $trace[0]['line'] ?? ''; 3104 3312 throw new SimplePieException("Call to undefined method $class::$method() in $file on line $line"); 3105 3313 } 3106 3314 3107 3315 /** 3316 * Item factory 3317 * 3318 * @param array<string, mixed> $data 3319 */ 3320 private function make_item(array $data): Item 3321 { 3322 $item = $this->registry->create(Item::class, [$this, $data]); 3323 $item->set_sanitize($this->sanitize); 3324 3325 return $item; 3326 } 3327 3328 /** 3108 3329 * Sorting callback for items 3109 3330 * 3110 3331 * @access private 3111 * @param SimplePie$a3112 * @param SimplePie$b3113 * @return boolean3114 */ 3115 public static function sort_items( $a,$b)3332 * @param Item $a 3333 * @param Item $b 3334 * @return -1|0|1 3335 */ 3336 public static function sort_items(Item $a, Item $b) 3116 3337 { 3117 3338 $a_date = $a->get_date('U'); … … 3137 3358 * 3138 3359 * @link http://simplepie.org/wiki/tutorial/sort_multiple_feeds_by_time_and_date#if_feeds_require_separate_per-feed_settings 3139 * @param array $urls List of SimplePie feed objects to merge3360 * @param array<SimplePie> $urls List of SimplePie feed objects to merge 3140 3361 * @param int $start Starting item 3141 3362 * @param int $end Number of items to return 3142 3363 * @param int $limit Maximum number of items per feed 3143 * @return array 3144 */ 3145 public static function merge_items( $urls, $start = 0, $end = 0,$limit = 0)3146 { 3147 if ( is_array($urls) && sizeof($urls) > 0) {3364 * @return array<Item> 3365 */ 3366 public static function merge_items(array $urls, int $start = 0, int $end = 0, int $limit = 0) 3367 { 3368 if (count($urls) > 0) { 3148 3369 $items = []; 3149 3370 foreach ($urls as $arg) { 3150 3371 if ($arg instanceof SimplePie) { 3151 3372 $items = array_merge($items, $arg->get_items(0, $limit)); 3373 3374 // @phpstan-ignore-next-line Enforce PHPDoc type. 3152 3375 } else { 3153 3376 trigger_error('Arguments must be SimplePie objects', E_USER_WARNING); … … 3173 3396 * There is no way to find PuSH links in the body of a microformats feed, 3174 3397 * so they are added to the headers when found, to be used later by get_links. 3175 * @param \SimplePie\File $file 3176 * @param string $hub 3177 * @param string $self 3178 */ 3179 private function store_links(&$file, $hub, $self) 3180 { 3181 if (isset($file->headers['link']['hub']) || 3182 (isset($file->headers['link']) && 3183 preg_match('/rel=hub/', $file->headers['link']))) { 3184 return; 3185 } 3186 3187 if ($hub) { 3188 if (isset($file->headers['link'])) { 3189 if ($file->headers['link'] !== '') { 3190 $file->headers['link'] = ', '; 3191 } 3192 } else { 3193 $file->headers['link'] = ''; 3194 } 3195 $file->headers['link'] .= '<'.$hub.'>; rel=hub'; 3196 if ($self) { 3197 $file->headers['link'] .= ', <'.$self.'>; rel=self'; 3198 } 3199 } 3398 */ 3399 private function store_links(Response $file, ?string $hub, ?string $self): Response 3400 { 3401 $linkHeaderLine = $file->get_header_line('link'); 3402 $linkHeader = $file->get_header('link'); 3403 3404 if ($hub && !preg_match('/rel=hub/', $linkHeaderLine)) { 3405 $linkHeader[] = '<'.$hub.'>; rel=hub'; 3406 } 3407 3408 if ($self && !preg_match('/rel=self/', $linkHeaderLine)) { 3409 $linkHeader[] = '<'.$self.'>; rel=self'; 3410 } 3411 3412 if (count($linkHeader) > 0) { 3413 $file = $file->with_header('link', $linkHeader); 3414 } 3415 3416 return $file; 3200 3417 } 3201 3418 … … 3207 3424 * @return DataCache 3208 3425 */ 3209 private function get_cache( $feed_url = '')3426 private function get_cache(string $feed_url = ''): DataCache 3210 3427 { 3211 3428 if ($this->cache === null) { … … 3222 3439 return $this->cache; 3223 3440 } 3441 3442 /** 3443 * Get a HTTP client 3444 */ 3445 private function get_http_client(): Client 3446 { 3447 if ($this->http_client === null) { 3448 $this->http_client = new FileClient( 3449 $this->get_registry(), 3450 [ 3451 'timeout' => $this->timeout, 3452 'redirects' => 5, 3453 'useragent' => $this->useragent, 3454 'force_fsockopen' => $this->force_fsockopen, 3455 'curl_options' => $this->curl_options, 3456 ] 3457 ); 3458 $this->http_client_injected = true; 3459 } 3460 3461 return $this->http_client; 3462 } 3224 3463 } 3225 3464 -
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 { -
trunk/src/wp-includes/SimplePie/src/XML/Declaration/Parser.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\XML\Declaration; … … 47 10 /** 48 11 * Parses the XML Declaration 49 *50 * @package SimplePie51 * @subpackage Parsing52 12 */ 53 13 class Parser … … 139 99 * @param string $data Input data 140 100 */ 141 public function __construct( $data)101 public function __construct(string $data) 142 102 { 143 103 $this->data = $data; … … 151 111 * @return bool true on success, false on failure 152 112 */ 153 public function parse() 113 public function parse(): bool 154 114 { 155 115 while ($this->state && $this->state !== self::STATE_EMIT && $this->has_data()) { … … 162 122 } 163 123 164 $this->version = ''; 165 $this->encoding = ''; 166 $this->standalone = ''; 124 // Reset the parser state. 125 $this->version = '1.0'; 126 $this->encoding = 'UTF-8'; 127 $this->standalone = false; 167 128 return false; 168 129 } … … 174 135 * @return bool true if there is further data, false if not 175 136 */ 176 public function has_data() 137 public function has_data(): bool 177 138 { 178 139 return (bool) ($this->position < $this->data_length); … … 193 154 /** 194 155 * Read value 156 * 157 * @return string|false 195 158 */ 196 159 public function get_value() … … 209 172 } 210 173 211 public function before_version_name() 174 public function before_version_name(): void 212 175 { 213 176 if ($this->skip_whitespace()) { … … 218 181 } 219 182 220 public function version_name() 183 public function version_name(): void 221 184 { 222 185 if (substr($this->data, $this->position, 7) === 'version') { … … 229 192 } 230 193 231 public function version_equals() 194 public function version_equals(): void 232 195 { 233 196 if (substr($this->data, $this->position, 1) === '=') { … … 240 203 } 241 204 242 public function version_value() 243 { 244 if ($this->version = $this->get_value()) { 205 public function version_value(): void 206 { 207 if ($version = $this->get_value()) { 208 $this->version = $version; 245 209 $this->skip_whitespace(); 246 210 if ($this->has_data()) { … … 254 218 } 255 219 256 public function encoding_name() 220 public function encoding_name(): void 257 221 { 258 222 if (substr($this->data, $this->position, 8) === 'encoding') { … … 265 229 } 266 230 267 public function encoding_equals() 231 public function encoding_equals(): void 268 232 { 269 233 if (substr($this->data, $this->position, 1) === '=') { … … 276 240 } 277 241 278 public function encoding_value() 279 { 280 if ($this->encoding = $this->get_value()) { 242 public function encoding_value(): void 243 { 244 if ($encoding = $this->get_value()) { 245 $this->encoding = $encoding; 281 246 $this->skip_whitespace(); 282 247 if ($this->has_data()) { … … 290 255 } 291 256 292 public function standalone_name() 257 public function standalone_name(): void 293 258 { 294 259 if (substr($this->data, $this->position, 10) === 'standalone') { … … 301 266 } 302 267 303 public function standalone_equals() 268 public function standalone_equals(): void 304 269 { 305 270 if (substr($this->data, $this->position, 1) === '=') { … … 312 277 } 313 278 314 public function standalone_value() 279 public function standalone_value(): void 315 280 { 316 281 if ($standalone = $this->get_value()) { -
trunk/src/wp-includes/class-wp-simplepie-file.php
r59141 r60771 76 76 $this->headers = wp_remote_retrieve_headers( $res ); 77 77 78 if ( $this->headers instanceof \WpOrg\Requests\Utility\CaseInsensitiveDictionary ) { 79 $this->headers = $this->headers->getAll(); 80 } 81 78 82 /* 79 83 * SimplePie expects multiple headers to be stored as a comma-separated string, -
trunk/src/wp-includes/feed.php
r60703 r60771 813 813 $feed = new SimplePie\SimplePie(); 814 814 815 $feed->set_sanitize_class( 'WP_SimplePie_Sanitize_KSES' ); 815 $feed->get_registry()->register( SimplePie\Sanitize::class, 'WP_SimplePie_Sanitize_KSES', true ); 816 816 817 /* 817 818 * We must manually overwrite $feed->sanitize because SimplePie's constructor … … 830 831 } 831 832 832 $feed-> set_file_class( 'WP_SimplePie_File');833 $feed->get_registry()->register( SimplePie\File::class, 'WP_SimplePie_File', true ); 833 834 834 835 $feed->set_feed_url( $url );
Note: See TracChangeset
for help on using the changeset viewer.