External Libraries: Update the SimplePie library to version 1.9.0.

References:
* [https://github.com/simplepie/simplepie/releases/tag/1.9.0 SimplePie 1.9.0 release notes]
* [https://github.com/simplepie/simplepie/compare/1.8.1...1.9.0 Full list of changes in SimplePie 1.9.0]

Follow-up to [59141], [60490].

Props swissspidy, TobiasBg, SergeyBiryukov.
Fixes #63961.
Built from https://develop.svn.wordpress.org/trunk@60771


git-svn-id: http://core.svn.wordpress.org/trunk@60107 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov
2025-09-16 22:47:31 +00:00
parent 60ce43fb10
commit 5a82c86d00
85 changed files with 3543 additions and 4280 deletions

View File

@@ -1,46 +1,7 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
/**
* PSR-4 implementation for SimplePie.
@@ -93,9 +54,6 @@ if (!class_exists('SimplePie'))
/**
* Autoloader class
*
* @package SimplePie
* @subpackage API
*/
class SimplePie_Autoloader
{

View File

@@ -1,47 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2017, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.7.0
* @copyright 2004-2017 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\SimplePie as NamespacedSimplePie;
@@ -49,6 +11,7 @@ class_exists('SimplePie\SimplePie');
// @trigger_error(sprintf('Using the "SimplePie" class is deprecated since SimplePie 1.7.0, use "SimplePie\SimplePie" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\SimplePie" instead */
class SimplePie extends NamespacedSimplePie

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Author;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Author');
// @trigger_error(sprintf('Using the "SimplePie_Author" class is deprecated since SimplePie 1.7.0, use "SimplePie\Author" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Author" instead */
class SimplePie_Author extends Author

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Cache;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Cache');
// @trigger_error(sprintf('Using the "SimplePie_Cache" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache" instead */
class SimplePie_Cache extends Cache

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Cache\Base;
@@ -48,6 +11,7 @@ interface_exists('SimplePie\Cache\Base');
// @trigger_error(sprintf('Using the "SimplePie_Cache_Base" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Base" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Base" instead */
interface SimplePie_Cache_Base extends Base

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Cache\DB;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Cache\DB');
// @trigger_error(sprintf('Using the "SimplePie_Cache_DB" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\DB" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\DB" instead */
abstract class SimplePie_Cache_DB extends DB

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Cache\File;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Cache\File');
// @trigger_error(sprintf('Using the "SimplePie_Cache_File" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\File" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\File" instead */
class SimplePie_Cache_File extends File

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Cache\Memcache;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Cache\Memcache');
// @trigger_error(sprintf('Using the "SimplePie_Cache_Memcache" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Memcache" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Memcache" instead */
class SimplePie_Cache_Memcache extends Memcache

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Cache\Memcached;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Cache\Memcached');
// @trigger_error(sprintf('Using the "SimplePie_Cache_Memcached" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Memcached" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Memcached" instead */
class SimplePie_Cache_Memcached extends Memcached

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Cache\MySQL;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Cache\MySQL');
// @trigger_error(sprintf('Using the "SimplePie_Cache_MySQL" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\MySQL" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\MySQL" instead */
class SimplePie_Cache_MySQL extends MySQL

View File

@@ -1,14 +1,9 @@
<?php
/**
* SimplePie Redis Cache Extension
*
* @package SimplePie
* @author Jan Kozak <galvani78@gmail.com>
* @link http://galvani.cz/
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version 0.2.9
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Cache\Redis;
@@ -16,6 +11,7 @@ class_exists('SimplePie\Cache\Redis');
// @trigger_error(sprintf('Using the "SimplePie_Cache_Redis" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Redis" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Redis" instead */
class SimplePie_Cache_Redis extends Redis

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Caption;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Caption');
// @trigger_error(sprintf('Using the "SimplePie_Caption" class is deprecated since SimplePie 1.7.0, use "SimplePie\Caption" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Caption" instead */
class SimplePie_Caption extends Caption

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Category;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Category');
// @trigger_error(sprintf('Using the "SimplePie_Category" class is deprecated since SimplePie 1.7.0, use "SimplePie\Category" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Category" instead */
class SimplePie_Category extends Category

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Content\Type\Sniffer;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Content\Type\Sniffer');
// @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);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Content\Type\Sniffer" instead */
class SimplePie_Content_Type_Sniffer extends Sniffer

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Copyright;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Copyright');
// @trigger_error(sprintf('Using the "SimplePie_Copyright" class is deprecated since SimplePie 1.7.0, use "SimplePie\Copyright" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Copyright" instead */
class SimplePie_Copyright extends Copyright

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
/**
* SimplePie class.
@@ -48,8 +11,6 @@
* Class for backward compatibility.
*
* @deprecated Use {@see SimplePie} directly
* @package SimplePie
* @subpackage API
*/
class SimplePie_Core extends SimplePie
{

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Credit;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Credit');
// @trigger_error(sprintf('Using the "SimplePie_Credit" class is deprecated since SimplePie 1.7.0, use "SimplePie\Credit" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Credit" instead */
class SimplePie_Credit extends Credit

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
/**
@@ -49,7 +12,6 @@
* This implements HTML5 as of revision 967 (2007-06-28)
*
* @deprecated Use DOMDocument instead!
* @package SimplePie
*/
class SimplePie_Decode_HTML_Entities
{
@@ -83,7 +45,7 @@ class SimplePie_Decode_HTML_Entities
* @access public
* @param string $data Input data
*/
public function __construct($data)
public function __construct(string $data)
{
$this->data = $data;
}
@@ -96,7 +58,8 @@ class SimplePie_Decode_HTML_Entities
*/
public function parse()
{
while (($this->position = strpos($this->data, '&', $this->position)) !== false) {
while (($position = strpos($this->data, '&', $this->position)) !== false) {
$this->position = $position;
$this->consume();
$this->entity();
$this->consumed = '';
@@ -108,7 +71,7 @@ class SimplePie_Decode_HTML_Entities
* Consume the next byte
*
* @access private
* @return mixed The next byte, or false, if there is no more data
* @return string|false The next byte, or false, if there is no more data
*/
public function consume()
{
@@ -125,9 +88,9 @@ class SimplePie_Decode_HTML_Entities
*
* @access private
* @param string $chars Characters to consume
* @return mixed A series of characters that match the range, or false
* @return string|false A series of characters that match the range, or false
*/
public function consume_range($chars)
public function consume_range(string $chars)
{
if ($len = strspn($this->data, $chars, $this->position)) {
$data = substr($this->data, $this->position, $len);
@@ -143,6 +106,7 @@ class SimplePie_Decode_HTML_Entities
* Unconsume one byte
*
* @access private
* @return void
*/
public function unconsume()
{
@@ -154,6 +118,7 @@ class SimplePie_Decode_HTML_Entities
* Decode an entity
*
* @access private
* @return void
*/
public function entity()
{
@@ -187,9 +152,13 @@ class SimplePie_Decode_HTML_Entities
static $windows_1252_specials = [0x0D => "\x0A", 0x80 => "\xE2\x82\xAC", 0x81 => "\xEF\xBF\xBD", 0x82 => "\xE2\x80\x9A", 0x83 => "\xC6\x92", 0x84 => "\xE2\x80\x9E", 0x85 => "\xE2\x80\xA6", 0x86 => "\xE2\x80\xA0", 0x87 => "\xE2\x80\xA1", 0x88 => "\xCB\x86", 0x89 => "\xE2\x80\xB0", 0x8A => "\xC5\xA0", 0x8B => "\xE2\x80\xB9", 0x8C => "\xC5\x92", 0x8D => "\xEF\xBF\xBD", 0x8E => "\xC5\xBD", 0x8F => "\xEF\xBF\xBD", 0x90 => "\xEF\xBF\xBD", 0x91 => "\xE2\x80\x98", 0x92 => "\xE2\x80\x99", 0x93 => "\xE2\x80\x9C", 0x94 => "\xE2\x80\x9D", 0x95 => "\xE2\x80\xA2", 0x96 => "\xE2\x80\x93", 0x97 => "\xE2\x80\x94", 0x98 => "\xCB\x9C", 0x99 => "\xE2\x84\xA2", 0x9A => "\xC5\xA1", 0x9B => "\xE2\x80\xBA", 0x9C => "\xC5\x93", 0x9D => "\xEF\xBF\xBD", 0x9E => "\xC5\xBE", 0x9F => "\xC5\xB8"];
if ($hex) {
$codepoint = hexdec($codepoint);
// Cap to PHP_INT_MAX to ensure consistent behaviour if $codepoint is so large
// it cannot fit into int just casting float to int might return junk (e.g. a negative number).
// If it is so large, `Misc::codepoint_to_utf8` will just return a replacement character.
$codepoint = (int) min(hexdec($codepoint), \PHP_INT_MAX);
} else {
$codepoint = intval($codepoint);
// Casting string to int caps at PHP_INT_MAX automatically.
$codepoint = (int) $codepoint;
}
if (isset($windows_1252_specials[$codepoint])) {
@@ -579,7 +548,9 @@ class SimplePie_Decode_HTML_Entities
];
for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++) {
$consumed = substr($this->consumed, 1);
// Cast for PHPStan on PHP < 8.0: We consumed as per the loop condition,
// so `$this->consumed` is non-empty and the substr offset is valid.
$consumed = (string) substr($this->consumed, 1);
if (isset($entities[$consumed])) {
$match = $consumed;
}

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Enclosure;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Enclosure');
// @trigger_error(sprintf('Using the "SimplePie_Enclosure" class is deprecated since SimplePie 1.7.0, use "SimplePie\Enclosure" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Enclosure" instead */
class SimplePie_Enclosure extends Enclosure

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Exception as SimplePieException;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Exception');
// @trigger_error(sprintf('Using the "SimplePie_Exception" class is deprecated since SimplePie 1.7.0, use "SimplePie\Exception" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Exception" instead */
class SimplePie_Exception extends SimplePieException

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\File;
@@ -48,6 +11,7 @@ class_exists('SimplePie\File');
// @trigger_error(sprintf('Using the "SimplePie_File" class is deprecated since SimplePie 1.7.0, use "SimplePie\File" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\File" instead */
class SimplePie_File extends File

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\HTTP\Parser;
@@ -48,8 +11,13 @@ class_exists('SimplePie\HTTP\Parser');
// @trigger_error(sprintf('Using the "SimplePie_HTTP_Parser" class is deprecated since SimplePie 1.7.0, use "SimplePie\HTTP\Parser" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\HTTP\Parser" instead */
/**
* @deprecated since SimplePie 1.7.0, use "SimplePie\HTTP\Parser" instead
* @template Psr7Compatible of bool
* @extends Parser<Psr7Compatible>
*/
class SimplePie_HTTP_Parser extends Parser
{
}

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\IRI;
@@ -48,6 +11,7 @@ class_exists('SimplePie\IRI');
// @trigger_error(sprintf('Using the "SimplePie_IRI" class is deprecated since SimplePie 1.7.0, use "SimplePie\IRI" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\IRI" instead */
class SimplePie_IRI extends IRI

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Item;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Item');
// @trigger_error(sprintf('Using the "SimplePie_Item" class is deprecated since SimplePie 1.7.0, use "SimplePie\Item" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Item" instead */
class SimplePie_Item extends Item

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Locator;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Locator');
// @trigger_error(sprintf('Using the "SimplePie_Locator" class is deprecated since SimplePie 1.7.0, use "SimplePie\Locator" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Locator" instead */
class SimplePie_Locator extends Locator

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Misc;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Misc');
// @trigger_error(sprintf('Using the "SimplePie_Misc" class is deprecated since SimplePie 1.7.0, use "SimplePie\Misc" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Misc" instead */
class SimplePie_Misc extends Misc

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Net\IPv6;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Net\IPv6');
// @trigger_error(sprintf('Using the "SimplePie_Net_IPv6" class is deprecated since SimplePie 1.7.0, use "SimplePie\Net\IPv6" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Net\IPv6" instead */
class SimplePie_Net_IPv6 extends IPv6

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Parse\Date;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Parse\Date');
// @trigger_error(sprintf('Using the "SimplePie_Parse_Date" class is deprecated since SimplePie 1.7.0, use "SimplePie\Parse\Date" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Parse\Date" instead */
class SimplePie_Parse_Date extends Date

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Parser;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Parser');
// @trigger_error(sprintf('Using the "SimplePie_Parser" class is deprecated since SimplePie 1.7.0, use "SimplePie\Parser" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Parser" instead */
class SimplePie_Parser extends Parser

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Rating;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Rating');
// @trigger_error(sprintf('Using the "SimplePie_Rating" class is deprecated since SimplePie 1.7.0, use "SimplePie\Rating" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Rating" instead */
class SimplePie_Rating extends Rating

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Registry;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Registry');
// @trigger_error(sprintf('Using the "SimplePie_Registry" class is deprecated since SimplePie 1.7.0, use "SimplePie\Registry" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Registry" instead */
class SimplePie_Registry extends Registry

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Restriction;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Restriction');
// @trigger_error(sprintf('Using the "SimplePie_Restriction" class is deprecated since SimplePie 1.7.0, use "SimplePie\Restriction" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Restriction" instead */
class SimplePie_Restriction extends Restriction

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Sanitize;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Sanitize');
// @trigger_error(sprintf('Using the "SimplePie_Sanitize" class is deprecated since SimplePie 1.7.0, use "SimplePie\Sanitize" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Sanitize" instead */
class SimplePie_Sanitize extends Sanitize

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Source;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Source');
// @trigger_error(sprintf('Using the "SimplePie_Source" class is deprecated since SimplePie 1.7.0, use "SimplePie\Source" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Source" instead */
class SimplePie_Source extends Source

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\XML\Declaration\Parser;
@@ -48,6 +11,7 @@ class_exists('SimplePie\XML\Declaration\Parser');
// @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);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\XML\Declaration\Parser" instead */
class SimplePie_XML_Declaration_Parser extends Parser

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
use SimplePie\Gzdecode;
@@ -48,6 +11,7 @@ class_exists('SimplePie\Gzdecode');
// @trigger_error(sprintf('Using the "SimplePie_gzdecode" class is deprecated since SimplePie 1.7.0, use "SimplePie\Gzdecode" instead.'), \E_USER_DEPRECATED);
/** @phpstan-ignore-next-line */
if (\false) {
/** @deprecated since SimplePie 1.7.0, use "SimplePie\Gzdecode" instead */
class SimplePie_gzdecode extends Gzdecode

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
@@ -50,16 +13,13 @@ namespace SimplePie;
* Used by {@see Item::get_author()} and {@see SimplePie::get_authors()}
*
* This class can be overloaded with {@see SimplePie::set_author_class()}
*
* @package SimplePie
* @subpackage API
*/
class Author
{
/**
* Author's name
*
* @var string
* @var ?string
* @see get_name()
*/
public $name;
@@ -67,7 +27,7 @@ class Author
/**
* Author's link
*
* @var string
* @var ?string
* @see get_link()
*/
public $link;
@@ -75,20 +35,19 @@ class Author
/**
* Author's email address
*
* @var string
* @var ?string
* @see get_email()
*/
public $email;
/**
* Constructor, used to input the data
*
* @param string $name
* @param string $link
* @param string $email
*/
public function __construct($name = null, $link = null, $email = null)
{
public function __construct(
?string $name = null,
?string $link = null,
?string $email = null
) {
$this->name = $name;
$this->link = $link;
$this->email = $email;

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
@@ -53,8 +16,6 @@ use SimplePie\Cache\Base;
* although the preferred way is to create your own handler
* via {@see register()}
*
* @package SimplePie
* @subpackage Caching
* @deprecated since SimplePie 1.8.0, use "SimplePie\SimplePie::set_cache()" instead
*/
class Cache
@@ -64,13 +25,13 @@ class Cache
*
* These receive 3 parameters to their constructor, as documented in
* {@see register()}
* @var array
* @var array<string, class-string<Base>>
*/
protected static $handlers = [
'mysql' => 'SimplePie\Cache\MySQL',
'memcache' => 'SimplePie\Cache\Memcache',
'memcached' => 'SimplePie\Cache\Memcached',
'redis' => 'SimplePie\Cache\Redis'
'mysql' => Cache\MySQL::class,
'memcache' => Cache\Memcache::class,
'memcached' => Cache\Memcached::class,
'redis' => Cache\Redis::class,
];
/**
@@ -88,7 +49,7 @@ class Cache
* @param Base::TYPE_FEED|Base::TYPE_IMAGE $extension 'spi' or 'spc'
* @return Base Type of object depends on scheme of `$location`
*/
public static function get_handler($location, $filename, $extension)
public static function get_handler(string $location, string $filename, $extension)
{
$type = explode(':', $location, 2);
$type = $type[0];
@@ -104,8 +65,12 @@ class Cache
* Create a new SimplePie\Cache object
*
* @deprecated since SimplePie 1.3.1, use {@see get_handler()} instead
* @param string $location
* @param string $filename
* @param Base::TYPE_FEED|Base::TYPE_IMAGE $extension
* @return Base
*/
public function create($location, $filename, $extension)
public function create(string $location, string $filename, $extension)
{
trigger_error('Cache::create() has been replaced with Cache::get_handler() since SimplePie 1.3.1, use the registry system instead.', \E_USER_DEPRECATED);
@@ -117,8 +82,9 @@ class Cache
*
* @param string $type DSN type to register for
* @param class-string<Base> $class Name of handler class. Must implement Base
* @return void
*/
public static function register($type, $class)
public static function register(string $type, $class)
{
self::$handlers[$type] = $class;
}
@@ -127,12 +93,17 @@ class Cache
* Parse a URL into an array
*
* @param string $url
* @return array
* @return array<string, mixed>
*/
public static function parse_URL($url)
public static function parse_URL(string $url)
{
$params = parse_url($url);
$params['extras'] = [];
$parsedUrl = parse_url($url);
if ($parsedUrl === false) {
return [];
}
$params = array_merge($parsedUrl, ['extras' => []]);
if (isset($params['query'])) {
parse_str($params['query'], $params['extras']);
}

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\Cache;
@@ -50,8 +13,6 @@ namespace SimplePie\Cache;
* Classes to be used with {@see \SimplePie\Cache::register()} are expected
* to implement this interface.
*
* @package SimplePie
* @subpackage Caching
* @deprecated since SimplePie 1.8.0, use "Psr\SimpleCache\CacheInterface" instead
*/
interface Base
@@ -77,12 +38,12 @@ interface Base
* @param string $name Unique ID for the cache
* @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
*/
public function __construct($location, $name, $type);
public function __construct(string $location, string $name, $type);
/**
* Save data to the cache
*
* @param array|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
* @param array<mixed>|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
* @return bool Successfulness
*/
public function save($data);
@@ -90,7 +51,7 @@ interface Base
/**
* Retrieve the data saved to the cache
*
* @return array Data for SimplePie::$data
* @return array<mixed> Data for SimplePie::$data
*/
public function load();

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2022 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\Cache;
@@ -49,8 +12,6 @@ use InvalidArgumentException;
/**
* Adapter for deprecated \SimplePie\Cache\Base implementations
*
* @package SimplePie
* @subpackage Caching
* @internal
*/
final class BaseDataCache implements DataCache
@@ -114,7 +75,7 @@ final class BaseDataCache implements DataCache
* </code>
*
* @param string $key The key of the item to store.
* @param array $value The value of the item to store, must be serializable.
* @param array<mixed> $value The value of the item to store, must be serializable.
* @param null|int $ttl Optional. The TTL value of this item. If no value is sent and
* the driver supports TTL then the library may set a default value
* for it or let the driver take care of that.

View File

@@ -1,61 +1,25 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2022 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\Cache;
/**
* Creating a cache filename with callables
*
* @package SimplePie
* @subpackage Caching
*/
final class CallableNameFilter implements NameFilter
{
/**
* @var callable
* @var callable(string): string
*/
private $callable;
/**
* @param callable(string): string $callable
*/
public function __construct(callable $callable)
{
$this->callable = $callable;
@@ -78,7 +42,7 @@ final class CallableNameFilter implements NameFilter
* and encodings or longer lengths, but MUST support at least that
* minimum.
*
* @param string $name The name for the cache will be most likly an url with query string
* @param string $name The name for the cache will be most likely an url with query string
*
* @return string the new cache name
*/

View File

@@ -1,54 +1,17 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\Cache;
use SimplePie\Item;
/**
* Base class for database-based caches
*
* @package SimplePie
* @subpackage Caching
* @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead
*/
abstract class DB implements Base
@@ -59,9 +22,9 @@ abstract class DB implements Base
* Converts a given {@see SimplePie} object into data to be stored
*
* @param \SimplePie\SimplePie $data
* @return array First item is the serialized data for storage, second item is the unique ID for this item
* @return array{string, array<string, Item>} First item is the serialized data for storage, second item is the unique ID for this item
*/
protected static function prepare_simplepie_object_for_cache($data)
protected static function prepare_simplepie_object_for_cache(\SimplePie\SimplePie $data)
{
$items = $data->get_items();
$items_by_id = [];

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2022 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\Cache;
@@ -55,8 +18,6 @@ use InvalidArgumentException;
* The methods names must be different, but should be compatible to the
* methods of \Psr\SimpleCache\CacheInterface.
*
* @package SimplePie
* @subpackage Caching
* @internal
*/
interface DataCache
@@ -88,7 +49,7 @@ interface DataCache
* </code>
*
* @param string $key The key of the item to store.
* @param array $value The value of the item to store, must be serializable.
* @param array<mixed> $value The value of the item to store, must be serializable.
* @param null|int $ttl Optional. The TTL value of this item. If no value is sent and
* the driver supports TTL then the library may set a default value
* for it or let the driver take care of that.

View File

@@ -1,54 +1,15 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\Cache;
/**
* Caches data to the filesystem
*
* @package SimplePie
* @subpackage Caching
* @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead
*/
class File implements Base
@@ -89,7 +50,7 @@ class File implements Base
* @param string $name Unique ID for the cache
* @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
*/
public function __construct($location, $name, $type)
public function __construct(string $location, string $name, $type)
{
$this->location = $location;
$this->filename = $name;
@@ -100,7 +61,7 @@ class File implements Base
/**
* Save data to the cache
*
* @param array|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
* @param array<mixed>|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
* @return bool Successfulness
*/
public function save($data)
@@ -119,12 +80,12 @@ class File implements Base
/**
* Retrieve the data saved to the cache
*
* @return array Data for SimplePie::$data
* @return array<mixed>|false Data for SimplePie::$data
*/
public function load()
{
if (file_exists($this->name) && is_readable($this->name)) {
return unserialize(file_get_contents($this->name));
return unserialize((string) file_get_contents($this->name));
}
return false;
}
@@ -132,7 +93,7 @@ class File implements Base
/**
* Retrieve the last modified time for the cache
*
* @return int Timestamp
* @return int|false Timestamp
*/
public function mtime()
{

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\Cache;
@@ -55,8 +18,6 @@ use Memcache as NativeMemcache;
* connect to memcache on `localhost` on port 11211. All tables will be
* prefixed with `sp_` and data will expire after 3600 seconds
*
* @package SimplePie
* @subpackage Caching
* @uses Memcache
* @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead
*/
@@ -65,14 +26,14 @@ class Memcache implements Base
/**
* Memcache instance
*
* @var Memcache
* @var NativeMemcache
*/
protected $cache;
/**
* Options
*
* @var array
* @var array<string, mixed>
*/
protected $options;
@@ -90,7 +51,7 @@ class Memcache implements Base
* @param string $name Unique ID for the cache
* @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
*/
public function __construct($location, $name, $type)
public function __construct(string $location, string $name, $type)
{
$this->options = [
'host' => '127.0.0.1',
@@ -111,7 +72,7 @@ class Memcache implements Base
/**
* Save data to the cache
*
* @param array|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
* @param array<mixed>|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
* @return bool Successfulness
*/
public function save($data)
@@ -125,7 +86,7 @@ class Memcache implements Base
/**
* Retrieve the data saved to the cache
*
* @return array Data for SimplePie::$data
* @return array<mixed>|false Data for SimplePie::$data
*/
public function load()
{
@@ -140,7 +101,7 @@ class Memcache implements Base
/**
* Retrieve the last modified time for the cache
*
* @return int Timestamp
* @return int|false Timestamp
*/
public function mtime()
{

View File

@@ -1,46 +1,10 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-FileCopyrightText: 2015 Paul L. McNeely
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\Cache;
@@ -55,9 +19,6 @@ use Memcached as NativeMemcached;
* connect to memcached on `localhost` on port 11211. All tables will be
* prefixed with `sp_` and data will expire after 3600 seconds
*
* @package SimplePie
* @subpackage Caching
* @author Paul L. McNeely
* @uses Memcached
* @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead
*/
@@ -71,7 +32,7 @@ class Memcached implements Base
/**
* Options
* @var array
* @var array<string, mixed>
*/
protected $options;
@@ -87,7 +48,7 @@ class Memcached implements Base
* @param string $name Unique ID for the cache
* @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
*/
public function __construct($location, $name, $type)
public function __construct(string $location, string $name, $type)
{
$this->options = [
'host' => '127.0.0.1',
@@ -107,7 +68,7 @@ class Memcached implements Base
/**
* Save data to the cache
* @param array|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
* @param array<mixed>|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
* @return bool Successfulness
*/
public function save($data)
@@ -121,7 +82,7 @@ class Memcached implements Base
/**
* Retrieve the data saved to the cache
* @return array Data for SimplePie::$data
* @return array<mixed>|false Data for SimplePie::$data
*/
public function load()
{
@@ -164,9 +125,10 @@ class Memcached implements Base
/**
* Set the last modified time and data to NativeMemcached
* @param string|false $data
* @return bool Success status
*/
private function setData($data)
private function setData($data): bool
{
if ($data !== false) {
$this->cache->set($this->name . '_mtime', time(), (int)$this->options['extras']['timeout']);

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\Cache;
@@ -53,8 +16,6 @@ namespace SimplePie\Cache;
* connect to the `mydb` database on `localhost` on port 3306, with the user
* `root` and the password `password`. All tables will be prefixed with `sp_`
*
* @package SimplePie
* @subpackage Caching
* @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead
*/
class MySQL extends DB
@@ -62,14 +23,14 @@ class MySQL extends DB
/**
* PDO instance
*
* @var \PDO
* @var \PDO|null
*/
protected $mysql;
/**
* Options
*
* @var array
* @var array<string, mixed>
*/
protected $options;
@@ -87,7 +48,7 @@ class MySQL extends DB
* @param string $name Unique ID for the cache
* @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
*/
public function __construct($location, $name, $type)
public function __construct(string $location, string $name, $type)
{
$this->options = [
'user' => null,
@@ -147,7 +108,7 @@ class MySQL extends DB
/**
* Save data to the cache
*
* @param array|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
* @param array<string>|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
* @return bool Successfulness
*/
public function save($data)
@@ -268,7 +229,7 @@ class MySQL extends DB
/**
* Retrieve the data saved to the cache
*
* @return array Data for SimplePie::$data
* @return array<string>|false Data for SimplePie::$data
*/
public function load()
{
@@ -310,7 +271,7 @@ class MySQL extends DB
$query->bindValue(':feed', $this->id);
if ($query->execute()) {
while ($row = $query->fetchColumn()) {
$feed['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['entry'][] = unserialize($row);
$feed['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['entry'][] = unserialize((string) $row);
}
} else {
return false;
@@ -325,7 +286,7 @@ class MySQL extends DB
/**
* Retrieve the last modified time for the cache
*
* @return int Timestamp
* @return int|false Timestamp
*/
public function mtime()
{
@@ -336,7 +297,7 @@ class MySQL extends DB
$query = $this->mysql->prepare('SELECT `mtime` FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :id');
$query->bindValue(':id', $this->id);
if ($query->execute() && ($time = $query->fetchColumn())) {
return $time;
return (int) $time;
}
return false;

View File

@@ -1,53 +1,14 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2022 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\Cache;
/**
* Interface for creating a cache filename
*
* @package SimplePie
* @subpackage Caching
*/
interface NameFilter
{
@@ -68,7 +29,7 @@ interface NameFilter
* and encodings or longer lengths, but MUST support at least that
* minimum.
*
* @param string $name The name for the cache will be most likly an url with query string
* @param string $name The name for the cache will be most likely an url with query string
*
* @return string the new cache name
*/

View File

@@ -1,57 +1,19 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2022 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\Cache;
use Psr\SimpleCache\CacheInterface;
use Psr\SimpleCache\InvalidArgumentException;
use Throwable;
/**
* Caches data into a PSR-16 cache implementation
*
* @package SimplePie
* @subpackage Caching
* @internal
*/
final class Psr16 implements DataCache
@@ -86,7 +48,7 @@ final class Psr16 implements DataCache
*
* @return array|mixed The value of the item from the cache, or $default in case of cache miss.
*
* @throws InvalidArgumentException
* @throws InvalidArgumentException&Throwable
* MUST be thrown if the $key string is not a legal value.
*/
public function get_data(string $key, $default = null)
@@ -109,14 +71,14 @@ final class Psr16 implements DataCache
* </code>
*
* @param string $key The key of the item to store.
* @param array $value The value of the item to store, must be serializable.
* @param array<mixed> $value The value of the item to store, must be serializable.
* @param null|int $ttl Optional. The TTL value of this item. If no value is sent and
* the driver supports TTL then the library may set a default value
* for it or let the driver take care of that.
*
* @return bool True on success and false on failure.
*
* @throws InvalidArgumentException
* @throws InvalidArgumentException&Throwable
* MUST be thrown if the $key string is not a legal value.
*/
public function set_data(string $key, array $value, ?int $ttl = null): bool
@@ -136,7 +98,7 @@ final class Psr16 implements DataCache
*
* @return bool True if the item was successfully removed. False if there was an error.
*
* @throws InvalidArgumentException
* @throws InvalidArgumentException&Throwable
* MUST be thrown if the $key string is not a legal value.
*/
public function delete_data(string $key): bool

View File

@@ -1,46 +1,10 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-FileCopyrightText: 2015 Jan Kozak <galvani78@gmail.com>
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\Cache;
@@ -55,8 +19,6 @@ use Redis as NativeRedis;
* connect to redis on `localhost` on port 6379. All tables will be
* prefixed with `simple_primary-` and data will expire after 3600 seconds
*
* @package SimplePie
* @subpackage Caching
* @uses Redis
* @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead
*/
@@ -72,7 +34,7 @@ class Redis implements Base
/**
* Options
*
* @var array
* @var array<string, mixed>
*/
protected $options;
@@ -88,9 +50,9 @@ class Redis implements Base
*
* @param string $location Location string (from SimplePie::$cache_location)
* @param string $name Unique ID for the cache
* @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
* @param Base::TYPE_FEED|Base::TYPE_IMAGE|array<string, mixed>|null $options Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
*/
public function __construct($location, $name, $options = null)
public function __construct(string $location, string $name, $options = null)
{
//$this->cache = \flow\simple\cache\Redis::getRedisClientInstance();
$parsed = \SimplePie\Cache::parse_URL($location);
@@ -118,6 +80,7 @@ class Redis implements Base
/**
* @param NativeRedis $cache
* @return void
*/
public function setRedisClient(NativeRedis $cache)
{
@@ -127,7 +90,7 @@ class Redis implements Base
/**
* Save data to the cache
*
* @param array|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
* @param array<mixed>|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
* @return bool Successfulness
*/
public function save($data)
@@ -146,7 +109,7 @@ class Redis implements Base
/**
* Retrieve the data saved to the cache
*
* @return array Data for SimplePie::$data
* @return array<mixed>|false Data for SimplePie::$data
*/
public function load()
{
@@ -161,7 +124,7 @@ class Redis implements Base
/**
* Retrieve the last modified time for the cache
*
* @return int Timestamp
* @return int|false Timestamp
*/
public function mtime()
{

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
@@ -50,16 +13,13 @@ namespace SimplePie;
* Used by {@see \SimplePie\Enclosure::get_caption()} and {@see \SimplePie\Enclosure::get_captions()}
*
* This class can be overloaded with {@see \SimplePie\SimplePie::set_caption_class()}
*
* @package SimplePie
* @subpackage API
*/
class Caption
{
/**
* Content type
*
* @var string
* @var ?string
* @see get_type()
*/
public $type;
@@ -67,7 +27,7 @@ class Caption
/**
* Language
*
* @var string
* @var ?string
* @see get_language()
*/
public $lang;
@@ -75,7 +35,7 @@ class Caption
/**
* Start time
*
* @var string
* @var ?string
* @see get_starttime()
*/
public $startTime;
@@ -83,7 +43,7 @@ class Caption
/**
* End time
*
* @var string
* @var ?string
* @see get_endtime()
*/
public $endTime;
@@ -91,7 +51,7 @@ class Caption
/**
* Caption text
*
* @var string
* @var ?string
* @see get_text()
*/
public $text;
@@ -102,8 +62,13 @@ class Caption
* For documentation on all the parameters, see the corresponding
* properties and their accessors
*/
public function __construct($type = null, $lang = null, $startTime = null, $endTime = null, $text = null)
{
public function __construct(
?string $type = null,
?string $lang = null,
?string $startTime = null,
?string $endTime = null,
?string $text = null
) {
$this->type = $type;
$this->lang = $lang;
$this->startTime = $startTime;

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
@@ -50,9 +13,6 @@ namespace SimplePie;
* Used by {@see \SimplePie\Item::get_category()} and {@see \SimplePie\Item::get_categories()}
*
* This class can be overloaded with {@see \SimplePie\SimplePie::set_category_class()}
*
* @package SimplePie
* @subpackage API
*/
class Category
{
@@ -99,7 +59,7 @@ class Category
* @param string|null $label
* @param string|null $type
*/
public function __construct($term = null, $scheme = null, $label = null, $type = null)
public function __construct(?string $term = null, ?string $scheme = null, ?string $label = null, ?string $type = null)
{
$this->term = $term;
$this->scheme = $scheme;
@@ -144,7 +104,7 @@ class Category
* @param bool $strict
* @return string|null
*/
public function get_label($strict = false)
public function get_label(bool $strict = false)
{
if ($this->label === null && $strict !== true) {
return $this->get_term();

View File

@@ -1,49 +1,16 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\Content\Type;
use InvalidArgumentException;
use SimplePie\File;
use SimplePie\HTTP\Response;
/**
* Content-type sniffing
*
@@ -54,26 +21,32 @@ namespace SimplePie\Content\Type;
*
*
* This class can be overloaded with {@see \SimplePie\SimplePie::set_content_type_sniffer_class()}
*
* @package SimplePie
* @subpackage HTTP
*/
class Sniffer
{
/**
* File object
*
* @var \SimplePie\File
* @var File|Response
*/
public $file;
/**
* Create an instance of the class with the input file
*
* @param Sniffer $file Input file
* @param File|Response $file Input file
*/
public function __construct($file)
public function __construct(/* File */ $file)
{
if (!is_object($file) || !$file instanceof Response) {
// For BC we're asking for `File`, but internally we accept every `Response` implementation
throw new InvalidArgumentException(sprintf(
'%s(): Argument #1 ($file) must be of type %s',
__METHOD__,
File::class
), 1);
}
$this->file = $file;
}
@@ -84,19 +57,21 @@ class Sniffer
*/
public function get_type()
{
if (isset($this->file->headers['content-type'])) {
if (!isset($this->file->headers['content-encoding'])
&& ($this->file->headers['content-type'] === 'text/plain'
|| $this->file->headers['content-type'] === 'text/plain; charset=ISO-8859-1'
|| $this->file->headers['content-type'] === 'text/plain; charset=iso-8859-1'
|| $this->file->headers['content-type'] === 'text/plain; charset=UTF-8')) {
$content_type = $this->file->has_header('content-type') ? $this->file->get_header_line('content-type') : null;
$content_encoding = $this->file->has_header('content-encoding') ? $this->file->get_header_line('content-encoding') : null;
if ($content_type !== null) {
if ($content_encoding === null
&& ($content_type === 'text/plain'
|| $content_type === 'text/plain; charset=ISO-8859-1'
|| $content_type === 'text/plain; charset=iso-8859-1'
|| $content_type === 'text/plain; charset=UTF-8')) {
return $this->text_or_binary();
}
if (($pos = strpos($this->file->headers['content-type'], ';')) !== false) {
$official = substr($this->file->headers['content-type'], 0, $pos);
if (($pos = strpos($content_type, ';')) !== false) {
$official = substr($content_type, 0, $pos);
} else {
$official = $this->file->headers['content-type'];
$official = $content_type;
}
$official = trim(strtolower($official));
@@ -130,12 +105,14 @@ class Sniffer
*/
public function text_or_binary()
{
if (substr($this->file->body, 0, 2) === "\xFE\xFF"
|| substr($this->file->body, 0, 2) === "\xFF\xFE"
|| substr($this->file->body, 0, 4) === "\x00\x00\xFE\xFF"
|| substr($this->file->body, 0, 3) === "\xEF\xBB\xBF") {
$body = $this->file->get_body_content();
if (substr($body, 0, 2) === "\xFE\xFF"
|| substr($body, 0, 2) === "\xFF\xFE"
|| substr($body, 0, 4) === "\x00\x00\xFE\xFF"
|| substr($body, 0, 3) === "\xEF\xBB\xBF") {
return 'text/plain';
} elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/', $this->file->body)) {
} elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/', $body)) {
return 'application/octet-stream';
}
@@ -149,25 +126,27 @@ class Sniffer
*/
public function unknown()
{
$ws = strspn($this->file->body, "\x09\x0A\x0B\x0C\x0D\x20");
if (strtolower(substr($this->file->body, $ws, 14)) === '<!doctype html'
|| strtolower(substr($this->file->body, $ws, 5)) === '<html'
|| strtolower(substr($this->file->body, $ws, 7)) === '<script') {
$body = $this->file->get_body_content();
$ws = strspn($body, "\x09\x0A\x0B\x0C\x0D\x20");
if (strtolower(substr($body, $ws, 14)) === '<!doctype html'
|| strtolower(substr($body, $ws, 5)) === '<html'
|| strtolower(substr($body, $ws, 7)) === '<script') {
return 'text/html';
} elseif (substr($this->file->body, 0, 5) === '%PDF-') {
} elseif (substr($body, 0, 5) === '%PDF-') {
return 'application/pdf';
} elseif (substr($this->file->body, 0, 11) === '%!PS-Adobe-') {
} elseif (substr($body, 0, 11) === '%!PS-Adobe-') {
return 'application/postscript';
} elseif (substr($this->file->body, 0, 6) === 'GIF87a'
|| substr($this->file->body, 0, 6) === 'GIF89a') {
} elseif (substr($body, 0, 6) === 'GIF87a'
|| substr($body, 0, 6) === 'GIF89a') {
return 'image/gif';
} elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") {
} elseif (substr($body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") {
return 'image/png';
} elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF") {
} elseif (substr($body, 0, 3) === "\xFF\xD8\xFF") {
return 'image/jpeg';
} elseif (substr($this->file->body, 0, 2) === "\x42\x4D") {
} elseif (substr($body, 0, 2) === "\x42\x4D") {
return 'image/bmp';
} elseif (substr($this->file->body, 0, 4) === "\x00\x00\x01\x00") {
} elseif (substr($body, 0, 4) === "\x00\x00\x01\x00") {
return 'image/vnd.microsoft.icon';
}
@@ -177,20 +156,22 @@ class Sniffer
/**
* Sniff images
*
* @return string Actual Content-Type
* @return string|false Actual Content-Type
*/
public function image()
{
if (substr($this->file->body, 0, 6) === 'GIF87a'
|| substr($this->file->body, 0, 6) === 'GIF89a') {
$body = $this->file->get_body_content();
if (substr($body, 0, 6) === 'GIF87a'
|| substr($body, 0, 6) === 'GIF89a') {
return 'image/gif';
} elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") {
} elseif (substr($body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") {
return 'image/png';
} elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF") {
} elseif (substr($body, 0, 3) === "\xFF\xD8\xFF") {
return 'image/jpeg';
} elseif (substr($this->file->body, 0, 2) === "\x42\x4D") {
} elseif (substr($body, 0, 2) === "\x42\x4D") {
return 'image/bmp';
} elseif (substr($this->file->body, 0, 4) === "\x00\x00\x01\x00") {
} elseif (substr($body, 0, 4) === "\x00\x00\x01\x00") {
return 'image/vnd.microsoft.icon';
}
@@ -204,16 +185,18 @@ class Sniffer
*/
public function feed_or_html()
{
$len = strlen($this->file->body);
$pos = strspn($this->file->body, "\x09\x0A\x0D\x20\xEF\xBB\xBF");
$body = $this->file->get_body_content();
$len = strlen($body);
$pos = strspn($body, "\x09\x0A\x0D\x20\xEF\xBB\xBF");
while ($pos < $len) {
switch ($this->file->body[$pos]) {
switch ($body[$pos]) {
case "\x09":
case "\x0A":
case "\x0D":
case "\x20":
$pos += strspn($this->file->body, "\x09\x0A\x0D\x20", $pos);
$pos += strspn($body, "\x09\x0A\x0D\x20", $pos);
continue 2;
case '<':
@@ -224,29 +207,29 @@ class Sniffer
return 'text/html';
}
if (substr($this->file->body, $pos, 3) === '!--') {
if (substr($body, $pos, 3) === '!--') {
$pos += 3;
if ($pos < $len && ($pos = strpos($this->file->body, '-->', $pos)) !== false) {
if ($pos < $len && ($pos = strpos($body, '-->', $pos)) !== false) {
$pos += 3;
} else {
return 'text/html';
}
} elseif (substr($this->file->body, $pos, 1) === '!') {
if ($pos < $len && ($pos = strpos($this->file->body, '>', $pos)) !== false) {
} elseif (substr($body, $pos, 1) === '!') {
if ($pos < $len && ($pos = strpos($body, '>', $pos)) !== false) {
$pos++;
} else {
return 'text/html';
}
} elseif (substr($this->file->body, $pos, 1) === '?') {
if ($pos < $len && ($pos = strpos($this->file->body, '?>', $pos)) !== false) {
} elseif (substr($body, $pos, 1) === '?') {
if ($pos < $len && ($pos = strpos($body, '?>', $pos)) !== false) {
$pos += 2;
} else {
return 'text/html';
}
} elseif (substr($this->file->body, $pos, 3) === 'rss'
|| substr($this->file->body, $pos, 7) === 'rdf:RDF') {
} elseif (substr($body, $pos, 3) === 'rss'
|| substr($body, $pos, 7) === 'rdf:RDF') {
return 'application/rss+xml';
} elseif (substr($this->file->body, $pos, 4) === 'feed') {
} elseif (substr($body, $pos, 4) === 'feed') {
return 'application/atom+xml';
} else {
return 'text/html';

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
@@ -50,16 +13,13 @@ namespace SimplePie;
* Used by {@see \SimplePie\Enclosure::get_copyright()}
*
* This class can be overloaded with {@see \SimplePie\SimplePie::set_copyright_class()}
*
* @package SimplePie
* @subpackage API
*/
class Copyright
{
/**
* Copyright URL
*
* @var string
* @var ?string
* @see get_url()
*/
public $url;
@@ -67,7 +27,7 @@ class Copyright
/**
* Attribution
*
* @var string
* @var ?string
* @see get_attribution()
*/
public $label;
@@ -78,8 +38,10 @@ class Copyright
* For documentation on all the parameters, see the corresponding
* properties and their accessors
*/
public function __construct($url = null, $label = null)
{
public function __construct(
?string $url = null,
?string $label = null
) {
$this->url = $url;
$this->label = $label;
}

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
@@ -50,16 +13,13 @@ namespace SimplePie;
* Used by {@see \SimplePie\Enclosure::get_credit()} and {@see \SimplePie\Enclosure::get_credits()}
*
* This class can be overloaded with {@see \SimplePie\SimplePie::set_credit_class()}
*
* @package SimplePie
* @subpackage API
*/
class Credit
{
/**
* Credited role
*
* @var string
* @var ?string
* @see get_role()
*/
public $role;
@@ -67,7 +27,7 @@ class Credit
/**
* Organizational scheme
*
* @var string
* @var ?string
* @see get_scheme()
*/
public $scheme;
@@ -75,7 +35,7 @@ class Credit
/**
* Credited name
*
* @var string
* @var ?string
* @see get_name()
*/
public $name;
@@ -86,8 +46,11 @@ class Credit
* For documentation on all the parameters, see the corresponding
* properties and their accessors
*/
public function __construct($role = null, $scheme = null, $name = null)
{
public function __construct(
?string $role = null,
?string $scheme = null,
?string $name = null
) {
$this->role = $role;
$this->scheme = $scheme;
$this->name = $name;

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
@@ -50,86 +13,83 @@ namespace SimplePie;
* Used by {@see \SimplePie\Item::get_enclosure()} and {@see \SimplePie\Item::get_enclosures()}
*
* This class can be overloaded with {@see \SimplePie\SimplePie::set_enclosure_class()}
*
* @package SimplePie
* @subpackage API
*/
class Enclosure
{
/**
* @var string
* @var ?string
* @see get_bitrate()
*/
public $bitrate;
/**
* @var array
* @var Caption[]|null
* @see get_captions()
*/
public $captions;
/**
* @var array
* @var Category[]|null
* @see get_categories()
*/
public $categories;
/**
* @var int
* @var ?int
* @see get_channels()
*/
public $channels;
/**
* @var \SimplePie\Copyright
* @var ?Copyright
* @see get_copyright()
*/
public $copyright;
/**
* @var array
* @var Credit[]|null
* @see get_credits()
*/
public $credits;
/**
* @var string
* @var ?string
* @see get_description()
*/
public $description;
/**
* @var int
* @var ?int
* @see get_duration()
*/
public $duration;
/**
* @var string
* @var ?string
* @see get_expression()
*/
public $expression;
/**
* @var string
* @var ?string
* @see get_framerate()
*/
public $framerate;
/**
* @var string
* @var ?string
* @see get_handler()
*/
public $handler;
/**
* @var array
* @var string[]|null
* @see get_hashes()
*/
public $hashes;
/**
* @var string
* @var ?string
* @see get_height()
*/
public $height;
@@ -141,79 +101,79 @@ class Enclosure
public $javascript;
/**
* @var array
* @var string[]|null
* @see get_keywords()
*/
public $keywords;
/**
* @var string
* @var ?string
* @see get_language()
*/
public $lang;
/**
* @var string
* @var ?int
* @see get_length()
*/
public $length;
/**
* @var string
* @var ?string
* @see get_link()
*/
public $link;
/**
* @var string
* @var ?string
* @see get_medium()
*/
public $medium;
/**
* @var string
* @var ?string
* @see get_player()
*/
public $player;
/**
* @var array
* @var Rating[]|null
* @see get_ratings()
*/
public $ratings;
/**
* @var array
* @var ?Restriction[]
* @see get_restrictions()
*/
public $restrictions;
/**
* @var string
* @var ?string
* @see get_sampling_rate()
*/
public $samplingrate;
/**
* @var array
* @var string[]|null
* @see get_thumbnails()
*/
public $thumbnails;
/**
* @var string
* @var ?string
* @see get_title()
*/
public $title;
/**
* @var string
* @var ?string
* @see get_type()
*/
public $type;
/**
* @var string
* @var ?string
* @see get_width()
*/
public $width;
@@ -224,10 +184,46 @@ class Enclosure
* For documentation on all the parameters, see the corresponding
* properties and their accessors
*
* @uses idna_convert If available, this will convert an IDN
* @uses idn_to_ascii If available, this will convert an IDN
*
* @param null $javascript
* @param Caption[]|null $captions
* @param Category[]|null $categories
* @param Credit[]|null $credits
* @param string[]|null $hashes
* @param string[]|null $keywords
* @param Rating[]|null $ratings
* @param Restriction[]|null $restrictions
* @param string[]|null $thumbnails
*/
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)
{
public function __construct(
?string $link = null,
?string $type = null,
?int $length = null,
$javascript = null,
?string $bitrate = null,
?array $captions = null,
?array $categories = null,
?int $channels = null,
?Copyright $copyright = null,
?array $credits = null,
?string $description = null,
?int $duration = null,
?string $expression = null,
?string $framerate = null,
?array $hashes = null,
?string $height = null,
?array $keywords = null,
?string $lang = null,
?string $medium = null,
?string $player = null,
?array $ratings = null,
?array $restrictions = null,
?string $samplingrate = null,
?array $thumbnails = null,
?string $title = null,
?string $width = null
) {
$this->bitrate = $bitrate;
$this->captions = $captions;
$this->categories = $categories;
@@ -254,10 +250,12 @@ class Enclosure
$this->type = $type;
$this->width = $width;
if (class_exists('idna_convert')) {
$idn = new \idna_convert();
$parsed = \SimplePie\Misc::parse_url($link);
$this->link = \SimplePie\Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
if (function_exists('idn_to_ascii')) {
$parsed = \SimplePie\Misc::parse_url($link ?? '');
if ($parsed['authority'] !== '' && !ctype_print($parsed['authority'])) {
$authority = (string) \idn_to_ascii($parsed['authority'], \IDNA_NONTRANSITIONAL_TO_ASCII, \INTL_IDNA_VARIANT_UTS46);
$this->link = \SimplePie\Misc::compress_parse_url($parsed['scheme'], $authority, $parsed['path'], $parsed['query'], $parsed['fragment']);
}
}
$this->handler = $this->get_handler(); // Needs to load last
}
@@ -293,7 +291,7 @@ class Enclosure
* @param int $key
* @return \SimplePie\Caption|null
*/
public function get_caption($key = 0)
public function get_caption(int $key = 0)
{
$captions = $this->get_captions();
if (isset($captions[$key])) {
@@ -306,7 +304,7 @@ class Enclosure
/**
* Get all captions
*
* @return array|null Array of {@see \SimplePie\Caption} objects
* @return Caption[]|null
*/
public function get_captions()
{
@@ -323,7 +321,7 @@ class Enclosure
* @param int $key
* @return \SimplePie\Category|null
*/
public function get_category($key = 0)
public function get_category(int $key = 0)
{
$categories = $this->get_categories();
if (isset($categories[$key])) {
@@ -336,7 +334,7 @@ class Enclosure
/**
* Get all categories
*
* @return array|null Array of {@see \SimplePie\Category} objects
* @return \SimplePie\Category[]|null
*/
public function get_categories()
{
@@ -381,7 +379,7 @@ class Enclosure
* @param int $key
* @return \SimplePie\Credit|null
*/
public function get_credit($key = 0)
public function get_credit(int $key = 0)
{
$credits = $this->get_credits();
if (isset($credits[$key])) {
@@ -394,7 +392,7 @@ class Enclosure
/**
* Get all credits
*
* @return array|null Array of {@see \SimplePie\Credit} objects
* @return Credit[]|null
*/
public function get_credits()
{
@@ -425,7 +423,7 @@ class Enclosure
* @param bool $convert Convert seconds into hh:mm:ss
* @return string|int|null 'hh:mm:ss' string if `$convert` was specified, otherwise integer (or null if none found)
*/
public function get_duration($convert = false)
public function get_duration(bool $convert = false)
{
if ($this->duration !== null) {
if ($convert) {
@@ -500,7 +498,7 @@ class Enclosure
* @param int $key
* @return string|null Hash as per `media:hash`, prefixed with "$algo:"
*/
public function get_hash($key = 0)
public function get_hash(int $key = 0)
{
$hashes = $this->get_hashes();
if (isset($hashes[$key])) {
@@ -513,7 +511,7 @@ class Enclosure
/**
* Get all credits
*
* @return array|null Array of strings, see {@see get_hash()}
* @return string[]|null Array of strings, see {@see get_hash()}
*/
public function get_hashes()
{
@@ -559,7 +557,7 @@ class Enclosure
* @param int $key
* @return string|null
*/
public function get_keyword($key = 0)
public function get_keyword(int $key = 0)
{
$keywords = $this->get_keywords();
if (isset($keywords[$key])) {
@@ -572,7 +570,7 @@ class Enclosure
/**
* Get all keywords
*
* @return array|null Array of strings
* @return string[]|null
*/
public function get_keywords()
{
@@ -586,7 +584,7 @@ class Enclosure
/**
* Get length
*
* @return float Length in bytes
* @return ?int Length in bytes
*/
public function get_length()
{
@@ -647,7 +645,7 @@ class Enclosure
* @param int $key
* @return \SimplePie\Rating|null
*/
public function get_rating($key = 0)
public function get_rating(int $key = 0)
{
$ratings = $this->get_ratings();
if (isset($ratings[$key])) {
@@ -660,7 +658,7 @@ class Enclosure
/**
* Get all ratings
*
* @return array|null Array of {@see \SimplePie\Rating} objects
* @return Rating[]|null
*/
public function get_ratings()
{
@@ -677,7 +675,7 @@ class Enclosure
* @param int $key
* @return \SimplePie\Restriction|null
*/
public function get_restriction($key = 0)
public function get_restriction(int $key = 0)
{
$restrictions = $this->get_restrictions();
if (isset($restrictions[$key])) {
@@ -690,7 +688,7 @@ class Enclosure
/**
* Get all restrictions
*
* @return array|null Array of {@see \SimplePie\Restriction} objects
* @return Restriction[]|null
*/
public function get_restrictions()
{
@@ -736,7 +734,7 @@ class Enclosure
* @param int $key
* @return string|null Thumbnail URL
*/
public function get_thumbnail($key = 0)
public function get_thumbnail(int $key = 0)
{
$thumbnails = $this->get_thumbnails();
if (isset($thumbnails[$key])) {
@@ -749,7 +747,7 @@ class Enclosure
/**
* Get all thumbnails
*
* @return array|null Array of thumbnail URLs
* @return string[]|null Array of thumbnail URLs
*/
public function get_thumbnails()
{
@@ -808,7 +806,7 @@ class Enclosure
*
* @deprecated Use the second parameter to {@see embed} instead
*
* @param array|string $options See first parameter to {@see embed}
* @param array<string, mixed>|string $options See first parameter to {@see embed}
* @return string HTML string to output
*/
public function native_embed($options = '')
@@ -857,11 +855,11 @@ class Enclosure
* `width` and `height` set to `auto` will default to 480x270 video resolution.
*
* @todo If the dimensions for media:content are defined, use them when width/height are set to 'auto'.
* @param array|string $options Comma-separated key:value list, or array
* @param array<string, mixed>|string $options Comma-separated key:value list, or array
* @param bool $native Use `<embed>`
* @return string HTML string to output
*/
public function embed($options = '', $native = false)
public function embed($options = '', bool $native = false)
{
// Set up defaults
$audio = '';
@@ -933,7 +931,7 @@ class Enclosure
}
}
$mime = explode('/', $type, 2);
$mime = explode('/', (string) $type, 2);
$mime = $mime[0];
// Process values for 'auto'
@@ -994,7 +992,10 @@ class Enclosure
// Flash Media Player file types.
// Preferred handler for MP3 file types.
elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== '')) {
$height += 20;
if (is_numeric($height)) {
$height += 20;
}
if ($native) {
$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>";
} else {
@@ -1005,7 +1006,10 @@ class Enclosure
// QuickTime 7 file types. Need to test with QuickTime 6.
// Only handle MP3's if the Flash Media Player is not present.
elseif ($handler === 'quicktime' || ($handler === 'mp3' && $mediaplayer === '')) {
$height += 16;
if (is_numeric($height)) {
$height += 16;
}
if ($native) {
if ($placeholder !== '') {
$embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" href=\"" . $this->get_link() . "\" src=\"$placeholder\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"false\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>";
@@ -1019,7 +1023,10 @@ class Enclosure
// Windows Media
elseif ($handler === 'wmedia') {
$height += 45;
if (is_numeric($height)) {
$height += 45;
}
if ($native) {
$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>";
} else {
@@ -1044,9 +1051,9 @@ class Enclosure
*
* @see get_type()
* @param bool $find_handler Internal use only, use {@see get_handler()} instead
* @return string MIME type
* @return string|null MIME type
*/
public function get_real_type($find_handler = false)
public function get_real_type(bool $find_handler = false)
{
// Mime-types by handler.
$types_flash = ['application/x-shockwave-flash', 'application/futuresplash']; // Flash
@@ -1055,10 +1062,9 @@ class Enclosure
$types_wmedia = ['application/asx', 'application/x-mplayer2', 'audio/x-ms-wma', 'audio/x-ms-wax', 'video/x-ms-asf-plugin', 'video/x-ms-asf', 'video/x-ms-wm', 'video/x-ms-wmv', 'video/x-ms-wvx']; // Windows Media
$types_mp3 = ['audio/mp3', 'audio/x-mp3', 'audio/mpeg', 'audio/x-mpeg']; // MP3
if ($this->get_type() !== null) {
$type = strtolower($this->type);
} else {
$type = null;
$type = $this->get_type();
if ($type !== null) {
$type = strtolower($type);
}
// If we encounter an unsupported mime-type, check the file extension and guess intelligently.
@@ -1114,9 +1120,9 @@ class Enclosure
$type = 'audio/x-ms-wma';
break;
// Video mime-types
case '3gp':
case '3gpp':
// Video mime-types
$type = 'video/3gpp';
break;
@@ -1177,8 +1183,8 @@ class Enclosure
$type = 'video/x-ms-wvx';
break;
// Flash mime-types
case 'spl':
// Flash mime-types
$type = 'application/futuresplash';
break;

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
@@ -48,8 +11,6 @@ use Exception as NativeException;
/**
* General SimplePie exception class
*
* @package SimplePie
*/
class Exception extends NativeException
{

View File

@@ -1,49 +1,14 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
use SimplePie\HTTP\Response;
/**
* Used for fetching remote files and reading local files
*
@@ -51,36 +16,93 @@ namespace SimplePie;
*
* This class can be overloaded with {@see \SimplePie\SimplePie::set_file_class()}
*
* @package SimplePie
* @subpackage HTTP
* @todo Move to properly supporting RFC2616 (HTTP/1.1)
*/
class File
class File implements Response
{
/**
* @var string The final URL after following all redirects
* @deprecated Use `get_final_requested_uri()` method.
*/
public $url;
public $useragent;
public $success = true;
public $headers = [];
public $body;
public $status_code = 0;
public $redirects = 0;
public $error;
public $method = \SimplePie\SimplePie::FILE_SOURCE_NONE;
public $permanent_url;
public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false, $curl_options = [])
/**
* @var ?string User agent to use in requests
* @deprecated Set the user agent in constructor.
*/
public $useragent;
/** @var bool */
public $success = true;
/** @var array<string, non-empty-array<string>> Canonical representation of headers */
private $parsed_headers = [];
/** @var array<string, string> Last known value of $headers property (used to detect external modification) */
private $last_headers = [];
/**
* @var array<string, string> Headers as string for BC
* @deprecated Use `get_headers()` method.
*/
public $headers = [];
/**
* @var ?string Body of the HTTP response
* @deprecated Use `get_body_content()` method.
*/
public $body;
/**
* @var int Status code of the HTTP response
* @deprecated Use `get_status_code()` method.
*/
public $status_code = 0;
/** @var non-negative-int Number of redirect that were already performed during this request sequence. */
public $redirects = 0;
/** @var ?string */
public $error;
/**
* @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.
* @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()`.
*/
public $method = \SimplePie\SimplePie::FILE_SOURCE_NONE;
/**
* @var string The permanent URL or the resource (first URL after the prefix of (only) permanent redirects)
* @deprecated Use `get_permanent_uri()` method.
*/
public $permanent_url;
/** @var bool Whether the permanent URL is still writeable (prefix of permanent redirects has not ended) */
private $permanentUrlMutable = true;
/**
* @param string $url
* @param int $timeout
* @param int $redirects
* @param ?array<string, string> $headers
* @param ?string $useragent
* @param bool $force_fsockopen
* @param array<int, mixed> $curl_options
*/
public function __construct(string $url, int $timeout = 10, int $redirects = 5, ?array $headers = null, ?string $useragent = null, bool $force_fsockopen = false, array $curl_options = [])
{
if (class_exists('idna_convert')) {
$idn = new \idna_convert();
if (function_exists('idn_to_ascii')) {
$parsed = \SimplePie\Misc::parse_url($url);
$url = \SimplePie\Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], null);
if ($parsed['authority'] !== '' && !ctype_print($parsed['authority'])) {
$authority = (string) \idn_to_ascii($parsed['authority'], \IDNA_NONTRANSITIONAL_TO_ASCII, \INTL_IDNA_VARIANT_UTS46);
$url = \SimplePie\Misc::compress_parse_url($parsed['scheme'], $authority, $parsed['path'], $parsed['query'], null);
}
}
$this->url = $url;
$this->permanent_url = $url;
if ($this->permanentUrlMutable) {
$this->permanent_url = $url;
}
$this->useragent = $useragent;
if (preg_match('/^http(s)?:\/\//i', $url)) {
if ($useragent === null) {
$useragent = ini_get('user_agent');
$useragent = (string) ini_get('user_agent');
$this->useragent = $useragent;
}
if (!is_array($headers)) {
@@ -93,6 +115,12 @@ class File
foreach ($headers as $key => $value) {
$headers2[] = "$key: $value";
}
if (isset($curl_options[CURLOPT_HTTPHEADER])) {
if (is_array($curl_options[CURLOPT_HTTPHEADER])) {
$headers2 = array_merge($headers2, $curl_options[CURLOPT_HTTPHEADER]);
}
unset($curl_options[CURLOPT_HTTPHEADER]);
}
if (version_compare(\SimplePie\Misc::get_curl_version(), '7.10.5', '>=')) {
curl_setopt($fp, CURLOPT_ENCODING, '');
}
@@ -109,10 +137,10 @@ class File
curl_setopt($fp, $curl_param, $curl_value);
}
$this->headers = curl_exec($fp);
if (curl_errno($fp) === 23 || curl_errno($fp) === 61) {
$responseHeaders = curl_exec($fp);
if (curl_errno($fp) === CURLE_WRITE_ERROR || curl_errno($fp) === CURLE_BAD_CONTENT_ENCODING) {
curl_setopt($fp, CURLOPT_ENCODING, 'none');
$this->headers = curl_exec($fp);
$responseHeaders = curl_exec($fp);
}
$this->status_code = curl_getinfo($fp, CURLINFO_HTTP_CODE);
if (curl_errno($fp)) {
@@ -123,29 +151,42 @@ class File
if ($info = curl_getinfo($fp)) {
$this->url = $info['url'];
}
curl_close($fp);
$this->headers = \SimplePie\HTTP\Parser::prepareHeaders($this->headers, $info['redirect_count'] + 1);
$parser = new \SimplePie\HTTP\Parser($this->headers);
// For PHPStan: We already checked that error did not occur.
assert(is_array($info) && $info['redirect_count'] >= 0);
if (\PHP_VERSION_ID < 80000) {
curl_close($fp);
}
$responseHeaders = \SimplePie\HTTP\Parser::prepareHeaders((string) $responseHeaders, $info['redirect_count'] + 1);
$parser = new \SimplePie\HTTP\Parser($responseHeaders, true);
if ($parser->parse()) {
$this->headers = $parser->headers;
$this->body = trim($parser->body);
$this->set_headers($parser->headers);
$this->body = $parser->body;
$this->status_code = $parser->status_code;
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) {
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) {
$this->redirects++;
$location = \SimplePie\Misc::absolutize_url($this->headers['location'], $url);
$previousStatusCode = $this->status_code;
$location = \SimplePie\Misc::absolutize_url($locationHeader, $url);
if ($location === false) {
$this->error = "Invalid redirect location, trying to base “{$locationHeader}” onto “{$url}";
$this->success = false;
return;
}
$this->permanentUrlMutable = $this->permanentUrlMutable && ($this->status_code == 301 || $this->status_code == 308);
$this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen, $curl_options);
$this->permanent_url = ($previousStatusCode == 301) ? $location : $url;
return;
}
}
}
} else {
$this->method = \SimplePie\SimplePie::FILE_SOURCE_REMOTE | \SimplePie\SimplePie::FILE_SOURCE_FSOCKOPEN;
$url_parts = parse_url($url);
if (($url_parts = parse_url($url)) === false) {
throw new \InvalidArgumentException('Malformed URL: ' . $url);
}
if (!isset($url_parts['host'])) {
throw new \InvalidArgumentException('Missing hostname: ' . $url);
}
$socket_host = $url_parts['host'];
if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') {
$socket_host = "ssl://$url_parts[host]";
$socket_host = 'ssl://' . $socket_host;
$url_parts['port'] = 443;
}
if (!isset($url_parts['port'])) {
@@ -184,36 +225,39 @@ class File
$info = stream_get_meta_data($fp);
$this->headers = '';
$responseHeaders = '';
while (!$info['eof'] && !$info['timed_out']) {
$this->headers .= fread($fp, 1160);
$responseHeaders .= fread($fp, 1160);
$info = stream_get_meta_data($fp);
}
if (!$info['timed_out']) {
$parser = new \SimplePie\HTTP\Parser($this->headers);
$parser = new \SimplePie\HTTP\Parser($responseHeaders, true);
if ($parser->parse()) {
$this->headers = $parser->headers;
$this->set_headers($parser->headers);
$this->body = $parser->body;
$this->status_code = $parser->status_code;
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) {
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) {
$this->redirects++;
$location = \SimplePie\Misc::absolutize_url($this->headers['location'], $url);
$previousStatusCode = $this->status_code;
$location = \SimplePie\Misc::absolutize_url($locationHeader, $url);
$this->permanentUrlMutable = $this->permanentUrlMutable && ($this->status_code == 301 || $this->status_code == 308);
if ($location === false) {
$this->error = "Invalid redirect location, trying to base “{$locationHeader}” onto “{$url}";
$this->success = false;
return;
}
$this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen, $curl_options);
$this->permanent_url = ($previousStatusCode == 301) ? $location : $url;
return;
}
if (isset($this->headers['content-encoding'])) {
if (($contentEncodingHeader = $this->get_header_line('content-encoding')) !== '') {
// Hey, we act dumb elsewhere, so let's do that here too
switch (strtolower(trim($this->headers['content-encoding'], "\x09\x0A\x0D\x20"))) {
switch (strtolower(trim($contentEncodingHeader, "\x09\x0A\x0D\x20"))) {
case 'gzip':
case 'x-gzip':
$decoder = new \SimplePie\Gzdecode($this->body);
if (!$decoder->parse()) {
if (($decompressed = gzdecode($this->body)) === false) {
$this->error = 'Unable to decode HTTP "gzip" stream';
$this->success = false;
} else {
$this->body = trim($decoder->data);
$this->body = $decompressed;
}
break;
@@ -222,7 +266,7 @@ class File
$this->body = $decompressed;
} elseif (($decompressed = gzuncompress($this->body)) !== false) {
$this->body = $decompressed;
} elseif (function_exists('gzdecode') && ($decompressed = gzdecode($this->body)) !== false) {
} elseif (($decompressed = gzdecode($this->body)) !== false) {
$this->body = $decompressed;
} else {
$this->error = 'Unable to decode HTTP "deflate" stream';
@@ -245,11 +289,155 @@ class File
}
} else {
$this->method = \SimplePie\SimplePie::FILE_SOURCE_LOCAL | \SimplePie\SimplePie::FILE_SOURCE_FILE_GET_CONTENTS;
if (empty($url) || !($this->body = trim(file_get_contents($url)))) {
$this->error = 'file_get_contents could not read the file';
if (empty($url) || !is_readable($url) || false === $filebody = file_get_contents($url)) {
$this->body = '';
$this->error = sprintf('file "%s" is not readable', $url);
$this->success = false;
} else {
$this->body = $filebody;
$this->status_code = 200;
}
}
if ($this->success) {
assert($this->body !== null); // For PHPStan
// Leading whitespace may cause XML parsing errors (XML declaration cannot be preceded by anything other than BOM) so we trim it.
// Note that unlike built-in `trim` functions default settings, we do not trim `\x00` to avoid breaking characters in UTF-16 or UTF-32 encoded strings.
// 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.
$this->body = preg_replace('/^[ \n\r\t\v]+</', '<', $this->body);
}
}
public function get_permanent_uri(): string
{
return (string) $this->permanent_url;
}
public function get_final_requested_uri(): string
{
return (string) $this->url;
}
public function get_status_code(): int
{
return (int) $this->status_code;
}
public function get_headers(): array
{
$this->maybe_update_headers();
return $this->parsed_headers;
}
public function has_header(string $name): bool
{
$this->maybe_update_headers();
return $this->get_header($name) !== [];
}
public function get_header(string $name): array
{
$this->maybe_update_headers();
return $this->parsed_headers[strtolower($name)] ?? [];
}
public function with_header(string $name, $value)
{
$this->maybe_update_headers();
$new = clone $this;
$newHeader = [
strtolower($name) => (array) $value,
];
$new->set_headers($newHeader + $this->get_headers());
return $new;
}
public function get_header_line(string $name): string
{
$this->maybe_update_headers();
return implode(', ', $this->get_header($name));
}
public function get_body_content(): string
{
return (string) $this->body;
}
/**
* Check if the $headers property was changed and update the internal state accordingly.
*/
private function maybe_update_headers(): void
{
if ($this->headers !== $this->last_headers) {
$this->parsed_headers = array_map(
function (string $header_line): array {
if (strpos($header_line, ',') === false) {
return [$header_line];
} else {
return array_map('trim', explode(',', $header_line));
}
},
$this->headers
);
}
$this->last_headers = $this->headers;
}
/**
* Sets headers internally.
*
* @param array<string, non-empty-array<string>> $headers
*/
private function set_headers(array $headers): void
{
$this->parsed_headers = $headers;
$this->headers = self::flatten_headers($headers);
$this->last_headers = $this->headers;
}
/**
* Converts PSR-7 compatible headers into a legacy format.
*
* @param array<string, non-empty-array<string>> $headers
*
* @return array<string, string>
*/
private function flatten_headers(array $headers): array
{
return array_map(function (array $values): string {
return implode(',', $values);
}, $headers);
}
/**
* Create a File instance from another Response
*
* For BC reasons in some places there MUST be a `File` instance
* instead of a `Response` implementation
*
* @see Locator::__construct()
* @internal
*/
final public static function fromResponse(Response $response): self
{
$headers = [];
foreach ($response->get_headers() as $name => $header) {
$headers[$name] = implode(', ', $header);
}
/** @var File */
$file = (new \ReflectionClass(File::class))->newInstanceWithoutConstructor();
$file->url = $response->get_final_requested_uri();
$file->useragent = null;
$file->headers = $headers;
$file->body = $response->get_body_content();
$file->status_code = $response->get_status_code();
$file->permanent_url = $response->get_permanent_uri();
return $file;
}
}

View File

@@ -1,55 +1,18 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
/**
* Decode 'gzip' encoded HTTP data
*
* @package SimplePie
* @subpackage HTTP
* @link http://www.gzip.org/format.txt
* @link https://www.php.net/manual/en/function.gzdecode.php
* @deprecated since SimplePie 1.9.0, use `gzdecode` function instead.
*/
class Gzdecode
{
@@ -179,7 +142,7 @@ class Gzdecode
* @param string $name
* @param mixed $value
*/
public function __set($name, $value)
public function __set(string $name, $value)
{
throw new Exception("Cannot write property $name");
}
@@ -189,7 +152,7 @@ class Gzdecode
*
* @param string $data
*/
public function __construct($data)
public function __construct(string $data)
{
$this->compressed_data = $data;
$this->compressed_size = strlen($data);
@@ -224,10 +187,10 @@ class Gzdecode
// MTIME
$mtime = substr($this->compressed_data, $this->position, 4);
// Reverse the string if we're on a big-endian arch because l is the only signed long and is machine endianness
if (current(unpack('S', "\x00\x01")) === 1) {
if (current((array) unpack('S', "\x00\x01")) === 1) {
$mtime = strrev($mtime);
}
$this->MTIME = current(unpack('l', $mtime));
$this->MTIME = current((array) unpack('l', $mtime));
$this->position += 4;
// Get the XFL (eXtra FLags)
@@ -248,7 +211,7 @@ class Gzdecode
}
// Get the length of the extra field
$len = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
$len = current((array) unpack('v', substr($this->compressed_data, $this->position, 2)));
$this->position += 2;
// Check the length of the string is still valid
@@ -300,7 +263,7 @@ class Gzdecode
$this->min_compressed_size += $len + 2;
if ($this->compressed_size >= $this->min_compressed_size) {
// Read the CRC
$crc = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
$crc = current((array) unpack('v', substr($this->compressed_data, $this->position, 2)));
// Check the CRC matches
if ((crc32(substr($this->compressed_data, 0, $this->position)) & 0xFFFF) === $crc) {
@@ -314,14 +277,15 @@ class Gzdecode
}
// Decompress the actual data
if (($this->data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false) {
if (($data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false) {
return false;
}
$this->data = $data;
$this->position = $this->compressed_size - 8;
// Check CRC of data
$crc = current(unpack('V', substr($this->compressed_data, $this->position, 4)));
$crc = current((array) unpack('V', substr($this->compressed_data, $this->position, 4)));
$this->position += 4;
/*if (extension_loaded('hash') && sprintf('%u', current(unpack('V', hash('crc32b', $this->data)))) !== sprintf('%u', $crc))
{
@@ -329,7 +293,7 @@ class Gzdecode
}*/
// Check ISIZE of data
$isize = current(unpack('V', substr($this->compressed_data, $this->position, 4)));
$isize = current((array) unpack('V', substr($this->compressed_data, $this->position, 4)));
$this->position += 4;
if (sprintf('%u', strlen($this->data) & 0xFFFFFFFF) !== sprintf('%u', $isize)) {
return false;

View File

@@ -0,0 +1,28 @@
<?php
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\HTTP;
/**
* HTTP Client interface
*
* @internal
*/
interface Client
{
public const METHOD_GET = 'GET';
/**
* send a request and return the response
*
* @param Client::METHOD_* $method
* @param array<string, string> $headers
*
* @throws ClientException if anything goes wrong requesting the data
*/
public function request(string $method, string $url, array $headers = []): Response;
}

View File

@@ -0,0 +1,19 @@
<?php
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\HTTP;
use SimplePie\Exception as SimplePieException;
/**
* Client exception class
*
* @internal
*/
final class ClientException extends SimplePieException
{
}

View File

@@ -0,0 +1,77 @@
<?php
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\HTTP;
use InvalidArgumentException;
use SimplePie\File;
use SimplePie\Misc;
use SimplePie\Registry;
use Throwable;
/**
* HTTP Client based on \SimplePie\File
*
* @internal
*/
final class FileClient implements Client
{
/** @var Registry */
private $registry;
/** @var array{timeout?: int, redirects?: int, useragent?: string, force_fsockopen?: bool, curl_options?: array<mixed>} */
private $options;
/**
* @param array{timeout?: int, redirects?: int, useragent?: string, force_fsockopen?: bool, curl_options?: array<mixed>} $options
*/
public function __construct(Registry $registry, array $options = [])
{
$this->registry = $registry;
$this->options = $options;
}
/**
* send a request and return the response
*
* @param Client::METHOD_* $method
* @param array<string, string> $headers
*
* @throws ClientException if anything goes wrong requesting the data
*/
public function request(string $method, string $url, array $headers = []): Response
{
// @phpstan-ignore-next-line Enforce PHPDoc type.
if ($method !== self::METHOD_GET) {
throw new InvalidArgumentException(sprintf(
'%s(): Argument #1 ($method) only supports method "%s".',
__METHOD__,
self::METHOD_GET
), 1);
}
try {
$file = $this->registry->create(File::class, [
$url,
$this->options['timeout'] ?? 10,
$this->options['redirects'] ?? 5,
$headers,
$this->options['useragent'] ?? Misc::get_default_useragent(),
$this->options['force_fsockopen'] ?? false,
$this->options['curl_options'] ?? []
]);
} catch (Throwable $th) {
throw new ClientException($th->getMessage(), $th->getCode(), $th);
}
if ($file->error !== null && $file->get_status_code() === 0) {
throw new ClientException($file->error);
}
return $file;
}
}

View File

@@ -1,54 +1,15 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\HTTP;
/**
* HTTP Response Parser
*
* @package SimplePie
* @subpackage HTTP
* @template Psr7Compatible of bool
*/
class Parser
{
@@ -73,10 +34,15 @@ class Parser
*/
public $reason = '';
/**
* @var Psr7Compatible whether headers are compatible with PSR-7 format.
*/
private $psr7Compatible;
/**
* Key/value pairs of the headers
*
* @var array
* @var (Psr7Compatible is true ? array<string, non-empty-array<string>> : array<string, string>)
*/
public $headers = [];
@@ -144,14 +110,14 @@ class Parser
protected $position = 0;
/**
* Name of the hedaer currently being parsed
* Name of the header currently being parsed
*
* @var string
*/
protected $name = '';
/**
* Value of the hedaer currently being parsed
* Value of the header currently being parsed
*
* @var string
*/
@@ -161,11 +127,13 @@ class Parser
* Create an instance of the class with the input data
*
* @param string $data Input data
* @param Psr7Compatible $psr7Compatible Whether the data types are in format compatible with PSR-7.
*/
public function __construct($data)
public function __construct(string $data, bool $psr7Compatible = false)
{
$this->data = $data;
$this->data_length = strlen($this->data);
$this->psr7Compatible = $psr7Compatible;
}
/**
@@ -184,7 +152,8 @@ class Parser
return true;
}
$this->http_version = '';
// Reset the parser state.
$this->http_version = 0.0;
$this->status_code = 0;
$this->reason = '';
$this->headers = [];
@@ -218,15 +187,16 @@ class Parser
/**
* Parse the HTTP version
* @return void
*/
protected function http_version()
{
if (strpos($this->data, "\x0A") !== false && strtoupper(substr($this->data, 0, 5)) === 'HTTP/') {
$len = strspn($this->data, '0123456789.', 5);
$this->http_version = substr($this->data, 5, $len);
$http_version = substr($this->data, 5, $len);
$this->position += 5 + $len;
if (substr_count($this->http_version, '.') <= 1) {
$this->http_version = (float) $this->http_version;
if (substr_count($http_version, '.') <= 1) {
$this->http_version = (float) $http_version;
$this->position += strspn($this->data, "\x09\x20", $this->position);
$this->state = self::STATE_STATUS;
} else {
@@ -239,6 +209,7 @@ class Parser
/**
* Parse the status code
* @return void
*/
protected function status()
{
@@ -253,6 +224,7 @@ class Parser
/**
* Parse the reason phrase
* @return void
*/
protected function reason()
{
@@ -262,8 +234,39 @@ class Parser
$this->state = self::STATE_NEW_LINE;
}
private function add_header(string $name, string $value): void
{
if ($this->psr7Compatible) {
// For PHPStan: should be enforced by template parameter but PHPStan is not smart enough.
/** @var array<string, non-empty-array<string>> */
$headers = &$this->headers;
$headers[$name][] = $value;
} else {
// For PHPStan: should be enforced by template parameter but PHPStan is not smart enough.
/** @var array<string, string>) */
$headers = &$this->headers;
$headers[$name] .= ', ' . $value;
}
}
private function replace_header(string $name, string $value): void
{
if ($this->psr7Compatible) {
// For PHPStan: should be enforced by template parameter but PHPStan is not smart enough.
/** @var array<string, non-empty-array<string>> */
$headers = &$this->headers;
$headers[$name] = [$value];
} else {
// For PHPStan: should be enforced by template parameter but PHPStan is not smart enough.
/** @var array<string, string>) */
$headers = &$this->headers;
$headers[$name] = $value;
}
}
/**
* Deal with a new line, shifting data around as needed
* @return void
*/
protected function new_line()
{
@@ -272,9 +275,9 @@ class Parser
$this->name = strtolower($this->name);
// We should only use the last Content-Type header. c.f. issue #1
if (isset($this->headers[$this->name]) && $this->name !== 'content-type') {
$this->headers[$this->name] .= ', ' . $this->value;
$this->add_header($this->name, $this->value);
} else {
$this->headers[$this->name] = $this->value;
$this->replace_header($this->name, $this->value);
}
}
$this->name = '';
@@ -292,6 +295,7 @@ class Parser
/**
* Parse a header name
* @return void
*/
protected function name()
{
@@ -312,6 +316,7 @@ class Parser
/**
* Parse LWS, replacing consecutive LWS characters with a single space
* @return void
*/
protected function linear_whitespace()
{
@@ -328,6 +333,7 @@ class Parser
/**
* See what state to move to while within non-quoted header values
* @return void
*/
protected function value()
{
@@ -362,6 +368,7 @@ class Parser
/**
* Parse a header value while outside quotes
* @return void
*/
protected function value_char()
{
@@ -373,6 +380,7 @@ class Parser
/**
* See what state to move to while within quoted header values
* @return void
*/
protected function quote()
{
@@ -404,6 +412,7 @@ class Parser
/**
* Parse a header value while within quotes
* @return void
*/
protected function quote_char()
{
@@ -415,6 +424,7 @@ class Parser
/**
* Parse an escaped character within quotes
* @return void
*/
protected function quote_escaped()
{
@@ -425,6 +435,7 @@ class Parser
/**
* Parse the body
* @return void
*/
protected function body()
{
@@ -439,6 +450,7 @@ class Parser
/**
* Parsed a "Transfer-Encoding: chunked" body
* @return void
*/
protected function chunked()
{
@@ -459,6 +471,9 @@ class Parser
}
$length = hexdec(trim($matches[1]));
// For PHPStan: this will only be float when larger than PHP_INT_MAX.
// But even on 32-bit systems, it would mean 2GiB chunk, which sounds unlikely.
\assert(\is_int($length), "Length needs to be shorter than PHP_INT_MAX");
if ($length === 0) {
// Ignore trailer headers
$this->state = self::STATE_EMIT;
@@ -485,11 +500,11 @@ class Parser
* Prepare headers (take care of proxies headers)
*
* @param string $headers Raw headers
* @param integer $count Redirection count. Default to 1.
* @param non-negative-int $count Redirection count. Default to 1.
*
* @return string
*/
public static function prepareHeaders($headers, $count = 1)
public static function prepareHeaders(string $headers, int $count = 1)
{
$data = explode("\r\n\r\n", $headers, $count);
$data = array_pop($data);

View File

@@ -0,0 +1,162 @@
<?php
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\HTTP;
use InvalidArgumentException;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;
use Throwable;
/**
* HTTP Client based on PSR-18 and PSR-17 implementations
*
* @internal
*/
final class Psr18Client implements Client
{
/**
* @var ClientInterface
*/
private $httpClient;
/**
* @var RequestFactoryInterface
*/
private $requestFactory;
/**
* @var UriFactoryInterface
*/
private $uriFactory;
/**
* @var int
*/
private $allowedRedirects = 5;
public function __construct(ClientInterface $httpClient, RequestFactoryInterface $requestFactory, UriFactoryInterface $uriFactory)
{
$this->httpClient = $httpClient;
$this->requestFactory = $requestFactory;
$this->uriFactory = $uriFactory;
}
public function getHttpClient(): ClientInterface
{
return $this->httpClient;
}
public function getRequestFactory(): RequestFactoryInterface
{
return $this->requestFactory;
}
public function getUriFactory(): UriFactoryInterface
{
return $this->uriFactory;
}
/**
* send a request and return the response
*
* @param Client::METHOD_* $method
* @param string $url
* @param array<string,string|string[]> $headers
*
* @throws ClientException if anything goes wrong requesting the data
*/
public function request(string $method, string $url, array $headers = []): Response
{
if ($method !== self::METHOD_GET) {
throw new InvalidArgumentException(sprintf(
'%s(): Argument #1 ($method) only supports method "%s".',
__METHOD__,
self::METHOD_GET
), 1);
}
if (preg_match('/^http(s)?:\/\//i', $url)) {
return $this->requestUrl($method, $url, $headers);
}
return $this->requestLocalFile($url);
}
/**
* @param array<string,string|string[]> $headers
*/
private function requestUrl(string $method, string $url, array $headers): Response
{
$permanentUrl = $url;
$requestedUrl = $url;
$remainingRedirects = $this->allowedRedirects;
$request = $this->requestFactory->createRequest(
$method,
$this->uriFactory->createUri($requestedUrl)
);
foreach ($headers as $name => $value) {
$request = $request->withHeader($name, $value);
}
do {
$followRedirect = false;
try {
$response = $this->httpClient->sendRequest($request);
} catch (ClientExceptionInterface $th) {
throw new ClientException($th->getMessage(), $th->getCode(), $th);
}
$statusCode = $response->getStatusCode();
// If we have a redirect
if (in_array($statusCode, [300, 301, 302, 303, 307]) && $response->hasHeader('Location')) {
// Prevent infinity redirect loops
if ($remainingRedirects <= 0) {
break;
}
$remainingRedirects--;
$followRedirect = true;
$requestedUrl = $response->getHeaderLine('Location');
if ($statusCode === 301) {
$permanentUrl = $requestedUrl;
}
$request = $request->withUri($this->uriFactory->createUri($requestedUrl));
}
} while ($followRedirect);
return new Psr7Response($response, $permanentUrl, $requestedUrl);
}
private function requestLocalFile(string $path): Response
{
if (!is_readable($path)) {
throw new ClientException(sprintf('file "%s" is not readable', $path));
}
try {
$raw = file_get_contents($path);
} catch (Throwable $th) {
throw new ClientException($th->getMessage(), $th->getCode(), $th);
}
if ($raw === false) {
throw new ClientException('file_get_contents() could not read the file', 1);
}
return new RawTextResponse($raw, $path);
}
}

View File

@@ -0,0 +1,91 @@
<?php
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\HTTP;
use Psr\Http\Message\ResponseInterface;
/**
* HTTP Response based on a PSR-7 response
*
* This interface must be interoperable with Psr\Http\Message\ResponseInterface
* @see https://www.php-fig.org/psr/psr-7/#33-psrhttpmessageresponseinterface
*
* @internal
*/
final class Psr7Response implements Response
{
/**
* @var ResponseInterface
*/
private $response;
/**
* @var string
*/
private $permanent_url;
/**
* @var string
*/
private $requested_url;
public function __construct(ResponseInterface $response, string $permanent_url, string $requested_url)
{
$this->response = $response;
$this->permanent_url = $permanent_url;
$this->requested_url = $requested_url;
}
public function get_permanent_uri(): string
{
return $this->permanent_url;
}
public function get_final_requested_uri(): string
{
return $this->requested_url;
}
public function get_status_code(): int
{
return $this->response->getStatusCode();
}
public function get_headers(): array
{
// The filtering is probably redundant but lets make PHPStan happy.
return array_filter($this->response->getHeaders(), function (array $header): bool {
return count($header) >= 1;
});
}
public function has_header(string $name): bool
{
return $this->response->hasHeader($name);
}
public function with_header(string $name, $value)
{
return new self($this->response->withHeader($name, $value), $this->permanent_url, $this->requested_url);
}
public function get_header(string $name): array
{
return $this->response->getHeader($name);
}
public function get_header_line(string $name): string
{
return $this->response->getHeaderLine($name);
}
public function get_body_content(): string
{
return $this->response->getBody()->__toString();
}
}

View File

@@ -0,0 +1,98 @@
<?php
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\HTTP;
/**
* HTTP Response for rax text
*
* This interface must be interoperable with Psr\Http\Message\ResponseInterface
* @see https://www.php-fig.org/psr/psr-7/#33-psrhttpmessageresponseinterface
*
* @internal
*/
final class RawTextResponse implements Response
{
/**
* @var string
*/
private $raw_text;
/**
* @var string
*/
private $permanent_url;
/**
* @var array<non-empty-array<string>>
*/
private $headers = [];
/**
* @var string
*/
private $requested_url;
public function __construct(string $raw_text, string $filepath)
{
$this->raw_text = $raw_text;
$this->permanent_url = $filepath;
$this->requested_url = $filepath;
}
public function get_permanent_uri(): string
{
return $this->permanent_url;
}
public function get_final_requested_uri(): string
{
return $this->requested_url;
}
public function get_status_code(): int
{
return 200;
}
public function get_headers(): array
{
return $this->headers;
}
public function has_header(string $name): bool
{
return isset($this->headers[strtolower($name)]);
}
public function get_header(string $name): array
{
return isset($this->headers[strtolower($name)]) ? $this->headers[$name] : [];
}
public function with_header(string $name, $value)
{
$new = clone $this;
$newHeader = [
strtolower($name) => (array) $value,
];
$new->headers = $newHeader + $this->headers;
return $new;
}
public function get_header_line(string $name): string
{
return isset($this->headers[strtolower($name)]) ? implode(", ", $this->headers[$name]) : '';
}
public function get_body_content(): string
{
return $this->raw_text;
}
}

View File

@@ -0,0 +1,171 @@
<?php
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-FileCopyrightText: 2014 PHP Framework Interoperability Group
// SPDX-License-Identifier: MIT
declare(strict_types=1);
namespace SimplePie\HTTP;
/**
* HTTP Response interface
*
* This interface must be interoperable with Psr\Http\Message\ResponseInterface
* @see https://www.php-fig.org/psr/psr-7/#33-psrhttpmessageresponseinterface
*
* @internal
*/
interface Response
{
/**
* Return the string representation of the permanent URI of the requested resource
* (the first location after a prefix of (only) permanent redirects).
*
* Depending on which components of the URI are present, the resulting
* string is either a full URI or relative reference according to RFC 3986,
* Section 4.1. The method concatenates the various components of the URI,
* using the appropriate delimiters:
*
* - If a scheme is present, it MUST be suffixed by ":".
* - If an authority is present, it MUST be prefixed by "//".
* - The path can be concatenated without delimiters. But there are two
* cases where the path has to be adjusted to make the URI reference
* valid as PHP does not allow to throw an exception in __toString():
* - If the path is rootless and an authority is present, the path MUST
* be prefixed by "/".
* - If the path is starting with more than one "/" and no authority is
* present, the starting slashes MUST be reduced to one.
* - If a query is present, it MUST be prefixed by "?".
* - If a fragment is present, it MUST be prefixed by "#".
*
* @see http://tools.ietf.org/html/rfc3986#section-4.1
*/
public function get_permanent_uri(): string;
/**
* Return the string representation of the final requested URL after following all redirects.
*
* Depending on which components of the URI are present, the resulting
* string is either a full URI or relative reference according to RFC 3986,
* Section 4.1. The method concatenates the various components of the URI,
* using the appropriate delimiters:
*
* - If a scheme is present, it MUST be suffixed by ":".
* - If an authority is present, it MUST be prefixed by "//".
* - The path can be concatenated without delimiters. But there are two
* cases where the path has to be adjusted to make the URI reference
* valid as PHP does not allow to throw an exception in __toString():
* - If the path is rootless and an authority is present, the path MUST
* be prefixed by "/".
* - If the path is starting with more than one "/" and no authority is
* present, the starting slashes MUST be reduced to one.
* - If a query is present, it MUST be prefixed by "?".
* - If a fragment is present, it MUST be prefixed by "#".
*
* @see http://tools.ietf.org/html/rfc3986#section-4.1
*/
public function get_final_requested_uri(): string;
/**
* Gets the response status code.
*
* The status code is a 3-digit integer result code of the server's attempt
* to understand and satisfy the request.
*
* @return int Status code.
*/
public function get_status_code(): int;
/**
* Retrieves all message header values.
*
* The keys represent the header name as it will be sent over the wire, and
* each value is an array of strings associated with the header.
*
* // Represent the headers as a string
* foreach ($message->get_headers() as $name => $values) {
* echo $name . ': ' . implode(', ', $values);
* }
*
* // Emit headers iteratively:
* foreach ($message->get_headers() as $name => $values) {
* foreach ($values as $value) {
* header(sprintf('%s: %s', $name, $value), false);
* }
* }
*
* @return array<non-empty-array<string>> Returns an associative array of the message's headers.
* Each key MUST be a header name, and each value MUST be an array of
* strings for that header.
*/
public function get_headers(): array;
/**
* Checks if a header exists by the given case-insensitive name.
*
* @param string $name Case-insensitive header field name.
* @return bool Returns true if any header names match the given header
* name using a case-insensitive string comparison. Returns false if
* no matching header name is found in the message.
*/
public function has_header(string $name): bool;
/**
* Retrieves a message header value by the given case-insensitive name.
*
* This method returns an array of all the header values of the given
* case-insensitive header name.
*
* If the header does not appear in the message, this method MUST return an
* empty array.
*
* @param string $name Case-insensitive header field name.
* @return string[] An array of string values as provided for the given
* header. If the header does not appear in the message, this method MUST
* return an empty array.
*/
public function get_header(string $name): array;
/**
* Return an instance with the provided value replacing the specified header.
*
* This method MUST be implemented in such a way as to retain the
* immutability of the message, and MUST return an instance that has the
* new and/or updated header and value.
*
* @param string $name Case-insensitive header field name.
* @param string|non-empty-array<string> $value Header value(s).
* @return static
* @throws \InvalidArgumentException for invalid header names or values.
*/
public function with_header(string $name, $value);
/**
* Retrieves a comma-separated string of the values for a single header.
*
* This method returns all of the header values of the given
* case-insensitive header name as a string concatenated together using
* a comma.
*
* NOTE: Not all header values may be appropriately represented using
* comma concatenation. For such headers, use getHeader() instead
* and supply your own delimiter when concatenating.
*
* If the header does not appear in the message, this method MUST return
* an empty string.
*
* @param string $name Case-insensitive header field name.
* @return string A string of values as provided for the given header
* concatenated together using a comma. If the header does not appear in
* the message, this method MUST return an empty string.
*/
public function get_header_line(string $name): string;
/**
* get the body as string
*
* @return string
*/
public function get_body_content(): string;
}

View File

@@ -1,87 +1,53 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-FileCopyrightText: 2008 Steve Minutillo
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
/**
* IRI parser/serialiser/normaliser
*
* @package SimplePie
* @subpackage HTTP
* @author Sam Sneddon
* @author Steve Minutillo
* @author Ryan McCue
* @copyright 2007-2012 Sam Sneddon, Steve Minutillo, Ryan McCue
* @license http://www.opensource.org/licenses/bsd-license.php
* @property ?string $scheme
* @property ?string $userinfo
* @property ?string $host
* @property ?int $port
* @property-write int|string|null $port
* @property ?string $authority
* @property string $path
* @property ?string $query
* @property ?string $fragment
*/
class IRI
{
/**
* Scheme
*
* @var string
* @var ?string
*/
protected $scheme = null;
/**
* User Information
*
* @var string
* @var ?string
*/
protected $iuserinfo = null;
/**
* ihost
*
* @var string
* @var ?string
*/
protected $ihost = null;
/**
* Port
*
* @var string
* @var ?int
*/
protected $port = null;
@@ -95,14 +61,14 @@ class IRI
/**
* iquery
*
* @var string
* @var ?string
*/
protected $iquery = null;
/**
* ifragment
*
* @var string
* @var ?string
*/
protected $ifragment = null;
@@ -111,6 +77,8 @@ class IRI
*
* Each key is the scheme, each value is an array with each key as the IRI
* part and value as the default value for that part.
*
* @var array<string, array<string, mixed>>
*/
protected $normalization = [
'acap' => [
@@ -139,7 +107,7 @@ class IRI
*/
public function __toString()
{
return $this->get_iri();
return (string) $this->get_iri();
}
/**
@@ -147,11 +115,13 @@ class IRI
*
* @param string $name Property name
* @param mixed $value Property value
* @return void
*/
public function __set($name, $value)
public function __set(string $name, $value)
{
if (method_exists($this, 'set_' . $name)) {
call_user_func([$this, 'set_' . $name], $value);
$callable = [$this, 'set_' . $name];
if (is_callable($callable)) {
call_user_func($callable, $value);
} elseif (
$name === 'iauthority'
|| $name === 'iuserinfo'
@@ -170,7 +140,7 @@ class IRI
* @param string $name Property name
* @return mixed
*/
public function __get($name)
public function __get(string $name)
{
// isset() returns false for null, we don't want to do that
// Also why we use array_key_exists below instead of isset()
@@ -187,7 +157,7 @@ class IRI
$return = $this->$name;
}
// host -> ihost
elseif (($prop = 'i' . $name) && array_key_exists($prop, $props)) {
elseif (array_key_exists($prop = 'i' . $name, $props)) {
$name = $prop;
$return = $this->$prop;
}
@@ -213,7 +183,7 @@ class IRI
* @param string $name Property name
* @return bool
*/
public function __isset($name)
public function __isset(string $name)
{
return method_exists($this, 'get_' . $name) || isset($this->$name);
}
@@ -222,26 +192,29 @@ class IRI
* Overload __unset() to provide access via properties
*
* @param string $name Property name
* @return void
*/
public function __unset($name)
public function __unset(string $name)
{
if (method_exists($this, 'set_' . $name)) {
call_user_func([$this, 'set_' . $name], '');
$callable = [$this, 'set_' . $name];
if (is_callable($callable)) {
call_user_func($callable, '');
}
}
/**
* Create a new IRI object, from a specified string
*
* @param string $iri
* @param string|null $iri
*/
public function __construct($iri = null)
public function __construct(?string $iri = null)
{
$this->set_iri($iri);
}
/**
* Clean up
* @return void
*/
public function __destruct()
{
@@ -321,27 +294,21 @@ class IRI
* Parse an IRI into scheme/authority/path/query/fragment segments
*
* @param string $iri
* @return array
* @return array{
* scheme: string|null,
* authority: string|null,
* path: string,
* query: string|null,
* fragment: string|null,
* }|false
*/
protected function parse_iri($iri)
protected function parse_iri(string $iri)
{
$iri = trim($iri, "\x20\x09\x0A\x0C\x0D");
if (preg_match('/^((?P<scheme>[^:\/?#]+):)?(\/\/(?P<authority>[^\/?#]*))?(?P<path>[^?#]*)(\?(?P<query>[^#]*))?(#(?P<fragment>.*))?$/', $iri, $match)) {
if ($match[1] === '') {
$match['scheme'] = null;
}
if (!isset($match[3]) || $match[3] === '') {
$match['authority'] = null;
}
if (!isset($match[5])) {
$match['path'] = '';
}
if (!isset($match[6]) || $match[6] === '') {
$match['query'] = null;
}
if (!isset($match[8]) || $match[8] === '') {
$match['fragment'] = null;
}
if (preg_match('/^(?:(?P<scheme>[^:\/?#]+):)?(:?\/\/(?P<authority>[^\/?#]*))?(?P<path>[^?#]*)(?:\?(?P<query>[^#]*))?(?:#(?P<fragment>.*))?$/', $iri, $match, \PREG_UNMATCHED_AS_NULL)) {
// TODO: Remove once we require PHP ≥ 7.4.
$match['query'] = $match['query'] ?? null;
$match['fragment'] = $match['fragment'] ?? null;
return $match;
}
@@ -355,7 +322,7 @@ class IRI
* @param string $input
* @return string
*/
protected function remove_dot_segments($input)
protected function remove_dot_segments(string $input)
{
$output = '';
while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..') {
@@ -404,13 +371,15 @@ class IRI
* @param bool $iprivate Allow iprivate
* @return string
*/
protected function replace_invalid_with_pct_encoding($string, $extra_chars, $iprivate = false)
protected function replace_invalid_with_pct_encoding(string $string, string $extra_chars, bool $iprivate = false)
{
// Normalize as many pct-encoded sections as possible
$string = preg_replace_callback('/(?:%[A-Fa-f0-9]{2})+/', [$this, 'remove_iunreserved_percent_encoded'], $string);
\assert(\is_string($string), "For PHPStan: Should not occur, the regex is valid");
// Replace invalid percent characters
$string = preg_replace('/%(?![A-Fa-f0-9]{2})/', '%25', $string);
\assert(\is_string($string), "For PHPStan: Should not occur, the regex is valid");
// Add unreserved and % to $extra_chars (the latter is safe because all
// pct-encoded sections are now valid).
@@ -525,10 +494,10 @@ class IRI
* Removes sequences of percent encoded bytes that represent UTF-8
* encoded characters in iunreserved
*
* @param array $match PCRE match
* @param array{string} $match PCRE match, a capture group #0 consisting of a sequence of valid percent-encoded bytes
* @return string Replacement
*/
protected function remove_iunreserved_percent_encoded($match)
protected function remove_iunreserved_percent_encoded(array $match)
{
// As we just have valid percent encoded sequences we can just explode
// and ignore the first member of the returned array (an empty string).
@@ -631,7 +600,8 @@ class IRI
}
} else {
for ($j = $start; $j <= $i; $j++) {
$string .= chr(hexdec($bytes[$j]));
// Cast for PHPStan, this will always be a number between 0 and 0xFF so hexdec will return int.
$string .= chr((int) hexdec($bytes[$j]));
}
}
}
@@ -648,6 +618,9 @@ class IRI
return $string;
}
/**
* @return void
*/
protected function scheme_normalization()
{
if (isset($this->normalization[$this->scheme]['iuserinfo']) && $this->iuserinfo === $this->normalization[$this->scheme]['iuserinfo']) {
@@ -708,15 +681,15 @@ class IRI
* Set the entire IRI. Returns true on success, false on failure (if there
* are any invalid characters).
*
* @param string $iri
* @param string|null $iri
* @return bool
*/
public function set_iri($iri, $clear_cache = false)
public function set_iri(?string $iri, bool $clear_cache = false)
{
static $cache;
if ($clear_cache) {
$cache = null;
return;
return false;
}
if (!$cache) {
$cache = [];
@@ -768,10 +741,10 @@ class IRI
* Set the scheme. Returns true on success, false on failure (if there are
* any invalid characters).
*
* @param string $scheme
* @param string|null $scheme
* @return bool
*/
public function set_scheme($scheme)
public function set_scheme(?string $scheme)
{
if ($scheme === null) {
$this->scheme = null;
@@ -788,15 +761,15 @@ class IRI
* Set the authority. Returns true on success, false on failure (if there are
* any invalid characters).
*
* @param string $authority
* @param string|null $authority
* @return bool
*/
public function set_authority($authority, $clear_cache = false)
public function set_authority(?string $authority, bool $clear_cache = false)
{
static $cache;
if ($clear_cache) {
$cache = null;
return;
return false;
}
if (!$cache) {
$cache = [];
@@ -820,13 +793,16 @@ class IRI
$remaining = $authority;
if (($iuserinfo_end = strrpos($remaining, '@')) !== false) {
$iuserinfo = substr($remaining, 0, $iuserinfo_end);
// Cast for PHPStan on PHP < 8.0. It does not detect that
// the range is not flipped so substr cannot return false.
$iuserinfo = (string) substr($remaining, 0, $iuserinfo_end);
$remaining = substr($remaining, $iuserinfo_end + 1);
} else {
$iuserinfo = null;
}
if (($port_start = strpos($remaining, ':', intval(strpos($remaining, ']')))) !== false) {
if (($port = substr($remaining, $port_start + 1)) === false) {
$port = substr($remaining, $port_start + 1);
if ($port === false) {
$port = null;
}
$remaining = substr($remaining, 0, $port_start);
@@ -851,10 +827,10 @@ class IRI
/**
* Set the iuserinfo.
*
* @param string $iuserinfo
* @param string|null $iuserinfo
* @return bool
*/
public function set_userinfo($iuserinfo)
public function set_userinfo(?string $iuserinfo)
{
if ($iuserinfo === null) {
$this->iuserinfo = null;
@@ -870,10 +846,10 @@ class IRI
* Set the ihost. Returns true on success, false on failure (if there are
* any invalid characters).
*
* @param string $ihost
* @param string|null $ihost
* @return bool
*/
public function set_host($ihost)
public function set_host(?string $ihost)
{
if ($ihost === null) {
$this->ihost = null;
@@ -914,7 +890,7 @@ class IRI
* Set the port. Returns true on success, false on failure (if there are
* any invalid characters).
*
* @param string $port
* @param string|int|null $port
* @return bool
*/
public function set_port($port)
@@ -922,7 +898,7 @@ class IRI
if ($port === null) {
$this->port = null;
return true;
} elseif (strspn($port, '0123456789') === strlen($port)) {
} elseif (strspn((string) $port, '0123456789') === strlen((string) $port)) {
$this->port = (int) $port;
$this->scheme_normalization();
return true;
@@ -935,15 +911,15 @@ class IRI
/**
* Set the ipath.
*
* @param string $ipath
* @param string|null $ipath
* @return bool
*/
public function set_path($ipath, $clear_cache = false)
public function set_path(?string $ipath, bool $clear_cache = false)
{
static $cache;
if ($clear_cache) {
$cache = null;
return;
return false;
}
if (!$cache) {
$cache = [];
@@ -968,10 +944,10 @@ class IRI
/**
* Set the iquery.
*
* @param string $iquery
* @param string|null $iquery
* @return bool
*/
public function set_query($iquery)
public function set_query(?string $iquery)
{
if ($iquery === null) {
$this->iquery = null;
@@ -985,10 +961,10 @@ class IRI
/**
* Set the ifragment.
*
* @param string $ifragment
* @param string|null $ifragment
* @return bool
*/
public function set_fragment($ifragment)
public function set_fragment(?string $ifragment)
{
if ($ifragment === null) {
$this->ifragment = null;
@@ -1002,9 +978,10 @@ class IRI
/**
* Convert an IRI to a URI (or parts thereof)
*
* @param string $string
* @return string
*/
public function to_uri($string)
public function to_uri(string $string)
{
static $non_ascii;
if (!$non_ascii) {
@@ -1025,7 +1002,7 @@ class IRI
/**
* Get the complete IRI
*
* @return string
* @return string|false
*/
public function get_iri()
{
@@ -1062,13 +1039,13 @@ class IRI
*/
public function get_uri()
{
return $this->to_uri($this->get_iri());
return $this->to_uri((string) $this->get_iri());
}
/**
* Get the complete iauthority
*
* @return string
* @return ?string
*/
protected function get_iauthority()
{
@@ -1092,7 +1069,7 @@ class IRI
/**
* Get the complete authority
*
* @return string
* @return ?string
*/
protected function get_authority()
{

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
@@ -50,9 +13,6 @@ namespace SimplePie;
* Used by {@see \SimplePie\SimplePie::get_item()} and {@see \SimplePie\SimplePie::get_items()}
*
* This class can be overloaded with {@see \SimplePie\SimplePie::set_item_class()}
*
* @package \SimplePie\SimplePie
* @subpackage API
*/
class Item implements RegistryAware
{
@@ -68,7 +28,7 @@ class Item implements RegistryAware
* Raw data
*
* @access private
* @var array
* @var array<string, mixed>
*/
public $data = [];
@@ -80,6 +40,11 @@ class Item implements RegistryAware
*/
protected $registry;
/**
* @var Sanitize|null
*/
private $sanitize = null;
/**
* Create a new item object
*
@@ -87,9 +52,9 @@ class Item implements RegistryAware
* {@see \SimplePie\SimplePie::get_item}. Avoid creating this manually.
*
* @param \SimplePie\SimplePie $feed Parent feed
* @param array $data Raw data
* @param array<string, mixed> $data Raw data
*/
public function __construct($feed, $data)
public function __construct(\SimplePie\SimplePie $feed, array $data)
{
$this->feed = $feed;
$this->data = $data;
@@ -102,8 +67,9 @@ class Item implements RegistryAware
*
* @since 1.3
* @param \SimplePie\Registry $registry
* @return void
*/
public function set_registry(\SimplePie\Registry $registry)/* : void */
public function set_registry(\SimplePie\Registry $registry)
{
$this->registry = $registry;
}
@@ -140,9 +106,9 @@ class Item implements RegistryAware
* @see http://simplepie.org/wiki/faq/supported_xml_namespaces
* @param string $namespace The URL of the XML namespace of the elements you're trying to access
* @param string $tag Tag name
* @return array
* @return array<array<string, mixed>>|null
*/
public function get_item_tags($namespace, $tag)
public function get_item_tags(string $namespace, string $tag)
{
if (isset($this->data['child'][$namespace][$tag])) {
return $this->data['child'][$namespace][$tag];
@@ -152,13 +118,31 @@ class Item implements RegistryAware
}
/**
* Get the base URL value.
* Uses `<xml:base>`, or item link, or feed base URL.
* Get base URL of the item itself.
* Returns `<xml:base>` or feed base URL.
* Similar to `Item::get_base()` but can safely be used during initialisation methods
* such as `Item::get_links()` (`Item::get_base()` and `Item::get_links()` call each-other)
* and is not affected by enclosures.
*
* @param array $element
* @param array<string, mixed> $element
* @see get_base
*/
private function get_own_base(array $element = []): string
{
if (!empty($element['xml_base_explicit']) && isset($element['xml_base'])) {
return $element['xml_base'];
}
return $this->feed->get_base();
}
/**
* Get the base URL value.
* Uses `<xml:base>`, or item link, or enclosure link, or feed base URL.
*
* @param array<string, mixed> $element
* @return string
*/
public function get_base($element = [])
public function get_base(array $element = [])
{
if (!empty($element['xml_base_explicit']) && isset($element['xml_base'])) {
return $element['xml_base'];
@@ -176,12 +160,13 @@ class Item implements RegistryAware
* @access private
* @see \SimplePie\SimplePie::sanitize()
* @param string $data Data to sanitize
* @param int $type One of the \SimplePie\SimplePie::CONSTRUCT_* constants
* @param int-mask-of<SimplePie::CONSTRUCT_*> $type
* @param string $base Base URL to resolve URLs against
* @return string Sanitized data
*/
public function sanitize($data, $type, $base = '')
public function sanitize(string $data, int $type, string $base = '')
{
// This really returns string|false but changing encoding is uncommon and we are going to deprecate it, so lets just lie to PHPStan in the interest of cleaner annotations.
return $this->feed->sanitize($data, $type, $base);
}
@@ -209,11 +194,11 @@ class Item implements RegistryAware
* MD5 hash based on the permalink, title and content.
*
* @since Beta 2
* @param boolean $hash Should we force using a hash instead of the supplied ID?
* @param bool $hash Should we force using a hash instead of the supplied ID?
* @param string|false $fn User-supplied function to generate an hash
* @return string|null
*/
public function get_id($hash = false, $fn = 'md5')
public function get_id(bool $hash = false, $fn = 'md5')
{
if (!$hash) {
if ($return = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'id')) {
@@ -286,10 +271,10 @@ class Item implements RegistryAware
* `<itunes:subtitle>`
*
* @since 0.8
* @param boolean $description_only Should we avoid falling back to the content?
* @param bool $description_only Should we avoid falling back to the content?
* @return string|null
*/
public function get_description($description_only = false)
public function get_description(bool $description_only = false)
{
if (($tags = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'summary')) &&
($return = $this->sanitize($tags[0]['data'], $this->registry->call(Misc::class, 'atom_10_construct_type', [$tags[0]['attribs']]), $this->get_base($tags[0])))) {
@@ -336,10 +321,10 @@ class Item implements RegistryAware
* Uses `<atom:content>` or `<content:encoded>` (RSS 1.0 Content Module)
*
* @since 1.0
* @param boolean $content_only Should we avoid falling back to the description?
* @param bool $content_only Should we avoid falling back to the description?
* @return string|null
*/
public function get_content($content_only = false)
public function get_content(bool $content_only = false)
{
if (($tags = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'content')) &&
($return = $this->sanitize($tags[0]['data'], $this->registry->call(Misc::class, 'atom_10_content_construct_type', [$tags[0]['attribs']]), $this->get_base($tags[0])))) {
@@ -363,7 +348,7 @@ class Item implements RegistryAware
* Uses `<media:thumbnail>`
*
*
* @return array|null
* @return array{url: string, height?: string, width?: string, time?: string}|null
*/
public function get_thumbnail()
{
@@ -390,7 +375,7 @@ class Item implements RegistryAware
* @param int $key The category that you want to return. Remember that arrays begin with 0, not 1
* @return \SimplePie\Category|null
*/
public function get_category($key = 0)
public function get_category(int $key = 0)
{
$categories = $this->get_categories();
if (isset($categories[$key])) {
@@ -462,7 +447,7 @@ class Item implements RegistryAware
* @param int $key The author that you want to return. Remember that arrays begin with 0, not 1
* @return \SimplePie\Author|null
*/
public function get_author($key = 0)
public function get_author(int $key = 0)
{
$authors = $this->get_authors();
if (isset($authors[$key])) {
@@ -479,7 +464,7 @@ class Item implements RegistryAware
* @param int $key The contrbutor that you want to return. Remember that arrays begin with 0, not 1
* @return \SimplePie\Author|null
*/
public function get_contributor($key = 0)
public function get_contributor(int $key = 0)
{
$contributors = $this->get_contributors();
if (isset($contributors[$key])) {
@@ -508,7 +493,8 @@ class Item implements RegistryAware
$name = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['name'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'])) {
$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]));
$uri = $contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0];
$uri = $this->sanitize($uri['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($uri));
}
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'])) {
$email = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
@@ -525,7 +511,8 @@ class Item implements RegistryAware
$name = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['name'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'])) {
$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]));
$url = $contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0];
$url = $this->sanitize($url['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($url));
}
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'])) {
$email = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
@@ -561,7 +548,8 @@ class Item implements RegistryAware
$name = $this->sanitize($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['name'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'])) {
$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]));
$uri = $author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0];
$uri = $this->sanitize($uri['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($uri));
}
if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'])) {
$email = $this->sanitize($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
@@ -578,7 +566,8 @@ class Item implements RegistryAware
$name = $this->sanitize($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['name'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'])) {
$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]));
$url = $author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0];
$url = $this->sanitize($url['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($url));
}
if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'])) {
$email = $this->sanitize($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
@@ -617,7 +606,7 @@ class Item implements RegistryAware
* Uses `<atom:rights>` or `<dc:rights>`
*
* @since 1.1
* @return string
* @return string|null
*/
public function get_copyright()
{
@@ -644,9 +633,9 @@ class Item implements RegistryAware
* @since Beta 2 (previously called `get_item_date` since 0.8)
*
* @param string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data)
* @return int|string|null
* @return ($date_format is 'U' ? ?int : ?string)
*/
public function get_date($date_format = 'j F Y, g:i a')
public function get_date(string $date_format = 'j F Y, g:i a')
{
if (!isset($this->data['date'])) {
if ($return = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'published')) {
@@ -675,7 +664,6 @@ class Item implements RegistryAware
}
}
if ($this->data['date']) {
$date_format = (string) $date_format;
switch ($date_format) {
case '':
return $this->sanitize($this->data['date']['raw'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
@@ -700,9 +688,9 @@ class Item implements RegistryAware
* {@see get_gmdate}
*
* @param string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data)
* @return int|string|null
* @return ($date_format is 'U' ? ?int : ?string)
*/
public function get_updated_date($date_format = 'j F Y, g:i a')
public function get_updated_date(string $date_format = 'j F Y, g:i a')
{
if (!isset($this->data['updated'])) {
if ($return = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'updated')) {
@@ -717,7 +705,6 @@ class Item implements RegistryAware
}
}
if ($this->data['updated']) {
$date_format = (string) $date_format;
switch ($date_format) {
case '':
return $this->sanitize($this->data['updated']['raw'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
@@ -744,12 +731,16 @@ class Item implements RegistryAware
* @since 1.0
*
* @param string $date_format Supports any PHP date format from {@see http://php.net/strftime} (empty for the raw data)
* @return int|string|null
* @return string|null|false see `strftime` for when this can return `false`
*/
public function get_local_date($date_format = '%c')
public function get_local_date(string $date_format = '%c')
{
if (!$date_format) {
return $this->sanitize($this->get_date(''), \SimplePie\SimplePie::CONSTRUCT_TEXT);
if ($date_format === '') {
if (($raw_date = $this->get_date('')) === null) {
return null;
}
return $this->sanitize($raw_date, \SimplePie\SimplePie::CONSTRUCT_TEXT);
} elseif (($date = $this->get_date('U')) !== null && $date !== false) {
return strftime($date_format, $date);
}
@@ -762,9 +753,9 @@ class Item implements RegistryAware
*
* @see get_date
* @param string $date_format Supports any PHP date format from {@see http://php.net/date}
* @return int|string|null
* @return string|null
*/
public function get_gmdate($date_format = 'j F Y, g:i a')
public function get_gmdate(string $date_format = 'j F Y, g:i a')
{
$date = $this->get_date('U');
if ($date === null) {
@@ -779,9 +770,9 @@ class Item implements RegistryAware
*
* @see get_updated_date
* @param string $date_format Supports any PHP date format from {@see http://php.net/date}
* @return int|string|null
* @return string|null
*/
public function get_updated_gmdate($date_format = 'j F Y, g:i a')
public function get_updated_gmdate(string $date_format = 'j F Y, g:i a')
{
$date = $this->get_updated_date('U');
if ($date === null) {
@@ -822,7 +813,7 @@ class Item implements RegistryAware
* @param string $rel The relationship of the link to return
* @return string|null Link URL
*/
public function get_link($key = 0, $rel = 'alternate')
public function get_link(int $key = 0, string $rel = 'alternate')
{
$links = $this->get_links($rel);
if ($links && $links[$key] !== null) {
@@ -839,36 +830,36 @@ class Item implements RegistryAware
*
* @since Beta 2
* @param string $rel The relationship of links to return
* @return array|null Links found for the item (strings)
* @return array<string>|null Links found for the item (strings)
*/
public function get_links($rel = 'alternate')
public function get_links(string $rel = 'alternate')
{
if (!isset($this->data['links'])) {
$this->data['links'] = [];
foreach ((array) $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'link') as $link) {
if (isset($link['attribs']['']['href'])) {
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($link));
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($link));
}
}
foreach ((array) $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_03, 'link') as $link) {
if (isset($link['attribs']['']['href'])) {
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($link));
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($link));
}
}
if ($links = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_10, 'link')) {
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($links[0]));
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($links[0]));
}
if ($links = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_090, 'link')) {
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($links[0]));
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($links[0]));
}
if ($links = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'link')) {
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($links[0]));
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($links[0]));
}
if ($links = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'guid')) {
if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true') {
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($links[0]));
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($links[0]));
}
}
@@ -881,8 +872,8 @@ class Item implements RegistryAware
} else {
$this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] = &$this->data['links'][$key];
}
} elseif (substr($key, 0, 41) === \SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY) {
$this->data['links'][substr($key, 41)] = &$this->data['links'][$key];
} elseif (substr((string) $key, 0, 41) === \SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY) {
$this->data['links'][substr((string) $key, 41)] = &$this->data['links'][$key];
}
$this->data['links'][$key] = array_unique($this->data['links'][$key]);
}
@@ -904,7 +895,7 @@ class Item implements RegistryAware
* @param int $key The enclosure that you want to return. Remember that arrays begin with 0, not 1
* @return \SimplePie\Enclosure|null
*/
public function get_enclosure($key = 0, $prefer = null)
public function get_enclosure(int $key = 0)
{
$enclosures = $this->get_enclosures();
if (isset($enclosures[$key])) {
@@ -944,7 +935,7 @@ class Item implements RegistryAware
$keywords_parent = null;
$player_parent = null;
$ratings_parent = null;
$restrictions_parent = null;
$restrictions_parent = [];
$thumbnails_parent = null;
$title_parent = null;
@@ -1139,20 +1130,19 @@ class Item implements RegistryAware
}
// DURATION
if ($duration_parent = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'duration')) {
$duration_tags = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'duration');
if ($duration_tags !== null) {
$seconds = null;
$minutes = null;
$hours = null;
if (isset($duration_parent[0]['data'])) {
$temp = explode(':', $this->sanitize($duration_parent[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT));
if (sizeof($temp) > 0) {
$seconds = (int) array_pop($temp);
}
if (sizeof($temp) > 0) {
if (isset($duration_tags[0]['data'])) {
$temp = explode(':', $this->sanitize($duration_tags[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT));
$seconds = (int) array_pop($temp);
if (count($temp) > 0) {
$minutes = (int) array_pop($temp);
$seconds += $minutes * 60;
}
if (sizeof($temp) > 0) {
if (count($temp) > 0) {
$hours = (int) array_pop($temp);
$seconds += $hours * 3600;
}
@@ -1236,11 +1226,11 @@ class Item implements RegistryAware
// PLAYER
if ($player_parent = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_MEDIARSS, 'player')) {
if (isset($player_parent[0]['attribs']['']['url'])) {
$player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
$player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($player_parent[0]));
}
} elseif ($player_parent = $parent->get_channel_tags(\SimplePie\SimplePie::NAMESPACE_MEDIARSS, 'player')) {
if (isset($player_parent[0]['attribs']['']['url'])) {
$player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
$player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($player_parent[0]));
}
}
@@ -1315,11 +1305,11 @@ class Item implements RegistryAware
}
} elseif ($restrictions = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'block')) {
foreach ($restrictions as $restriction) {
$restriction_relationship = 'allow';
$restriction_relationship = Restriction::RELATIONSHIP_ALLOW;
$restriction_type = null;
$restriction_value = 'itunes';
if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') {
$restriction_relationship = 'deny';
$restriction_relationship = Restriction::RELATIONSHIP_DENY;
}
$restrictions_parent[] = $this->registry->create(Restriction::class, [$restriction_relationship, $restriction_type, $restriction_value]);
}
@@ -1341,32 +1331,32 @@ class Item implements RegistryAware
}
} elseif ($restrictions = $parent->get_channel_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'block')) {
foreach ($restrictions as $restriction) {
$restriction_relationship = 'allow';
$restriction_relationship = Restriction::RELATIONSHIP_ALLOW;
$restriction_type = null;
$restriction_value = 'itunes';
if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') {
$restriction_relationship = 'deny';
$restriction_relationship = Restriction::RELATIONSHIP_DENY;
}
$restrictions_parent[] = $this->registry->create(Restriction::class, [$restriction_relationship, $restriction_type, $restriction_value]);
}
}
if (is_array($restrictions_parent)) {
if (count($restrictions_parent) > 0) {
$restrictions_parent = array_values(array_unique($restrictions_parent));
} else {
$restrictions_parent = [new \SimplePie\Restriction('allow', null, 'default')];
$restrictions_parent = [new \SimplePie\Restriction(Restriction::RELATIONSHIP_ALLOW, null, 'default')];
}
// THUMBNAILS
if ($thumbnails = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_MEDIARSS, 'thumbnail')) {
foreach ($thumbnails as $thumbnail) {
if (isset($thumbnail['attribs']['']['url'])) {
$thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
$thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($thumbnail));
}
}
} elseif ($thumbnails = $parent->get_channel_tags(\SimplePie\SimplePie::NAMESPACE_MEDIARSS, 'thumbnail')) {
foreach ($thumbnails as $thumbnail) {
if (isset($thumbnail['attribs']['']['url'])) {
$thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
$thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($thumbnail));
}
}
}
@@ -1490,7 +1480,7 @@ class Item implements RegistryAware
if (isset($content['attribs']['']['width'])) {
$width = $this->sanitize($content['attribs']['']['width'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
$url = $this->sanitize($content['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
$url = $this->sanitize($content['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($content));
// Checking the other optional media: elements. Priority: media:content, media:group, item, channel
@@ -1749,9 +1739,11 @@ class Item implements RegistryAware
// PLAYER
if (isset($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'])) {
$player = $this->sanitize($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
$playerElem = $content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0];
$player = $this->sanitize($playerElem['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($playerElem));
} elseif (isset($group['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'])) {
$player = $this->sanitize($group['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
$playerElem = $group['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0];
$player = $this->sanitize($playerElem['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($playerElem));
} else {
$player = $player_parent;
}
@@ -1841,14 +1833,14 @@ class Item implements RegistryAware
// THUMBNAILS
if (isset($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['thumbnail'])) {
foreach ($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) {
$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($thumbnail));
}
if (is_array($thumbnails)) {
$thumbnails = array_values(array_unique($thumbnails));
}
} elseif (isset($group['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['thumbnail'])) {
foreach ($group['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) {
$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($thumbnail));
}
if (is_array($thumbnails)) {
$thumbnails = array_values(array_unique($thumbnails));
@@ -1946,7 +1938,7 @@ class Item implements RegistryAware
$width = $this->sanitize($content['attribs']['']['width'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['url'])) {
$url = $this->sanitize($content['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
$url = $this->sanitize($content['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($content));
}
// Checking the other optional media: elements. Priority: media:content, media:group, item, channel
@@ -2101,7 +2093,8 @@ class Item implements RegistryAware
// PLAYER
if (isset($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'])) {
if (isset($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'])) {
$player = $this->sanitize($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
$playerElem = $content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0];
$player = $this->sanitize($playerElem['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($playerElem));
}
} else {
$player = $player_parent;
@@ -2157,7 +2150,7 @@ class Item implements RegistryAware
if (isset($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['thumbnail'])) {
foreach ($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) {
if (isset($thumbnail['attribs']['']['url'])) {
$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($thumbnail));
}
}
if (is_array($thumbnails)) {
@@ -2197,7 +2190,7 @@ class Item implements RegistryAware
$url = null;
$width = null;
$url = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($link));
$url = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($link));
if (isset($link['attribs']['']['type'])) {
$type = $this->sanitize($link['attribs']['']['type'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
@@ -2233,7 +2226,7 @@ class Item implements RegistryAware
$url = null;
$width = null;
$url = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($link));
$url = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($link));
if (isset($link['attribs']['']['type'])) {
$type = $this->sanitize($link['attribs']['']['type'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
@@ -2264,8 +2257,8 @@ class Item implements RegistryAware
$url = null;
$width = null;
$url = $this->sanitize($enclosure['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($enclosure));
$url = $this->feed->sanitize->https_url($url);
$url = $this->sanitize($enclosure['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($enclosure));
$url = $this->get_sanitize()->https_url($url);
if (isset($enclosure['attribs']['']['type'])) {
$type = $this->sanitize($enclosure['attribs']['']['type'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
@@ -2278,7 +2271,7 @@ class Item implements RegistryAware
}
}
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)) {
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)) {
// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
$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]);
}
@@ -2302,7 +2295,7 @@ class Item implements RegistryAware
* @since 1.0
* @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo
* @link http://www.georss.org/ GeoRSS
* @return string|null
* @return float|null
*/
public function get_latitude()
{
@@ -2325,7 +2318,7 @@ class Item implements RegistryAware
* @since 1.0
* @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo
* @link http://www.georss.org/ GeoRSS
* @return string|null
* @return float|null
*/
public function get_longitude()
{
@@ -2354,6 +2347,20 @@ class Item implements RegistryAware
return null;
}
public function set_sanitize(Sanitize $sanitize): void
{
$this->sanitize = $sanitize;
}
protected function get_sanitize(): Sanitize
{
if ($this->sanitize === null) {
$this->sanitize = new Sanitize();
}
return $this->sanitize;
}
}
class_alias('SimplePie\Item', 'SimplePie_Item');

View File

@@ -1,76 +1,70 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
use DomDocument;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;
use SimplePie\HTTP\Client;
use SimplePie\HTTP\ClientException;
use SimplePie\HTTP\FileClient;
use SimplePie\HTTP\Psr18Client;
use SimplePie\HTTP\Response;
/**
* Used for feed auto-discovery
*
*
* This class can be overloaded with {@see \SimplePie\SimplePie::set_locator_class()}
*
* @package SimplePie
*/
class Locator implements RegistryAware
{
public $useragent;
public $timeout;
/** @var ?string */
public $useragent = null;
/** @var int */
public $timeout = 10;
/** @var File */
public $file;
/** @var string[] */
public $local = [];
/** @var string[] */
public $elsewhere = [];
/** @var array<mixed> */
public $cached_entities = [];
/** @var string */
public $http_base;
/** @var string */
public $base;
/** @var int */
public $base_location = 0;
/** @var int */
public $checked_feeds = 0;
/** @var int */
public $max_checked_feeds = 10;
/** @var bool */
public $force_fsockopen = false;
/** @var array<int, mixed> */
public $curl_options = [];
/** @var ?\DomDocument */
public $dom;
/** @var ?Registry */
protected $registry;
public function __construct(\SimplePie\File $file, $timeout = 10, $useragent = null, $max_checked_feeds = 10, $force_fsockopen = false, $curl_options = [])
/**
* @var Client|null
*/
private $http_client = null;
/**
* @param array<int, mixed> $curl_options
*/
public function __construct(File $file, int $timeout = 10, ?string $useragent = null, int $max_checked_feeds = 10, bool $force_fsockopen = false, array $curl_options = [])
{
$this->file = $file;
$this->useragent = $useragent;
@@ -79,12 +73,14 @@ class Locator implements RegistryAware
$this->force_fsockopen = $force_fsockopen;
$this->curl_options = $curl_options;
if (class_exists('DOMDocument') && $this->file->body != '') {
$body = $this->file->get_body_content();
if (class_exists('DOMDocument') && $body != '') {
$this->dom = new \DOMDocument();
set_error_handler(['SimplePie\Misc', 'silence_errors']);
set_error_handler([Misc::class, 'silence_errors']);
try {
$this->dom->loadHTML($this->file->body);
$this->dom->loadHTML($body);
} catch (\Throwable $ex) {
$this->dom = null;
}
@@ -94,18 +90,41 @@ class Locator implements RegistryAware
}
}
public function set_registry(\SimplePie\Registry $registry)/* : void */
/**
* Set a PSR-18 client and PSR-17 factories
*
* Allows you to use your own HTTP client implementations.
*/
final public function set_http_client(
ClientInterface $http_client,
RequestFactoryInterface $request_factory,
UriFactoryInterface $uri_factory
): void {
$this->http_client = new Psr18Client($http_client, $request_factory, $uri_factory);
}
/**
* @return void
*/
public function set_registry(\SimplePie\Registry $registry)
{
$this->registry = $registry;
}
public function find($type = \SimplePie\SimplePie::LOCATOR_ALL, &$working = null)
/**
* @param SimplePie::LOCATOR_* $type
* @param array<Response>|null $working
* @return Response|null
*/
public function find(int $type = \SimplePie\SimplePie::LOCATOR_ALL, ?array &$working = null)
{
assert($this->registry !== null);
if ($this->is_feed($this->file)) {
return $this->file;
}
if ($this->file->method & \SimplePie\SimplePie::FILE_SOURCE_REMOTE) {
if (Misc::is_remote_uri($this->file->get_final_requested_uri())) {
$sniffer = $this->registry->create(Content\Type\Sniffer::class, [$this->file]);
if ($sniffer->get_type() !== 'text/html') {
return null;
@@ -140,9 +159,14 @@ class Locator implements RegistryAware
return null;
}
public function is_feed($file, $check_html = false)
/**
* @return bool
*/
public function is_feed(Response $file, bool $check_html = false)
{
if ($file->method & \SimplePie\SimplePie::FILE_SOURCE_REMOTE) {
assert($this->registry !== null);
if (Misc::is_remote_uri($file->get_final_requested_uri())) {
$sniffer = $this->registry->create(Content\Type\Sniffer::class, [$file]);
$sniffed = $sniffer->get_type();
$mime_types = ['application/rss+xml', 'application/rdf+xml',
@@ -153,19 +177,24 @@ class Locator implements RegistryAware
}
return in_array($sniffed, $mime_types);
} elseif ($file->method & \SimplePie\SimplePie::FILE_SOURCE_LOCAL) {
} elseif (is_file($file->get_final_requested_uri())) {
return true;
} else {
return false;
}
}
/**
* @return void
*/
public function get_base()
{
assert($this->registry !== null);
if ($this->dom === null) {
throw new \SimplePie\Exception('DOMDocument not found, unable to use locator');
}
$this->http_base = $this->file->url;
$this->http_base = $this->file->get_final_requested_uri();
$this->base = $this->http_base;
$elements = $this->dom->getElementsByTagName('base');
foreach ($elements as $element) {
@@ -181,6 +210,9 @@ class Locator implements RegistryAware
}
}
/**
* @return array<Response>|null
*/
public function autodiscovery()
{
$done = [];
@@ -196,8 +228,15 @@ class Locator implements RegistryAware
return null;
}
protected function search_elements_by_tag($name, &$done, $feeds)
/**
* @param string[] $done
* @param array<string, Response> $feeds
* @return array<string, Response>
*/
protected function search_elements_by_tag(string $name, array &$done, array $feeds)
{
assert($this->registry !== null);
if ($this->dom === null) {
throw new \SimplePie\Exception('DOMDocument not found, unable to use locator');
}
@@ -223,11 +262,17 @@ class Locator implements RegistryAware
if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !in_array('stylesheet', $rel) && $link->hasAttribute('type') && in_array(strtolower($this->registry->call(Misc::class, 'parse_mime', [$link->getAttribute('type')])), ['text/html', 'application/rss+xml', 'application/atom+xml'])) && !isset($feeds[$href])) {
$this->checked_feeds++;
$headers = [
'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',
'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER,
];
$feed = $this->registry->create(File::class, [$href, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options]);
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)) {
$feeds[$href] = $feed;
try {
$feed = $this->get_http_client()->request(Client::METHOD_GET, $href, $headers);
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)) {
$feeds[$href] = $feed;
}
} catch (ClientException $th) {
// Just mark it as done and continue.
}
}
$done[] = $href;
@@ -237,8 +282,13 @@ class Locator implements RegistryAware
return $feeds;
}
/**
* @return true|null
*/
public function get_links()
{
assert($this->registry !== null);
if ($this->dom === null) {
throw new \SimplePie\Exception('DOMDocument not found, unable to use locator');
}
@@ -258,7 +308,7 @@ class Locator implements RegistryAware
continue;
}
$current = $this->registry->call(Misc::class, 'parse_url', [$this->file->url]);
$current = $this->registry->call(Misc::class, 'parse_url', [$this->file->get_final_requested_uri()]);
if ($parsed['authority'] === '' || $parsed['authority'] === $current['authority']) {
$this->local[] = $href;
@@ -276,8 +326,15 @@ class Locator implements RegistryAware
return null;
}
public function get_rel_link($rel)
/**
* Extracts first `link` element with given `rel` attribute inside the `head` element.
*
* @return string|null
*/
public function get_rel_link(string $rel)
{
assert($this->registry !== null);
if ($this->dom === null) {
throw new \SimplePie\Exception('DOMDocument not found, unable to use '.
'locator');
@@ -288,8 +345,10 @@ class Locator implements RegistryAware
}
$xpath = new \DOMXpath($this->dom);
$query = '//a[@rel and @href] | //link[@rel and @href]';
foreach ($xpath->query($query) as $link) {
$query = '(//head)[1]/link[@rel and @href]';
/** @var \DOMNodeList<\DOMElement> */
$queryResult = $xpath->query($query);
foreach ($queryResult as $link) {
$href = trim($link->getAttribute('href'));
$parsed = $this->registry->call(Misc::class, 'parse_url', [$href]);
if ($parsed['scheme'] === '' ||
@@ -317,33 +376,49 @@ class Locator implements RegistryAware
}
}
}
return null;
}
public function extension(&$array)
/**
* @param string[] $array
* @return array<Response>|null
*/
public function extension(array &$array)
{
foreach ($array as $key => $value) {
if ($this->checked_feeds === $this->max_checked_feeds) {
break;
}
if (in_array(strtolower(strrchr($value, '.')), ['.rss', '.rdf', '.atom', '.xml'])) {
$extension = strrchr($value, '.');
if ($extension !== false && in_array(strtolower($extension), ['.rss', '.rdf', '.atom', '.xml'])) {
$this->checked_feeds++;
$headers = [
'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',
'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER,
];
$feed = $this->registry->create(File::class, [$value, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options]);
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)) {
return [$feed];
} else {
unset($array[$key]);
try {
$feed = $this->get_http_client()->request(Client::METHOD_GET, $value, $headers);
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)) {
return [$feed];
}
} catch (ClientException $th) {
// Just unset and continue.
}
unset($array[$key]);
}
}
return null;
}
public function body(&$array)
/**
* @param string[] $array
* @return array<Response>|null
*/
public function body(array &$array)
{
foreach ($array as $key => $value) {
if ($this->checked_feeds === $this->max_checked_feeds) {
@@ -352,18 +427,52 @@ class Locator implements RegistryAware
if (preg_match('/(feed|rss|rdf|atom|xml)/i', $value)) {
$this->checked_feeds++;
$headers = [
'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',
'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER,
];
$feed = $this->registry->create(File::class, [$value, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen, $this->curl_options]);
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)) {
return [$feed];
} else {
unset($array[$key]);
try {
$feed = $this->get_http_client()->request(Client::METHOD_GET, $value, $headers);
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)) {
return [$feed];
}
} catch (ClientException $th) {
// Just unset and continue.
}
unset($array[$key]);
}
}
return null;
}
/**
* Get a HTTP client
*/
private function get_http_client(): Client
{
assert($this->registry !== null);
if ($this->http_client === null) {
$options = [
'timeout' => $this->timeout,
'redirects' => 5,
'force_fsockopen' => $this->force_fsockopen,
'curl_options' => $this->curl_options,
];
if ($this->useragent !== null) {
$options['useragent'] = $this->useragent;
}
return new FileClient(
$this->registry,
$options
);
}
return $this->http_client;
}
}
class_alias('SimplePie\Locator', 'SimplePie_Locator', false);

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
@@ -48,14 +11,16 @@ use SimplePie\XML\Declaration\Parser;
/**
* Miscellaneous utilities
*
* @package SimplePie
*/
class Misc
{
/** @var int|null */
private static $SIMPLEPIE_BUILD = null;
public static function time_hms($seconds)
/**
* @return string
*/
public static function time_hms(int $seconds)
{
$time = '';
@@ -80,7 +45,10 @@ class Misc
return $time;
}
public static function absolutize_url($relative, $base)
/**
* @return string|false
*/
public static function absolutize_url(string $relative, string $base)
{
$iri = \SimplePie\IRI::absolutize(new \SimplePie\IRI($base), $relative);
if ($iri === false) {
@@ -89,15 +57,23 @@ class Misc
return $iri->get_uri();
}
/**
* @internal
*/
public static function is_remote_uri(string $uri): bool
{
return preg_match('/^https?:\/\//i', $uri) === 1;
}
/**
* Get a HTML/XML element from a HTML string
*
* @deprecated since SimplePie 1.3, use DOMDocument instead (parsing HTML with regex is bad!)
* @param string $realname Element name (including namespace prefix if applicable)
* @param string $string HTML document
* @return array
* @return array<array{tag: string, self_closing: bool, attribs: array<string, array{data: string}>, content?: string}>
*/
public static function get_element($realname, $string)
public static function get_element(string $realname, string $string)
{
// trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.3, use "DOMDocument" instead.'), \E_USER_DEPRECATED);
@@ -116,11 +92,11 @@ class Misc
}
$return[$i]['attribs'] = [];
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)) {
for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++) {
if (count($attribs[$j]) === 2) {
$attribs[$j][2] = $attribs[$j][1];
foreach ($attribs as $attrib) {
if (count($attrib) === 2) {
$attrib[2] = $attrib[1];
}
$return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = Misc::entities_decode(end($attribs[$j]));
$return[$i]['attribs'][strtolower($attrib[1])]['data'] = Misc::entities_decode(end($attrib));
}
}
}
@@ -128,9 +104,16 @@ class Misc
return $return;
}
public static function element_implode($element)
/**
* @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.
* @param array{tag: string, self_closing: bool, attribs: array<string, array{data: string}>, content: string} $element
* @return string
*/
public static function element_implode(array $element)
{
$full = "<$element[tag]";
// trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.9.'), \E_USER_DEPRECATED);
$full = "<{$element['tag']}";
foreach ($element['attribs'] as $key => $value) {
$key = strtolower($key);
$full .= " $key=\"" . htmlspecialchars($value['data'], ENT_COMPAT, 'UTF-8') . '"';
@@ -138,12 +121,19 @@ class Misc
if ($element['self_closing']) {
$full .= ' />';
} else {
$full .= ">$element[content]</$element[tag]>";
$full .= ">{$element['content']}</{$element['tag']}>";
}
return $full;
}
public static function error($message, $level, $file, $line)
/**
* @param string $message
* @param int $level
* @param string $file
* @param int $line
* @return string
*/
public static function error(string $message, int $level, string $file, int $line)
{
if ((error_reporting() & $level) > 0) {
switch ($level) {
@@ -179,7 +169,10 @@ class Misc
return $message;
}
public static function fix_protocol($url, $http = 1)
/**
* @return string
*/
public static function fix_protocol(string $url, int $http = 1)
{
$url = Misc::normalize_url($url);
$parsed = Misc::parse_url($url);
@@ -204,8 +197,11 @@ class Misc
/**
* @deprecated since SimplePie 1.8.0, use PHP native array_replace_recursive() instead.
* @param array<mixed> $array1
* @param array<mixed> $array2
* @return array<mixed>
*/
public static function array_merge_recursive($array1, $array2)
public static function array_merge_recursive(array $array1, array $array2)
{
foreach ($array2 as $key => $value) {
if (is_array($value)) {
@@ -218,7 +214,10 @@ class Misc
return $array1;
}
public static function parse_url($url)
/**
* @return array<string, string>
*/
public static function parse_url(string $url)
{
$iri = new \SimplePie\IRI($url);
return [
@@ -230,7 +229,10 @@ class Misc
];
}
public static function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '')
/**
* @return string
*/
public static function compress_parse_url(string $scheme = '', string $authority = '', string $path = '', string $query = '', ?string $fragment = '')
{
$iri = new \SimplePie\IRI('');
$iri->scheme = $scheme;
@@ -241,17 +243,26 @@ class Misc
return $iri->get_uri();
}
public static function normalize_url($url)
/**
* @return string
*/
public static function normalize_url(string $url)
{
$iri = new \SimplePie\IRI($url);
return $iri->get_uri();
}
public static function percent_encoding_normalization($match)
/**
* @deprecated since SimplePie 1.9.0. This functionality is part of `IRI` if you need it standalone, consider copying the function to your codebase.
* @param array<int, string> $match
* @return string
*/
public static function percent_encoding_normalization(array $match)
{
$integer = hexdec($match[1]);
if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E) {
return chr($integer);
// Cast for PHPStan, the value would only be float when above PHP_INT_MAX, which would not go in this branch.
return chr((int) $integer);
}
return strtoupper($match[0]);
@@ -264,7 +275,7 @@ class Misc
* @param string $string Windows-1252 encoded string
* @return string UTF-8 encoded string
*/
public static function windows_1252_to_utf8($string)
public static function windows_1252_to_utf8(string $string)
{
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"];
@@ -277,22 +288,22 @@ class Misc
* @param string $data Raw data in $input encoding
* @param string $input Encoding of $data
* @param string $output Encoding you want
* @return string|boolean False if we can't convert it
* @return string|false False if we can't convert it
*/
public static function change_encoding($data, $input, $output)
public static function change_encoding(string $data, string $input, string $output)
{
$input = Misc::encoding($input);
$output = Misc::encoding($output);
// We fail to fail on non US-ASCII bytes
if ($input === 'US-ASCII') {
static $non_ascii_octects = '';
if (!$non_ascii_octects) {
static $non_ascii_octets = '';
if (!$non_ascii_octets) {
for ($i = 0x80; $i <= 0xFF; $i++) {
$non_ascii_octects .= chr($i);
$non_ascii_octets .= chr($i);
}
}
$data = substr($data, 0, strcspn($data, $non_ascii_octects));
$data = substr($data, 0, strcspn($data, $non_ascii_octets));
}
// This is first, as behaviour of this is completely predictable
@@ -316,7 +327,10 @@ class Misc
return false;
}
protected static function change_encoding_mbstring($data, $input, $output)
/**
* @return string|false
*/
protected static function change_encoding_mbstring(string $data, string $input, string $output)
{
if ($input === 'windows-949') {
$input = 'EUC-KR';
@@ -348,18 +362,18 @@ class Misc
return false;
}
protected static function change_encoding_iconv($data, $input, $output)
/**
* @return string|false
*/
protected static function change_encoding_iconv(string $data, string $input, string $output)
{
return @iconv($input, $output, $data);
}
/**
* @param string $data
* @param string $input
* @param string $output
* @return string|false
*/
protected static function change_encoding_uconverter($data, $input, $output)
protected static function change_encoding_uconverter(string $data, string $input, string $output)
{
return @\UConverter::transcode($data, $output, $input);
}
@@ -375,10 +389,11 @@ class Misc
* @param string $charset Character set to standardise
* @return string Standardised name
*/
public static function encoding($charset)
public static function encoding(string $charset)
{
// Normalization from UTS #22
switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset))) {
// Cast for PHPStan, the regex should not fail.
switch (strtolower((string) preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset))) {
case 'adobestandardencoding':
case 'csadobestandardencoding':
return 'Adobe-Standard-Encoding';
@@ -1687,16 +1702,15 @@ class Misc
}
}
/**
* @return string
*/
public static function get_curl_version()
{
if (is_array($curl = curl_version())) {
$curl = $curl['version'];
} elseif (substr($curl, 0, 5) === 'curl/') {
$curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5));
} elseif (substr($curl, 0, 8) === 'libcurl/') {
$curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8));
} else {
$curl = 0;
$curl = '0';
}
return $curl;
}
@@ -1704,11 +1718,14 @@ class Misc
/**
* Strip HTML comments
*
* @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.
* @param string $data Data to strip comments from
* @return string Comment stripped string
*/
public static function strip_comments($data)
public static function strip_comments(string $data)
{
// trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.9.'), \E_USER_DEPRECATED);
$output = '';
while (($start = strpos($data, '<!--')) !== false) {
$output .= substr($data, 0, $start);
@@ -1721,7 +1738,10 @@ class Misc
return $output . $data;
}
public static function parse_date($dt)
/**
* @return int|false
*/
public static function parse_date(string $dt)
{
$parser = \SimplePie\Parse\Date::get();
return $parser->parse($dt);
@@ -1734,7 +1754,7 @@ class Misc
* @param string $data Input data
* @return string Output data
*/
public static function entities_decode($data)
public static function entities_decode(string $data)
{
// trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.3, use "DOMDocument" instead.'), \E_USER_DEPRECATED);
@@ -1745,12 +1765,14 @@ class Misc
/**
* Remove RFC822 comments
*
* @param string $data Data to strip comments from
* @deprecated since SimplePie 1.9.0. If you need it, consider copying the function to your codebase.
* @param string $string Data to strip comments from
* @return string Comment stripped string
*/
public static function uncomment_rfc822($string)
public static function uncomment_rfc822(string $string)
{
$string = (string) $string;
// trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.9.'), \E_USER_DEPRECATED);
$position = 0;
$length = strlen($string);
$depth = 0;
@@ -1791,7 +1813,10 @@ class Misc
return $output;
}
public static function parse_mime($mime)
/**
* @return string
*/
public static function parse_mime(string $mime)
{
if (($pos = strpos($mime, ';')) === false) {
return trim($mime);
@@ -1800,7 +1825,11 @@ class Misc
return trim(substr($mime, 0, $pos));
}
public static function atom_03_construct_type($attribs)
/**
* @param array<string, array<string, string>> $attribs
* @return int-mask-of<SimplePie::CONSTRUCT_*>
*/
public static function atom_03_construct_type(array $attribs)
{
if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode'])) === 'base64') {
$mode = \SimplePie\SimplePie::CONSTRUCT_BASE64;
@@ -1829,7 +1858,11 @@ class Misc
return \SimplePie\SimplePie::CONSTRUCT_TEXT | $mode;
}
public static function atom_10_construct_type($attribs)
/**
* @param array<string, array<string, string>> $attribs
* @return int-mask-of<SimplePie::CONSTRUCT_*>
*/
public static function atom_10_construct_type(array $attribs)
{
if (isset($attribs['']['type'])) {
switch (strtolower(trim($attribs['']['type']))) {
@@ -1849,7 +1882,11 @@ class Misc
return \SimplePie\SimplePie::CONSTRUCT_TEXT;
}
public static function atom_10_content_construct_type($attribs)
/**
* @param array<string, array<string, string>> $attribs
* @return int-mask-of<SimplePie::CONSTRUCT_*>
*/
public static function atom_10_content_construct_type(array $attribs)
{
if (isset($attribs['']['type'])) {
$type = strtolower(trim($attribs['']['type']));
@@ -1873,12 +1910,18 @@ class Misc
return \SimplePie\SimplePie::CONSTRUCT_TEXT;
}
public static function is_isegment_nz_nc($string)
/**
* @return bool
*/
public static function is_isegment_nz_nc(string $string)
{
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);
}
public static function space_separated_tokens($string)
/**
* @return string[]
*/
public static function space_separated_tokens(string $string)
{
$space_characters = "\x20\x09\x0A\x0B\x0C\x0D";
$string_length = strlen($string);
@@ -1901,11 +1944,10 @@ class Misc
*
* @static
* @param int $codepoint Unicode codepoint
* @return string UTF-8 character
* @return string|false UTF-8 character
*/
public static function codepoint_to_utf8($codepoint)
public static function codepoint_to_utf8(int $codepoint)
{
$codepoint = (int) $codepoint;
if ($codepoint < 0) {
return false;
} elseif ($codepoint <= 0x7f) {
@@ -1928,12 +1970,15 @@ class Misc
* Returns an associative array of name/value pairs, where the value is an
* array of values that have used the same name
*
* @deprecated since SimplePie 1.9.0. If you need it, consider copying the function to your codebase.
* @static
* @param string $str The input string.
* @return array
* @return array<string, array<string|null>>
*/
public static function parse_str($str)
public static function parse_str(string $str)
{
// trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.9.'), \E_USER_DEPRECATED);
$return = [];
$str = explode('&', $str);
@@ -1955,9 +2000,9 @@ class Misc
* @todo Add support for EBCDIC
* @param string $data XML data
* @param \SimplePie\Registry $registry Class registry
* @return array Possible encodings
* @return array<string> Possible encodings
*/
public static function xml_encoding($data, $registry)
public static function xml_encoding(string $data, \SimplePie\Registry $registry)
{
// UTF-32 Big Endian BOM
if (substr($data, 0, 4) === "\x00\x00\xFE\xFF") {
@@ -2036,6 +2081,9 @@ class Misc
return $encoding;
}
/**
* @return void
*/
public static function output_javascript()
{
if (function_exists('ob_gzhandler')) {
@@ -2045,7 +2093,7 @@ class Misc
header('Cache-Control: must-revalidate');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
$body = <<<END
$body = <<<JS
function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
if (placeholder != '') {
document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="false" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
@@ -2066,7 +2114,7 @@ function embed_flv(width, height, link, placeholder, loop, player) {
function embed_wmedia(width, height, link) {
document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
}
END;
JS;
echo $body;
}
@@ -2075,37 +2123,36 @@ END;
*
* Uses the git index if it exists, otherwise uses the modification time
* of the newest file.
*
* @return int
*/
public static function get_build()
{
if (static::$SIMPLEPIE_BUILD !== null) {
return static::$SIMPLEPIE_BUILD;
if (self::$SIMPLEPIE_BUILD !== null) {
return self::$SIMPLEPIE_BUILD;
}
$root = dirname(__FILE__, 2);
if (file_exists($root . '/.git/index')) {
static::$SIMPLEPIE_BUILD = filemtime($root . '/.git/index');
self::$SIMPLEPIE_BUILD = (int) filemtime($root . '/.git/index');
return static::$SIMPLEPIE_BUILD;
} elseif (file_exists($root . '/SimplePie')) {
return self::$SIMPLEPIE_BUILD;
} elseif (file_exists($root . '/src')) {
$time = 0;
foreach (glob($root . '/SimplePie/*.php') as $file) {
foreach (glob($root . '/src/*.php') ?: [] as $file) {
if (($mtime = filemtime($file)) > $time) {
$time = $mtime;
}
}
static::$SIMPLEPIE_BUILD = $time;
return static::$SIMPLEPIE_BUILD;
} elseif (file_exists(dirname(__FILE__) . '/Core.php')) {
static::$SIMPLEPIE_BUILD = filemtime(dirname(__FILE__) . '/Core.php');
self::$SIMPLEPIE_BUILD = $time;
return static::$SIMPLEPIE_BUILD;
return self::$SIMPLEPIE_BUILD;
}
static::$SIMPLEPIE_BUILD = filemtime(__FILE__);
self::$SIMPLEPIE_BUILD = (int) filemtime(__FILE__);
return static::$SIMPLEPIE_BUILD;
return self::$SIMPLEPIE_BUILD;
}
/**
@@ -2120,13 +2167,16 @@ END;
/**
* Format debugging information
*
* @return string
*/
public static function debug(&$sp)
public static function debug(SimplePie &$sp)
{
$info = 'SimplePie ' . \SimplePie\SimplePie::VERSION . ' Build ' . static::get_build() . "\n";
$info .= 'PHP ' . PHP_VERSION . "\n";
if ($sp->error() !== null) {
$info .= 'Error occurred: ' . $sp->error() . "\n";
// TODO: Remove cast with multifeeds.
$info .= 'Error occurred: ' . implode(', ', (array) $sp->error()) . "\n";
} else {
$info .= "No error found.\n";
}
@@ -2140,12 +2190,9 @@ END;
$info .= ' Version ' . PCRE_VERSION . "\n";
break;
case 'curl':
$version = curl_version();
$version = (array) curl_version();
$info .= ' Version ' . $version['version'] . "\n";
break;
case 'mbstring':
$info .= ' Overloading: ' . mb_get_info('func_overload') . "\n";
break;
case 'iconv':
$info .= ' Version ' . ICONV_VERSION . "\n";
break;
@@ -2160,9 +2207,13 @@ END;
return $info;
}
public static function silence_errors($num, $str)
/**
* @return bool
*/
public static function silence_errors(int $num, string $str)
{
// No-op
return true;
}
/**
@@ -2170,9 +2221,12 @@ END;
* @param string $url the URL to sanitize.
* @return string the same URL without HTTP credentials.
*/
public static function url_remove_credentials($url)
public static function url_remove_credentials(string $url)
{
return preg_replace('#^(https?://)[^/:@]+:[^/:@]+@#i', '$1', $url);
// Cast for PHPStan: I do not think this can fail.
// The regex is valid and there should be no backtracking.
// https://github.com/phpstan/phpstan/issues/11547
return (string) preg_replace('#^(https?://)[^/:@]+:[^/:@]+@#i', '$1', $url);
}
}

View File

@@ -1,54 +1,15 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\Net;
/**
* Class to validate and to work with IPv6 addresses.
*
* @package SimplePie
* @subpackage HTTP
* @copyright 2003-2005 The PHP Group
* @license http://www.opensource.org/licenses/bsd-license.php
* @link http://pear.php.net/package/Net_IPv6
@@ -62,7 +23,7 @@ class IPv6
/**
* Uncompresses an IPv6 address
*
* RFC 4291 allows you to compress concecutive zero pieces in an address to
* RFC 4291 allows you to compress consecutive zero pieces in an address to
* '::'. This method expects a valid IPv6 address and expands the '::' to
* the required number of zero pieces.
*
@@ -77,7 +38,7 @@ class IPv6
* @param string $ip An IPv6 address
* @return string The uncompressed IPv6 address
*/
public static function uncompress($ip)
public static function uncompress(string $ip)
{
$c1 = -1;
$c2 = -1;
@@ -122,7 +83,7 @@ class IPv6
/**
* Compresses an IPv6 address
*
* RFC 4291 allows you to compress concecutive zero pieces in an address to
* RFC 4291 allows you to compress consecutive zero pieces in an address to
* '::'. This method expects a valid IPv6 address and compresses consecutive
* zero pieces to '::'.
*
@@ -133,14 +94,14 @@ class IPv6
* @param string $ip An IPv6 address
* @return string The compressed IPv6 address
*/
public static function compress($ip)
public static function compress(string $ip)
{
// Prepare the IP to be compressed
$ip = self::uncompress($ip);
$ip_parts = self::split_v6_v4($ip);
// Replace all leading zeros
$ip_parts[0] = preg_replace('/(^|:)0+([0-9])/', '\1\2', $ip_parts[0]);
$ip_parts[0] = (string) preg_replace('/(^|:)0+([0-9])/', '\1\2', $ip_parts[0]);
// Find bunches of zeros
if (preg_match_all('/(?:^|:)(?:0(?::|$))+/', $ip_parts[0], $matches, PREG_OFFSET_CAPTURE)) {
@@ -153,6 +114,7 @@ class IPv6
}
}
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.');
$ip_parts[0] = substr_replace($ip_parts[0], '::', $pos, $max);
}
@@ -173,12 +135,13 @@ class IPv6
* 0:0:0:0:0:FFFF:129.144.52.38
*
* @param string $ip An IPv6 address
* @return array [0] contains the IPv6 represented part, and [1] the IPv4 represented part
* @return array{string, string} [0] contains the IPv6 represented part, and [1] the IPv4 represented part
*/
private static function split_v6_v4($ip)
private static function split_v6_v4(string $ip): array
{
if (strpos($ip, '.') !== false) {
$pos = strrpos($ip, ':');
assert($pos !== false, 'For PHPStan: IPv6 address must contain colon, since split_v6_v4 is only ever called after uncompress.');
$ipv6_part = substr($ip, 0, $pos);
$ipv4_part = substr($ip, $pos + 1);
return [$ipv6_part, $ipv4_part];
@@ -195,7 +158,7 @@ class IPv6
* @param string $ip An IPv6 address
* @return bool true if $ip is a valid IPv6 address
*/
public static function check_ipv6($ip)
public static function check_ipv6(string $ip)
{
$ip = self::uncompress($ip);
[$ipv6, $ipv4] = self::split_v6_v4($ip);
@@ -221,7 +184,11 @@ class IPv6
// Check the value is valid
$value = hexdec($ipv6_part);
if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF) {
if ($value < 0 || $value > 0xFFFF) {
return false;
}
assert(is_int($value), 'For PHPStan: $value is only float when $ipv6_part > PHP_INT_MAX');
if (dechex($value) !== strtolower($ipv6_part)) {
return false;
}
}
@@ -248,7 +215,7 @@ class IPv6
* @param string $ip An IPv6 address
* @return bool true if $ip is a valid IPv6 address
*/
public static function checkIPv6($ip)
public static function checkIPv6(string $ip)
{
return self::check_ipv6($ip);
}

View File

@@ -1,54 +1,14 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\Parse;
/**
* Date Parser
*
* @package SimplePie
* @subpackage Parsing
*/
class Date
{
@@ -64,7 +24,7 @@ class Date
* List of days, calendar day name => ordinal day number in the week
*
* @access protected
* @var array
* @var array<string, int<1,7>>
*/
public $day = [
// English
@@ -169,7 +129,7 @@ class Date
* List of months, calendar month name => calendar month number
*
* @access protected
* @var array
* @var array<string, int<1,12>>
*/
public $month = [
// English
@@ -201,15 +161,15 @@ class Date
'januari' => 1,
'februari' => 2,
'maart' => 3,
'april' => 4,
// 'april' => 4,
'mei' => 5,
'juni' => 6,
'juli' => 7,
'augustus' => 8,
'september' => 9,
// 'september' => 9,
'oktober' => 10,
'november' => 11,
'december' => 12,
// 'november' => 11,
// 'december' => 12,
// French
'janvier' => 1,
'février' => 2,
@@ -225,26 +185,26 @@ class Date
'décembre' => 12,
// German
'januar' => 1,
'jan' => 1,
// 'jan' => 1,
'februar' => 2,
'feb' => 2,
// 'feb' => 2,
'märz' => 3,
'mär' => 3,
'april' => 4,
'apr' => 4,
'mai' => 5, // no short form for may
'juni' => 6,
'jun' => 6,
'juli' => 7,
'jul' => 7,
'august' => 8,
'aug' => 8,
'september' => 9,
'sep' => 9,
'oktober' => 10,
// 'april' => 4,
// 'apr' => 4,
// 'mai' => 5, // no short form for may
// 'juni' => 6,
// 'jun' => 6,
// 'juli' => 7,
// 'jul' => 7,
// 'august' => 8,
// 'aug' => 8,
// 'september' => 9,
// 'sep' => 9,
// 'oktober' => 10,
'okt' => 10,
'november' => 11,
'nov' => 11,
// 'november' => 11,
// 'nov' => 11,
'dezember' => 12,
'dez' => 12,
// Italian
@@ -258,17 +218,17 @@ class Date
'agosto' => 8,
'settembre' => 9,
'ottobre' => 10,
'novembre' => 11,
// 'novembre' => 11,
'dicembre' => 12,
// Spanish
'enero' => 1,
'febrero' => 2,
'marzo' => 3,
// 'marzo' => 3,
'abril' => 4,
'mayo' => 5,
'junio' => 6,
'julio' => 7,
'agosto' => 8,
// 'agosto' => 8,
'septiembre' => 9,
'setiembre' => 9,
'octubre' => 10,
@@ -298,8 +258,8 @@ class Date
'augusztus' => 8,
'szeptember' => 9,
'október' => 10,
'november' => 11,
'december' => 12,
// 'november' => 11,
// 'december' => 12,
// Greek
'Ιαν' => 1,
'Φεβ' => 2,
@@ -351,7 +311,7 @@ class Date
* List of timezones, abbreviation => offset from UTC
*
* @access protected
* @var array
* @var array<string, int>
*/
public $timezone = [
'ACDT' => 37800,
@@ -422,7 +382,7 @@ class Date
'GILT' => 43200,
'GIT' => -32400,
'GST' => 14400,
'GST' => -7200,
// 'GST' => -7200,
'GYT' => -14400,
'HAA' => -10800,
'HAC' => -18000,
@@ -576,7 +536,7 @@ class Date
* Array of user-added callback methods
*
* @access private
* @var array
* @var array<string>
*/
public $built_in = [];
@@ -584,7 +544,7 @@ class Date
* Array of user-added callback methods
*
* @access private
* @var array
* @var array<callable(string): (int|false)>
*/
public $user = [];
@@ -619,6 +579,7 @@ class Date
* Get the object
*
* @access public
* @return Date
*/
public static function get()
{
@@ -635,18 +596,21 @@ class Date
* @final
* @access public
* @param string $date Date to parse
* @return int Timestamp corresponding to date string, or false on failure
* @return int|false Timestamp corresponding to date string, or false on failure
*/
public function parse($date)
public function parse(string $date)
{
foreach ($this->user as $method) {
if (($returned = call_user_func($method, $date)) !== false) {
return $returned;
return (int) $returned;
}
}
foreach ($this->built_in as $method) {
if (($returned = call_user_func([$this, $method], $date)) !== false) {
// TODO: we should really check this in constructor but that would require private properties.
/** @var callable(string): (int|false) */
$callable = [$this, $method];
if (($returned = call_user_func($callable, $date)) !== false) {
return $returned;
}
}
@@ -660,14 +624,11 @@ class Date
* @final
* @access public
* @param callable $callback
* @return void
*/
public function add_callback($callback)
public function add_callback(callable $callback)
{
if (is_callable($callback)) {
$this->user[] = $callback;
} else {
trigger_error('User-supplied function must be a valid callback', E_USER_WARNING);
}
$this->user[] = $callback;
}
/**
@@ -676,9 +637,10 @@ class Date
* spaces to be used as the time separator (including more than one))
*
* @access protected
* @return int Timestamp
* @param string $date
* @return int|false Timestamp
*/
public function date_w3cdtf($date)
public function date_w3cdtf(string $date)
{
$pcre = <<<'PCRE'
/
@@ -749,12 +711,11 @@ PCRE;
* Remove RFC822 comments
*
* @access protected
* @param string $data Data to strip comments from
* @param string $string Data to strip comments from
* @return string Comment stripped string
*/
public function remove_rfc2822_comments($string)
public function remove_rfc2822_comments(string $string)
{
$string = (string) $string;
$position = 0;
$length = strlen($string);
$depth = 0;
@@ -799,9 +760,10 @@ PCRE;
* Parse RFC2822's date format
*
* @access protected
* @return int Timestamp
* @param string $date
* @return int|false Timestamp
*/
public function date_rfc2822($date)
public function date_rfc2822(string $date)
{
static $pcre;
if (!$pcre) {
@@ -834,20 +796,31 @@ PCRE;
11: Alphabetic timezone
*/
$day = (int) $match[2];
// Find the month number
$month = $this->month[strtolower($match[3])];
$year = (int) $match[4];
$hour = (int) $match[5];
$minute = (int) $match[6];
// Second is optional, if it is empty set it to zero
$second = (int) $match[7];
$tz_sign = $match[8];
$tz_hour = (int) $match[9];
$tz_minute = (int) $match[10];
$tz_code = isset($match[11]) ? strtoupper($match[11]) : '';
// Numeric timezone
if ($match[8] !== '') {
$timezone = $match[9] * 3600;
$timezone += $match[10] * 60;
if ($match[8] === '-') {
if ($tz_sign !== '') {
$timezone = $tz_hour * 3600;
$timezone += $tz_minute * 60;
if ($tz_sign === '-') {
$timezone = 0 - $timezone;
}
}
// Character timezone
elseif (isset($this->timezone[strtoupper($match[11])])) {
$timezone = $this->timezone[strtoupper($match[11])];
elseif (isset($this->timezone[$tz_code])) {
$timezone = $this->timezone[$tz_code];
}
// Assume everything else to be -0000
else {
@@ -855,20 +828,13 @@ PCRE;
}
// Deal with 2/3 digit years
if ($match[4] < 50) {
$match[4] += 2000;
} elseif ($match[4] < 1000) {
$match[4] += 1900;
if ($year < 50) {
$year += 2000;
} elseif ($year < 1000) {
$year += 1900;
}
// Second is optional, if it is empty set it to zero
if ($match[7] !== '') {
$second = $match[7];
} else {
$second = 0;
}
return gmmktime(intval($match[5]), intval($match[6]), intval($second), intval($month), intval($match[2]), intval($match[4])) - $timezone;
return gmmktime($hour, $minute, $second, $month, $day, $year) - $timezone;
}
return false;
@@ -878,9 +844,10 @@ PCRE;
* Parse RFC850's date format
*
* @access protected
* @return int Timestamp
* @param string $date
* @return int|false Timestamp
*/
public function date_rfc850($date)
public function date_rfc850(string $date)
{
static $pcre;
if (!$pcre) {
@@ -905,12 +872,20 @@ PCRE;
8: Timezone
*/
$day = (int) $match[2];
// Month
$month = $this->month[strtolower($match[3])];
$year = (int) $match[4];
$hour = (int) $match[5];
$minute = (int) $match[6];
// Second is optional, if it is empty set it to zero
$second = (int) $match[7];
$tz_code = strtoupper($match[8]);
// Character timezone
if (isset($this->timezone[strtoupper($match[8])])) {
$timezone = $this->timezone[strtoupper($match[8])];
if (isset($this->timezone[$tz_code])) {
$timezone = $this->timezone[$tz_code];
}
// Assume everything else to be -0000
else {
@@ -918,13 +893,13 @@ PCRE;
}
// Deal with 2 digit year
if ($match[4] < 50) {
$match[4] += 2000;
if ($year < 50) {
$year += 2000;
} else {
$match[4] += 1900;
$year += 1900;
}
return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone;
return gmmktime($hour, $minute, $second, $month, $day, $year) - $timezone;
}
return false;
@@ -934,9 +909,10 @@ PCRE;
* Parse C99's asctime()'s date format
*
* @access protected
* @return int Timestamp
* @param string $date
* @return int|false Timestamp
*/
public function date_asctime($date)
public function date_asctime(string $date)
{
static $pcre;
if (!$pcre) {
@@ -972,9 +948,10 @@ PCRE;
* Parse dates using strtotime()
*
* @access protected
* @return int Timestamp
* @param string $date
* @return int|false Timestamp
*/
public function date_strtotime($date)
public function date_strtotime(string $date)
{
$strtotime = strtotime($date);
if ($strtotime === -1 || $strtotime === false) {

File diff suppressed because one or more lines are too long

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
@@ -50,16 +13,13 @@ namespace SimplePie;
* Used by {@see \SimplePie\Enclosure::get_rating()} and {@see \SimplePie\Enclosure::get_ratings()}
*
* This class can be overloaded with {@see \SimplePie\SimplePie::set_rating_class()}
*
* @package SimplePie
* @subpackage API
*/
class Rating
{
/**
* Rating scheme
*
* @var string
* @var ?string
* @see get_scheme()
*/
public $scheme;
@@ -67,7 +27,7 @@ class Rating
/**
* Rating value
*
* @var string
* @var ?string
* @see get_value()
*/
public $value;
@@ -78,8 +38,10 @@ class Rating
* For documentation on all the parameters, see the corresponding
* properties and their accessors
*/
public function __construct($scheme = null, $value = null)
{
public function __construct(
?string $scheme = null,
?string $value = null
) {
$this->scheme = $scheme;
$this->value = $value;
}

View File

@@ -1,49 +1,13 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
use InvalidArgumentException;
use SimplePie\Content\Type\Sniffer;
use SimplePie\Parse\Date;
use SimplePie\XML\Declaration\Parser as DeclarationParser;
@@ -52,8 +16,6 @@ use SimplePie\XML\Declaration\Parser as DeclarationParser;
* Handles creating objects and calling methods
*
* Access this via {@see \SimplePie\SimplePie::get_registry()}
*
* @package SimplePie
*/
class Registry
{
@@ -90,7 +52,7 @@ class Registry
* Class mapping
*
* @see register()
* @var array
* @var array<string, class-string>
*/
protected $classes = [];
@@ -147,7 +109,7 @@ class Registry
* @param bool $legacy Whether to enable legacy support for this class
* @return bool Successfulness
*/
public function register($type, $class, $legacy = false)
public function register(string $type, $class, bool $legacy = false)
{
if (array_key_exists($type, $this->legacyTypes)) {
// trigger_error(sprintf('"%s"(): Using argument #1 ($type) with value "%s" is deprecated since SimplePie 1.8.0, use class-string "%s" instead.', __METHOD__, $type, $this->legacyTypes[$type]), \E_USER_DEPRECATED);
@@ -200,9 +162,13 @@ class Registry
return null;
}
// For PHPStan: values in $default should be subtypes of keys.
/** @var class-string<T> */
$class = $this->default[$type];
if (array_key_exists($type, $this->classes)) {
// For PHPStan: values in $classes should be subtypes of keys.
/** @var class-string<T> */
$class = $this->classes[$type];
}
@@ -214,17 +180,26 @@ class Registry
*
* @template T class-string $type
* @param class-string<T> $type
* @param array $parameters Parameters to pass to the constructor
* @param array<mixed> $parameters Parameters to pass to the constructor
* @return T Instance of class
*/
public function &create($type, $parameters = [])
public function &create($type, array $parameters = [])
{
$class = $this->get_class($type);
if ($class === null) {
throw new InvalidArgumentException(sprintf(
'%s(): Argument #1 ($type) "%s" not found in class list.',
__METHOD__,
$type
), 1);
}
if (!method_exists($class, '__construct')) {
$instance = new $class();
} else {
$reflector = new \ReflectionClass($class);
// For PHPStan: $class is T.
/** @var T */
$instance = $reflector->newInstanceArgs($parameters);
}
@@ -234,6 +209,7 @@ class Registry
trigger_error(sprintf('Using the method "set_registry()" without implementing "%s" is deprecated since SimplePie 1.8.0, implement "%s" in "%s".', RegistryAware::class, RegistryAware::class, $class), \E_USER_DEPRECATED);
$instance->set_registry($this);
}
return $instance;
}
@@ -242,12 +218,19 @@ class Registry
*
* @param class-string $type
* @param string $method
* @param array $parameters
* @param array<mixed> $parameters
* @return mixed
*/
public function &call($type, $method, $parameters = [])
public function &call($type, string $method, array $parameters = [])
{
$class = $this->get_class($type);
if ($class === null) {
throw new InvalidArgumentException(sprintf(
'%s(): Argument #1 ($type) "%s" not found in class list.',
__METHOD__,
$type
), 1);
}
if (in_array($class, $this->legacy)) {
switch ($type) {
@@ -256,6 +239,8 @@ class Registry
// Cache::create() methods in PHP < 8.0.
// No longer supported as of PHP 8.0.
if ($method === 'get_handler') {
// Fixing this PHPStan error breaks CacheTest::testDirectOverrideLegacy()
/** @phpstan-ignore argument.type */
$result = @call_user_func_array([$class, 'create'], $parameters);
return $result;
}
@@ -263,7 +248,9 @@ class Registry
}
}
$result = call_user_func_array([$class, $method], $parameters);
$callable = [$class, $method];
assert(is_callable($callable), 'For PHPstan');
$result = call_user_func_array($callable, $parameters);
return $result;
}
}

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2022 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
@@ -48,17 +11,13 @@ namespace SimplePie;
* Handles the injection of Registry into other class
*
* {@see \SimplePie\SimplePie::get_registry()}
*
* @package SimplePie
*/
interface RegistryAware
{
/**
* Set the Registry into the class
*
* @param Registry $registry
*
* @return void
*/
public function set_registry(Registry $registry)/* : void */;
public function set_registry(Registry $registry);
}

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
@@ -50,16 +13,16 @@ namespace SimplePie;
* Used by {@see \SimplePie\Enclosure::get_restriction()} and {@see \SimplePie\Enclosure::get_restrictions()}
*
* This class can be overloaded with {@see \SimplePie\SimplePie::set_restriction_class()}
*
* @package SimplePie
* @subpackage API
*/
class Restriction
{
public const RELATIONSHIP_ALLOW = 'allow';
public const RELATIONSHIP_DENY = 'deny';
/**
* Relationship ('allow'/'deny')
*
* @var string
* @var self::RELATIONSHIP_*|null
* @see get_relationship()
*/
public $relationship;
@@ -67,7 +30,7 @@ class Restriction
/**
* Type of restriction
*
* @var string
* @var string|null
* @see get_type()
*/
public $type;
@@ -75,7 +38,7 @@ class Restriction
/**
* Restricted values
*
* @var string
* @var string|null
* @see get_value()
*/
public $value;
@@ -85,8 +48,10 @@ class Restriction
*
* For documentation on all the parameters, see the corresponding
* properties and their accessors
*
* @param ?self::RELATIONSHIP_* $relationship
*/
public function __construct($relationship = null, $type = null, $value = null)
public function __construct(?string $relationship = null, ?string $type = null, ?string $value = null)
{
$this->relationship = $relationship;
$this->type = $type;
@@ -107,7 +72,7 @@ class Restriction
/**
* Get the relationship
*
* @return string|null Either 'allow' or 'deny'
* @return ?self::RELATIONSHIP_*
*/
public function get_relationship()
{

View File

@@ -1,55 +1,27 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
use DOMDocument;
use DOMXPath;
use InvalidArgumentException;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;
use SimplePie\Cache\Base;
use SimplePie\Cache\BaseDataCache;
use SimplePie\Cache\CallableNameFilter;
use SimplePie\Cache\DataCache;
use SimplePie\Cache\NameFilter;
use SimplePie\HTTP\Client;
use SimplePie\HTTP\ClientException;
use SimplePie\HTTP\FileClient;
use SimplePie\HTTP\Psr18Client;
/**
* Used for data cleanup and post-processing
@@ -57,36 +29,59 @@ use SimplePie\Cache\NameFilter;
*
* This class can be overloaded with {@see \SimplePie\SimplePie::set_sanitize_class()}
*
* @package SimplePie
* @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
*/
class Sanitize implements RegistryAware
{
// Private vars
public $base;
/** @var string */
public $base = '';
// Options
/** @var bool */
public $remove_div = true;
/** @var string */
public $image_handler = '';
/** @var string[] */
public $strip_htmltags = ['base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'];
/** @var bool */
public $encode_instead_of_strip = false;
/** @var string[] */
public $strip_attributes = ['bgsound', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'];
/** @var string[] */
public $rename_attributes = [];
/** @var array<string, array<string, string>> */
public $add_attributes = ['audio' => ['preload' => 'none'], 'iframe' => ['sandbox' => 'allow-scripts allow-same-origin'], 'video' => ['preload' => 'none']];
/** @var bool */
public $strip_comments = false;
/** @var string */
public $output_encoding = 'UTF-8';
/** @var bool */
public $enable_cache = true;
/** @var string */
public $cache_location = './cache';
/** @var string&(callable(string): string) */
public $cache_name_function = 'md5';
/**
* @var NameFilter
*/
private $cache_namefilter;
/** @var int */
public $timeout = 10;
/** @var string */
public $useragent = '';
/** @var bool */
public $force_fsockopen = false;
public $replace_url_attributes = null;
/** @var array<string, string|string[]> */
public $replace_url_attributes = [];
/**
* @var array<int, mixed> Custom curl options
* @see SimplePie::set_curl_options()
*/
private $curl_options = [];
/** @var Registry */
public $registry;
/**
@@ -104,45 +99,65 @@ class Sanitize implements RegistryAware
* @see \SimplePie\Sanitize::set_https_domains()
* Array is a tree split at DNS levels. Example:
* array('biz' => true, 'com' => array('example' => true), 'net' => array('example' => array('www' => true)))
* @var true|array<string, true|array<string, true|array<string, array<string, true|array<string, true|array<string, true>>>>>>
*/
public $https_domains = [];
/**
* @var Client|null
*/
private $http_client = null;
public function __construct()
{
// Set defaults
$this->set_url_replacements(null);
}
public function remove_div($enable = true)
/**
* @return void
*/
public function remove_div(bool $enable = true)
{
$this->remove_div = (bool) $enable;
}
/**
* @param string|false $page
* @return void
*/
public function set_image_handler($page = false)
{
if ($page) {
$this->image_handler = (string) $page;
} else {
$this->image_handler = false;
$this->image_handler = '';
}
}
public function set_registry(\SimplePie\Registry $registry)/* : void */
/**
* @return void
*/
public function set_registry(\SimplePie\Registry $registry)
{
$this->registry = $registry;
}
public function pass_cache_data($enable_cache = true, $cache_location = './cache', $cache_name_function = 'md5', $cache_class = 'SimplePie\Cache', ?DataCache $cache = null)
/**
* @param (string&(callable(string): string))|NameFilter $cache_name_function
* @param class-string<Cache> $cache_class
* @return void
*/
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)
{
if (isset($enable_cache)) {
$this->enable_cache = (bool) $enable_cache;
}
$this->enable_cache = $enable_cache;
if ($cache_location) {
$this->cache_location = (string) $cache_location;
$this->cache_location = $cache_location;
}
if (!is_string($cache_name_function) && !is_object($cache_name_function) && !$cache_name_function instanceof NameFilter) {
// @phpstan-ignore-next-line Enforce PHPDoc type.
if (!is_string($cache_name_function) && !$cache_name_function instanceof NameFilter) {
throw new InvalidArgumentException(sprintf(
'%s(): Argument #3 ($cache_name_function) must be of type %s',
__METHOD__,
@@ -153,7 +168,7 @@ class Sanitize implements RegistryAware
// BC: $cache_name_function could be a callable as string
if (is_string($cache_name_function)) {
// 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);
$this->cache_name_function = (string) $cache_name_function;
$this->cache_name_function = $cache_name_function;
$cache_name_function = new CallableNameFilter($cache_name_function);
}
@@ -165,21 +180,49 @@ class Sanitize implements RegistryAware
}
}
public function pass_file_data($file_class = 'SimplePie\File', $timeout = 10, $useragent = '', $force_fsockopen = false)
/**
* Set a PSR-18 client and PSR-17 factories
*
* Allows you to use your own HTTP client implementations.
*/
final public function set_http_client(
ClientInterface $http_client,
RequestFactoryInterface $request_factory,
UriFactoryInterface $uri_factory
): void {
$this->http_client = new Psr18Client($http_client, $request_factory, $uri_factory);
}
/**
* @deprecated since SimplePie 1.9.0, use \SimplePie\Sanitize::set_http_client() instead.
* @param class-string<File> $file_class
* @param array<int, mixed> $curl_options
* @return void
*/
public function pass_file_data(string $file_class = File::class, int $timeout = 10, string $useragent = '', bool $force_fsockopen = false, array $curl_options = [])
{
// 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);
if ($timeout) {
$this->timeout = (string) $timeout;
$this->timeout = $timeout;
}
if ($useragent) {
$this->useragent = (string) $useragent;
$this->useragent = $useragent;
}
if ($force_fsockopen) {
$this->force_fsockopen = (string) $force_fsockopen;
$this->force_fsockopen = $force_fsockopen;
}
$this->curl_options = $curl_options;
// Invalidate the registered client.
$this->http_client = null;
}
/**
* @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.
* @return void
*/
public function strip_htmltags($tags = ['base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'])
{
if ($tags) {
@@ -189,15 +232,22 @@ class Sanitize implements RegistryAware
$this->strip_htmltags = explode(',', $tags);
}
} else {
$this->strip_htmltags = false;
$this->strip_htmltags = [];
}
}
public function encode_instead_of_strip($encode = false)
/**
* @return void
*/
public function encode_instead_of_strip(bool $encode = false)
{
$this->encode_instead_of_strip = (bool) $encode;
$this->encode_instead_of_strip = $encode;
}
/**
* @param string[]|string $attribs
* @return void
*/
public function rename_attributes($attribs = [])
{
if ($attribs) {
@@ -207,10 +257,14 @@ class Sanitize implements RegistryAware
$this->rename_attributes = explode(',', $attribs);
}
} else {
$this->rename_attributes = false;
$this->rename_attributes = [];
}
}
/**
* @param string[]|string $attribs
* @return void
*/
public function strip_attributes($attribs = ['bgsound', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'])
{
if ($attribs) {
@@ -220,31 +274,33 @@ class Sanitize implements RegistryAware
$this->strip_attributes = explode(',', $attribs);
}
} else {
$this->strip_attributes = false;
$this->strip_attributes = [];
}
}
public function add_attributes($attribs = ['audio' => ['preload' => 'none'], 'iframe' => ['sandbox' => 'allow-scripts allow-same-origin'], 'video' => ['preload' => 'none']])
/**
* @param array<string, array<string, string>> $attribs
* @return void
*/
public function add_attributes(array $attribs = ['audio' => ['preload' => 'none'], 'iframe' => ['sandbox' => 'allow-scripts allow-same-origin'], 'video' => ['preload' => 'none']])
{
if ($attribs) {
if (is_array($attribs)) {
$this->add_attributes = $attribs;
} else {
$this->add_attributes = explode(',', $attribs);
}
} else {
$this->add_attributes = false;
}
$this->add_attributes = $attribs;
}
public function strip_comments($strip = false)
/**
* @return void
*/
public function strip_comments(bool $strip = false)
{
$this->strip_comments = (bool) $strip;
$this->strip_comments = $strip;
}
public function set_output_encoding($encoding = 'UTF-8')
/**
* @return void
*/
public function set_output_encoding(string $encoding = 'UTF-8')
{
$this->output_encoding = (string) $encoding;
$this->output_encoding = $encoding;
}
/**
@@ -256,9 +312,10 @@ class Sanitize implements RegistryAware
* |ins|@cite, |q|@cite, |source|@src, |video|@src
*
* @since 1.0
* @param array|null $element_attribute Element/attribute key/value pairs, null for default
* @param array<string, string|string[]>|null $element_attribute Element/attribute key/value pairs, null for default
* @return void
*/
public function set_url_replacements($element_attribute = null)
public function set_url_replacements(?array $element_attribute = null)
{
if ($element_attribute === null) {
$element_attribute = [
@@ -282,20 +339,25 @@ class Sanitize implements RegistryAware
]
];
}
$this->replace_url_attributes = (array) $element_attribute;
$this->replace_url_attributes = $element_attribute;
}
/**
* Set the list of domains for which to force HTTPS.
* @see \SimplePie\Misc::https_url()
* Example array('biz', 'example.com', 'example.org', 'www.example.net');
*
* @param string[] $domains list of domain names ['biz', 'example.com', 'example.org', 'www.example.net']
*
* @return void
*/
public function set_https_domains($domains)
public function set_https_domains(array $domains)
{
$this->https_domains = [];
foreach ($domains as $domain) {
$domain = trim($domain, ". \t\n\r\0\x0B");
$segments = array_reverse(explode('.', $domain));
/** @var true|array<string, true|array<string, true|array<string, array<string, true|array<string, true|array<string, true>>>>>> */ // Needed for PHPStan.
$node = &$this->https_domains;
foreach ($segments as $segment) {//Build a tree
if ($node === true) {
@@ -312,8 +374,10 @@ class Sanitize implements RegistryAware
/**
* Check if the domain is in the list of forced HTTPS.
*
* @return bool
*/
protected function is_https_domain($domain)
protected function is_https_domain(string $domain)
{
$domain = trim($domain, '. ');
$segments = array_reverse(explode('.', $domain));
@@ -330,16 +394,26 @@ class Sanitize implements RegistryAware
/**
* Force HTTPS for selected Web sites.
*
* @return string
*/
public function https_url($url)
public function https_url(string $url)
{
return (strtolower(substr($url, 0, 7)) === 'http://') &&
$this->is_https_domain(parse_url($url, PHP_URL_HOST)) ?
substr_replace($url, 's', 4, 0) : //Add the 's' to HTTPS
$url;
return (
strtolower(substr($url, 0, 7)) === 'http://'
&& ($parsed = parse_url($url, PHP_URL_HOST)) !== false // Malformed URL
&& $parsed !== null // Missing host
&& $this->is_https_domain($parsed) // Should be forced?
) ? substr_replace($url, 's', 4, 0) // Add the 's' to HTTPS
: $url;
}
public function sanitize($data, $type, $base = '')
/**
* @param int-mask-of<SimplePie::CONSTRUCT_*> $type
* @param string $base
* @return string Sanitized data; false if output encoding is changed to something other than UTF-8 and conversion fails
*/
public function sanitize(string $data, int $type, string $base = '')
{
$data = trim($data);
if ($data !== '' || $type & \SimplePie\SimplePie::CONSTRUCT_IRI) {
@@ -362,9 +436,13 @@ class Sanitize implements RegistryAware
$document = new \DOMDocument();
$document->encoding = 'UTF-8';
// PHPStan seems to have trouble resolving int-mask because bitwise
// operators are used when operators are used when passing this parameter.
// https://github.com/phpstan/phpstan/issues/9384
/** @var int-mask-of<SimplePie::CONSTRUCT_*> $type */
$data = $this->preprocess($data, $type);
set_error_handler(['SimplePie\Misc', 'silence_errors']);
set_error_handler([Misc::class, 'silence_errors']);
$document->loadHTML($data);
restore_error_handler();
@@ -372,16 +450,19 @@ class Sanitize implements RegistryAware
// Strip comments
if ($this->strip_comments) {
/** @var \DOMNodeList<\DOMComment> */
$comments = $xpath->query('//comment()');
foreach ($comments as $comment) {
$comment->parentNode->removeChild($comment);
$parentNode = $comment->parentNode;
assert($parentNode !== null, 'For PHPStan, comment must have a parent');
$parentNode->removeChild($comment);
}
}
// Strip out HTML tags and attributes that might cause various security problems.
// Based on recommendations by Mark Pilgrim at:
// http://diveintomark.org/archives/2003/06/12/how_to_consume_rss_safely
// https://web.archive.org/web/20110902041826/http://diveintomark.org:80/archives/2003/06/12/how_to_consume_rss_safely
if ($this->strip_htmltags) {
foreach ($this->strip_htmltags as $tag) {
$this->strip_tag($tag, $document, $xpath, $type);
@@ -413,7 +494,7 @@ class Sanitize implements RegistryAware
}
// If image handling (caching, etc.) is enabled, cache and rewrite all the image tags.
if (isset($this->image_handler) && ((string) $this->image_handler) !== '' && $this->enable_cache) {
if ($this->image_handler !== '' && $this->enable_cache) {
$images = $document->getElementsByTagName('img');
foreach ($images as $img) {
@@ -424,11 +505,18 @@ class Sanitize implements RegistryAware
if ($cache->get_data($image_url, false)) {
$img->setAttribute('src', $this->image_handler . $image_url);
} else {
$file = $this->registry->create(File::class, [$img->getAttribute('src'), $this->timeout, 5, ['X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']], $this->useragent, $this->force_fsockopen]);
$headers = $file->headers;
try {
$file = $this->get_http_client()->request(
Client::METHOD_GET,
$img->getAttribute('src'),
['X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']]
);
} catch (ClientException $th) {
continue;
}
if ($file->success && ($file->method & \SimplePie\SimplePie::FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) {
if ($cache->set_data($image_url, ['headers' => $file->headers, 'body' => $file->body], $this->cache_duration)) {
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))) {
if ($cache->set_data($image_url, ['headers' => $file->get_headers(), 'body' => $file->get_body_content()], $this->cache_duration)) {
$img->setAttribute('src', $this->image_handler . $image_url);
} else {
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);
@@ -440,18 +528,23 @@ class Sanitize implements RegistryAware
}
// Get content node
$div = $document->getElementsByTagName('body')->item(0)->firstChild;
$div = null;
if (($item = $document->getElementsByTagName('body')->item(0)) !== null) {
$div = $item->firstChild;
}
// Finally, convert to a HTML string
$data = trim($document->saveHTML($div));
$data = trim((string) $document->saveHTML($div));
if ($this->remove_div) {
$data = preg_replace('/^<div' . \SimplePie\SimplePie::PCRE_XML_ATTRIBUTE . '>/', '', $data);
$data = preg_replace('/<\/div>$/', '', $data);
// Cast for PHPStan, it is unable to validate a non-literal regex above.
$data = preg_replace('/<\/div>$/', '', (string) $data);
} else {
$data = preg_replace('/^<div' . \SimplePie\SimplePie::PCRE_XML_ATTRIBUTE . '>/', '<div>', $data);
}
$data = str_replace('</source>', '', $data);
// Cast for PHPStan, it is unable to validate a non-literal regex above.
$data = str_replace('</source>', '', (string) $data);
}
if ($type & \SimplePie\SimplePie::CONSTRUCT_IRI) {
@@ -466,13 +559,19 @@ class Sanitize implements RegistryAware
}
if ($this->output_encoding !== 'UTF-8') {
// This really returns string|false but changing encoding is uncommon and we are going to deprecate it, so lets just lie to PHPStan in the interest of cleaner annotations.
/** @var string */
$data = $this->registry->call(Misc::class, 'change_encoding', [$data, 'UTF-8', $this->output_encoding]);
}
}
return $data;
}
protected function preprocess($html, $type)
/**
* @param int-mask-of<SimplePie::CONSTRUCT_*> $type
* @return string
*/
protected function preprocess(string $html, int $type)
{
$ret = '';
$html = preg_replace('%</?(?:html|body)[^>]*?'.'>%is', '', $html);
@@ -493,7 +592,11 @@ class Sanitize implements RegistryAware
return $ret;
}
public function replace_urls($document, $tag, $attributes)
/**
* @param array<string>|string $attributes
* @return void
*/
public function replace_urls(DOMDocument $document, string $tag, $attributes)
{
if (!is_array($attributes)) {
$attributes = [$attributes];
@@ -515,7 +618,11 @@ class Sanitize implements RegistryAware
}
}
public function do_strip_htmltags($match)
/**
* @param array<int, string> $match
* @return string
*/
public function do_strip_htmltags(array $match)
{
if ($this->encode_instead_of_strip) {
if (isset($match[4]) && !in_array(strtolower($match[1]), ['script', 'style'])) {
@@ -532,9 +639,21 @@ class Sanitize implements RegistryAware
}
}
protected function strip_tag($tag, $document, $xpath, $type)
/**
* @param int-mask-of<SimplePie::CONSTRUCT_*> $type
* @return void
*/
protected function strip_tag(string $tag, DOMDocument $document, DOMXPath $xpath, int $type)
{
$elements = $xpath->query('body//' . $tag);
if ($elements === false) {
throw new \SimplePie\Exception(sprintf(
'%s(): Possibly malformed expression, check argument #1 ($tag)',
__METHOD__
), 1);
}
if ($this->encode_instead_of_strip) {
foreach ($elements as $element) {
$fragment = $document->createDocumentFragment();
@@ -542,7 +661,7 @@ class Sanitize implements RegistryAware
// For elements which aren't script or style, include the tag itself
if (!in_array($tag, ['script', 'style'])) {
$text = '<' . $tag;
if ($element->hasAttributes()) {
if ($element->attributes !== null) {
$attrs = [];
foreach ($element->attributes as $name => $attr) {
$value = $attr->value;
@@ -568,21 +687,26 @@ class Sanitize implements RegistryAware
$number = $element->childNodes->length;
for ($i = $number; $i > 0; $i--) {
$child = $element->childNodes->item(0);
$fragment->appendChild($child);
if (($child = $element->childNodes->item(0)) !== null) {
$fragment->appendChild($child);
}
}
if (!in_array($tag, ['script', 'style'])) {
$fragment->appendChild(new \DOMText('</' . $tag . '>'));
}
$element->parentNode->replaceChild($fragment, $element);
if (($parentNode = $element->parentNode) !== null) {
$parentNode->replaceChild($fragment, $element);
}
}
return;
} elseif (in_array($tag, ['script', 'style'])) {
foreach ($elements as $element) {
$element->parentNode->removeChild($element);
if (($parentNode = $element->parentNode) !== null) {
$parentNode->removeChild($element);
}
}
return;
@@ -591,37 +715,67 @@ class Sanitize implements RegistryAware
$fragment = $document->createDocumentFragment();
$number = $element->childNodes->length;
for ($i = $number; $i > 0; $i--) {
$child = $element->childNodes->item(0);
$fragment->appendChild($child);
if (($child = $element->childNodes->item(0)) !== null) {
$fragment->appendChild($child);
}
}
$element->parentNode->replaceChild($fragment, $element);
if (($parentNode = $element->parentNode) !== null) {
$parentNode->replaceChild($fragment, $element);
}
}
}
}
protected function strip_attr($attrib, $xpath)
/**
* @return void
*/
protected function strip_attr(string $attrib, DOMXPath $xpath)
{
$elements = $xpath->query('//*[@' . $attrib . ']');
if ($elements === false) {
throw new \SimplePie\Exception(sprintf(
'%s(): Possibly malformed expression, check argument #1 ($attrib)',
__METHOD__
), 1);
}
/** @var \DOMElement $element */
foreach ($elements as $element) {
$element->removeAttribute($attrib);
}
}
protected function rename_attr($attrib, $xpath)
/**
* @return void
*/
protected function rename_attr(string $attrib, DOMXPath $xpath)
{
$elements = $xpath->query('//*[@' . $attrib . ']');
if ($elements === false) {
throw new \SimplePie\Exception(sprintf(
'%s(): Possibly malformed expression, check argument #1 ($attrib)',
__METHOD__
), 1);
}
/** @var \DOMElement $element */
foreach ($elements as $element) {
$element->setAttribute('data-sanitized-' . $attrib, $element->getAttribute($attrib));
$element->removeAttribute($attrib);
}
}
protected function add_attr($tag, $valuePairs, $document)
/**
* @param array<string, string> $valuePairs
* @return void
*/
protected function add_attr(string $tag, array $valuePairs, DOMDocument $document)
{
$elements = $document->getElementsByTagName($tag);
/** @var \DOMElement $element */
foreach ($elements as $element) {
foreach ($valuePairs as $attrib => $value) {
$element->setAttribute($attrib, $value);
@@ -636,7 +790,7 @@ class Sanitize implements RegistryAware
*
* @return DataCache
*/
private function get_cache($image_url = '')
private function get_cache(string $image_url = ''): DataCache
{
if ($this->cache === null) {
// @trigger_error(sprintf('Not providing as PSR-16 cache implementation is deprecated since SimplePie 1.8.0, please use "SimplePie\SimplePie::set_cache()".'), \E_USER_DEPRECATED);
@@ -651,6 +805,27 @@ class Sanitize implements RegistryAware
return $this->cache;
}
/**
* Get a HTTP client
*/
private function get_http_client(): Client
{
if ($this->http_client === null) {
$this->http_client = new FileClient(
$this->registry,
[
'timeout' => $this->timeout,
'redirects' => 5,
'useragent' => $this->useragent,
'force_fsockopen' => $this->force_fsockopen,
'curl_options' => $this->curl_options,
]
);
}
return $this->http_client;
}
}
class_alias('SimplePie\Sanitize', 'SimplePie_Sanitize');

File diff suppressed because it is too large Load Diff

View File

@@ -1,46 +1,9 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie;
@@ -50,33 +13,47 @@ namespace SimplePie;
* Used by {@see \SimplePie\Item::get_source()}
*
* This class can be overloaded with {@see \SimplePie::set_source_class()}
*
* @package SimplePie
* @subpackage API
*/
class Source implements RegistryAware
{
/** @var Item */
public $item;
/** @var array<string, mixed> */
public $data = [];
/** @var Registry */
protected $registry;
public function __construct($item, $data)
/**
* @param array<string, mixed> $data
*/
public function __construct(Item $item, array $data)
{
$this->item = $item;
$this->data = $data;
}
public function set_registry(\SimplePie\Registry $registry)/* : void */
/**
* @return void
*/
public function set_registry(\SimplePie\Registry $registry)
{
$this->registry = $registry;
}
/**
* @return string
*/
public function __toString()
{
return md5(serialize($this->data));
}
public function get_source_tags($namespace, $tag)
/**
* @param string $namespace
* @param string $tag
* @return array<array<string, mixed>>|null
*/
public function get_source_tags(string $namespace, string $tag)
{
if (isset($this->data['child'][$namespace][$tag])) {
return $this->data['child'][$namespace][$tag];
@@ -85,21 +62,37 @@ class Source implements RegistryAware
return null;
}
public function get_base($element = [])
/**
* @param array<string, mixed> $element
* @return string
*/
public function get_base(array $element = [])
{
return $this->item->get_base($element);
}
public function sanitize($data, $type, $base = '')
/**
* @param string $data
* @param int-mask-of<SimplePie::CONSTRUCT_*> $type
* @param string $base
* @return string
*/
public function sanitize(string $data, $type, string $base = '')
{
return $this->item->sanitize($data, $type, $base);
}
/**
* @return Item
*/
public function get_item()
{
return $this->item;
}
/**
* @return string|null
*/
public function get_title()
{
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'title')) {
@@ -121,7 +114,11 @@ class Source implements RegistryAware
return null;
}
public function get_category($key = 0)
/**
* @param int $key
* @return Category|null
*/
public function get_category(int $key = 0)
{
$categories = $this->get_categories();
if (isset($categories[$key])) {
@@ -131,6 +128,9 @@ class Source implements RegistryAware
return null;
}
/**
* @return array<Category>|null
*/
public function get_categories()
{
$categories = [];
@@ -175,7 +175,11 @@ class Source implements RegistryAware
return null;
}
public function get_author($key = 0)
/**
* @param int $key
* @return Author|null
*/
public function get_author(int $key = 0)
{
$authors = $this->get_authors();
if (isset($authors[$key])) {
@@ -185,6 +189,9 @@ class Source implements RegistryAware
return null;
}
/**
* @return array<Author>|null
*/
public function get_authors()
{
$authors = [];
@@ -196,7 +203,8 @@ class Source implements RegistryAware
$name = $this->sanitize($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['name'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'])) {
$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]));
$uri = $author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0];
$uri = $this->sanitize($uri['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($uri));
}
if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'])) {
$email = $this->sanitize($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
@@ -213,7 +221,8 @@ class Source implements RegistryAware
$name = $this->sanitize($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['name'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'])) {
$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]));
$url = $author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0];
$url = $this->sanitize($url['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($url));
}
if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'])) {
$email = $this->sanitize($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
@@ -239,7 +248,11 @@ class Source implements RegistryAware
return null;
}
public function get_contributor($key = 0)
/**
* @param int $key
* @return Author|null
*/
public function get_contributor(int $key = 0)
{
$contributors = $this->get_contributors();
if (isset($contributors[$key])) {
@@ -249,6 +262,9 @@ class Source implements RegistryAware
return null;
}
/**
* @return array<Author>|null
*/
public function get_contributors()
{
$contributors = [];
@@ -260,7 +276,8 @@ class Source implements RegistryAware
$name = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['name'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'])) {
$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]));
$uri = $contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0];
$uri = $this->sanitize($uri['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($uri));
}
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'])) {
$email = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
@@ -277,7 +294,8 @@ class Source implements RegistryAware
$name = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['name'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'])) {
$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]));
$url = $contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0];
$url = $this->sanitize($url['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($url));
}
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'])) {
$email = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
@@ -294,7 +312,12 @@ class Source implements RegistryAware
return null;
}
public function get_link($key = 0, $rel = 'alternate')
/**
* @param int $key
* @param string $rel
* @return string|null
*/
public function get_link(int $key = 0, string $rel = 'alternate')
{
$links = $this->get_links($rel);
if (isset($links[$key])) {
@@ -306,13 +329,19 @@ class Source implements RegistryAware
/**
* Added for parity between the parent-level and the item/entry-level.
*
* @return string|null
*/
public function get_permalink()
{
return $this->get_link(0);
}
public function get_links($rel = 'alternate')
/**
* @param string $rel
* @return array<string>|null
*/
public function get_links(string $rel = 'alternate')
{
if (!isset($this->data['links'])) {
$this->data['links'] = [];
@@ -344,6 +373,8 @@ class Source implements RegistryAware
$keys = array_keys($this->data['links']);
foreach ($keys as $key) {
$key = (string) $key;
if ($this->registry->call(Misc::class, 'is_isegment_nz_nc', [$key])) {
if (isset($this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key])) {
$this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key]);
@@ -365,6 +396,9 @@ class Source implements RegistryAware
return null;
}
/**
* @return string|null
*/
public function get_description()
{
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'subtitle')) {
@@ -390,6 +424,9 @@ class Source implements RegistryAware
return null;
}
/**
* @return string|null
*/
public function get_copyright()
{
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'rights')) {
@@ -407,6 +444,9 @@ class Source implements RegistryAware
return null;
}
/**
* @return string|null
*/
public function get_language()
{
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'language')) {
@@ -422,6 +462,9 @@ class Source implements RegistryAware
return null;
}
/**
* @return float|null
*/
public function get_latitude()
{
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_W3C_BASIC_GEO, 'lat')) {
@@ -433,6 +476,9 @@ class Source implements RegistryAware
return null;
}
/**
* @return float|null
*/
public function get_longitude()
{
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_W3C_BASIC_GEO, 'long')) {
@@ -446,6 +492,9 @@ class Source implements RegistryAware
return null;
}
/**
* @return string|null
*/
public function get_image_url()
{
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'image')) {

View File

@@ -1,54 +1,14 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\XML\Declaration;
/**
* Parses the XML Declaration
*
* @package SimplePie
* @subpackage Parsing
*/
class Parser
{
@@ -138,7 +98,7 @@ class Parser
* @access public
* @param string $data Input data
*/
public function __construct($data)
public function __construct(string $data)
{
$this->data = $data;
$this->data_length = strlen($this->data);
@@ -150,7 +110,7 @@ class Parser
* @access public
* @return bool true on success, false on failure
*/
public function parse()
public function parse(): bool
{
while ($this->state && $this->state !== self::STATE_EMIT && $this->has_data()) {
$state = $this->state;
@@ -161,9 +121,10 @@ class Parser
return true;
}
$this->version = '';
$this->encoding = '';
$this->standalone = '';
// Reset the parser state.
$this->version = '1.0';
$this->encoding = 'UTF-8';
$this->standalone = false;
return false;
}
@@ -173,7 +134,7 @@ class Parser
* @access private
* @return bool true if there is further data, false if not
*/
public function has_data()
public function has_data(): bool
{
return (bool) ($this->position < $this->data_length);
}
@@ -192,6 +153,8 @@ class Parser
/**
* Read value
*
* @return string|false
*/
public function get_value()
{
@@ -208,7 +171,7 @@ class Parser
return false;
}
public function before_version_name()
public function before_version_name(): void
{
if ($this->skip_whitespace()) {
$this->state = self::STATE_VERSION_NAME;
@@ -217,7 +180,7 @@ class Parser
}
}
public function version_name()
public function version_name(): void
{
if (substr($this->data, $this->position, 7) === 'version') {
$this->position += 7;
@@ -228,7 +191,7 @@ class Parser
}
}
public function version_equals()
public function version_equals(): void
{
if (substr($this->data, $this->position, 1) === '=') {
$this->position++;
@@ -239,9 +202,10 @@ class Parser
}
}
public function version_value()
public function version_value(): void
{
if ($this->version = $this->get_value()) {
if ($version = $this->get_value()) {
$this->version = $version;
$this->skip_whitespace();
if ($this->has_data()) {
$this->state = self::STATE_ENCODING_NAME;
@@ -253,7 +217,7 @@ class Parser
}
}
public function encoding_name()
public function encoding_name(): void
{
if (substr($this->data, $this->position, 8) === 'encoding') {
$this->position += 8;
@@ -264,7 +228,7 @@ class Parser
}
}
public function encoding_equals()
public function encoding_equals(): void
{
if (substr($this->data, $this->position, 1) === '=') {
$this->position++;
@@ -275,9 +239,10 @@ class Parser
}
}
public function encoding_value()
public function encoding_value(): void
{
if ($this->encoding = $this->get_value()) {
if ($encoding = $this->get_value()) {
$this->encoding = $encoding;
$this->skip_whitespace();
if ($this->has_data()) {
$this->state = self::STATE_STANDALONE_NAME;
@@ -289,7 +254,7 @@ class Parser
}
}
public function standalone_name()
public function standalone_name(): void
{
if (substr($this->data, $this->position, 10) === 'standalone') {
$this->position += 10;
@@ -300,7 +265,7 @@ class Parser
}
}
public function standalone_equals()
public function standalone_equals(): void
{
if (substr($this->data, $this->position, 1) === '=') {
$this->position++;
@@ -311,7 +276,7 @@ class Parser
}
}
public function standalone_value()
public function standalone_value(): void
{
if ($standalone = $this->get_value()) {
switch ($standalone) {

View File

@@ -75,6 +75,10 @@ class WP_SimplePie_File extends SimplePie\File {
} else {
$this->headers = wp_remote_retrieve_headers( $res );
if ( $this->headers instanceof \WpOrg\Requests\Utility\CaseInsensitiveDictionary ) {
$this->headers = $this->headers->getAll();
}
/*
* SimplePie expects multiple headers to be stored as a comma-separated string,
* but `wp_remote_retrieve_headers()` returns them as an array, so they need

View File

@@ -812,7 +812,8 @@ function fetch_feed( $url ) {
$feed = new SimplePie\SimplePie();
$feed->set_sanitize_class( 'WP_SimplePie_Sanitize_KSES' );
$feed->get_registry()->register( SimplePie\Sanitize::class, 'WP_SimplePie_Sanitize_KSES', true );
/*
* We must manually overwrite $feed->sanitize because SimplePie's constructor
* sets it before we have a chance to set the sanitization class.
@@ -829,7 +830,7 @@ function fetch_feed( $url ) {
$feed->set_cache_class( 'WP_Feed_Cache' );
}
$feed->set_file_class( 'WP_SimplePie_File' );
$feed->get_registry()->register( SimplePie\File::class, 'WP_SimplePie_File', true );
$feed->set_feed_url( $url );
/** This filter is documented in wp-includes/class-wp-feed-cache-transient.php */

View File

@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.9-alpha-60770';
$wp_version = '6.9-alpha-60771';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.