Make WordPress Core

Changeset 60771


Ignore:
Timestamp:
09/16/2025 10:45:37 PM (2 months ago)
Author:
SergeyBiryukov
Message:

External Libraries: Update the SimplePie library to version 1.9.0.

References:

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

Props swissspidy, TobiasBg, SergeyBiryukov.
Fixes #63961.

Location:
trunk/src/wp-includes
Files:
7 added
1 deleted
77 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/SimplePie/autoloader.php

    r59141 r60771  
    11<?php
    2 /**
    3  * SimplePie
    4  *
    5  * A PHP-Based RSS and Atom Feed Framework.
    6  * Takes the hard work out of managing a complete RSS/Atom solution.
    7  *
    8  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    9  * All rights reserved.
    10  *
    11  * Redistribution and use in source and binary forms, with or without modification, are
    12  * permitted provided that the following conditions are met:
    13  *
    14  *  * Redistributions of source code must retain the above copyright notice, this list of
    15  *    conditions and the following disclaimer.
    16  *
    17  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    18  *    of conditions and the following disclaimer in the documentation and/or other materials
    19  *    provided with the distribution.
    20  *
    21  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    22  *    to endorse or promote products derived from this software without specific prior
    23  *    written permission.
    24  *
    25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    26  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    27  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    28  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    30  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    32  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    33  * POSSIBILITY OF SUCH DAMAGE.
    34  *
    35  * @package SimplePie
    36  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    37  * @author Ryan Parman
    38  * @author Sam Sneddon
    39  * @author Ryan McCue
    40  * @link http://simplepie.org/ SimplePie
    41  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    42  */
    432
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
    445
    456/**
     
    9455/**
    9556 * Autoloader class
    96  *
    97  * @package SimplePie
    98  * @subpackage API
    9957 */
    10058class SimplePie_Autoloader
  • trunk/src/wp-includes/SimplePie/library/SimplePie.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2017, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @version 1.7.0
    38  * @copyright 2004-2017 Ryan Parman, Sam Sneddon, Ryan McCue
    39  * @author Ryan Parman
    40  * @author Sam Sneddon
    41  * @author Ryan McCue
    42  * @link http://simplepie.org/ SimplePie
    43  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    44  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    457
    468use SimplePie\SimplePie as NamespacedSimplePie;
     
    5012// @trigger_error(sprintf('Using the "SimplePie" class is deprecated since SimplePie 1.7.0, use "SimplePie\SimplePie" instead.'), \E_USER_DEPRECATED);
    5113
     14/** @phpstan-ignore-next-line */
    5215if (\false) {
    5316    /** @deprecated since SimplePie 1.7.0, use "SimplePie\SimplePie" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Author.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Author;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Author" class is deprecated since SimplePie 1.7.0, use "SimplePie\Author" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Author" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Cache.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Cache;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Cache" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Cache/Base.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Cache\Base;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Cache_Base" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Base" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Base" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Cache/DB.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Cache\DB;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Cache_DB" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\DB" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\DB" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Cache/File.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Cache\File;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Cache_File" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\File" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\File" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Cache/Memcache.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Cache\Memcache;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Cache_Memcache" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Memcache" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Memcache" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Cache/Memcached.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Cache\Memcached;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Cache_Memcached" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Memcached" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Memcached" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Cache/MySQL.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Cache\MySQL;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Cache_MySQL" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\MySQL" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\MySQL" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Cache/Redis.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie Redis Cache Extension
    5  *
    6  * @package SimplePie
    7  * @author Jan Kozak <galvani78@gmail.com>
    8  * @link http://galvani.cz/
    9  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    10  * @version 0.2.9
    11  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    127
    138use SimplePie\Cache\Redis;
     
    1712// @trigger_error(sprintf('Using the "SimplePie_Cache_Redis" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Redis" instead.'), \E_USER_DEPRECATED);
    1813
     14/** @phpstan-ignore-next-line */
    1915if (\false) {
    2016    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Redis" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Caption.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Caption;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Caption" class is deprecated since SimplePie 1.7.0, use "SimplePie\Caption" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Caption" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Category.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Category;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Category" class is deprecated since SimplePie 1.7.0, use "SimplePie\Category" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Category" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Content/Type/Sniffer.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Content\Type\Sniffer;
     
    4912// @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);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Content\Type\Sniffer" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Copyright.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Copyright;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Copyright" class is deprecated since SimplePie 1.7.0, use "SimplePie\Copyright" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Copyright" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Core.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458/**
     
    4912 *
    5013 * @deprecated Use {@see SimplePie} directly
    51  * @package SimplePie
    52  * @subpackage API
    5314 */
    5415class SimplePie_Core extends SimplePie
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Credit.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Credit;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Credit" class is deprecated since SimplePie 1.7.0, use "SimplePie\Credit" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Credit" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Decode/HTML/Entities.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458
     
    5013 *
    5114 * @deprecated Use DOMDocument instead!
    52  * @package SimplePie
    5315 */
    5416class SimplePie_Decode_HTML_Entities
     
    8446     * @param string $data Input data
    8547     */
    86     public function __construct($data)
     48    public function __construct(string $data)
    8749    {
    8850        $this->data = $data;
     
    9759    public function parse()
    9860    {
    99         while (($this->position = strpos($this->data, '&', $this->position)) !== false) {
     61        while (($position = strpos($this->data, '&', $this->position)) !== false) {
     62            $this->position = $position;
    10063            $this->consume();
    10164            $this->entity();
     
    10972     *
    11073     * @access private
    111      * @return mixed The next byte, or false, if there is no more data
     74     * @return string|false The next byte, or false, if there is no more data
    11275     */
    11376    public function consume()
     
    12689     * @access private
    12790     * @param string $chars Characters to consume
    128      * @return mixed A series of characters that match the range, or false
    129      */
    130     public function consume_range($chars)
     91     * @return string|false A series of characters that match the range, or false
     92     */
     93    public function consume_range(string $chars)
    13194    {
    13295        if ($len = strspn($this->data, $chars, $this->position)) {
     
    144107     *
    145108     * @access private
     109     * @return void
    146110     */
    147111    public function unconsume()
     
    155119     *
    156120     * @access private
     121     * @return void
    157122     */
    158123    public function entity()
     
    188153
    189154                    if ($hex) {
    190                         $codepoint = hexdec($codepoint);
     155                        // Cap to PHP_INT_MAX to ensure consistent behaviour if $codepoint is so large
     156                        // it cannot fit into int – just casting float to int might return junk (e.g. a negative number).
     157                        // If it is so large, `Misc::codepoint_to_utf8` will just return a replacement character.
     158                        $codepoint = (int) min(hexdec($codepoint), \PHP_INT_MAX);
    191159                    } else {
    192                         $codepoint = intval($codepoint);
     160                        // Casting string to int caps at PHP_INT_MAX automatically.
     161                        $codepoint = (int) $codepoint;
    193162                    }
    194163
     
    580549
    581550                for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++) {
    582                     $consumed = substr($this->consumed, 1);
     551                    // Cast for PHPStan on PHP < 8.0: We consumed as per the loop condition,
     552                    // so `$this->consumed` is non-empty and the substr offset is valid.
     553                    $consumed = (string) substr($this->consumed, 1);
    583554                    if (isset($entities[$consumed])) {
    584555                        $match = $consumed;
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Enclosure.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Enclosure;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Enclosure" class is deprecated since SimplePie 1.7.0, use "SimplePie\Enclosure" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Enclosure" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Exception.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Exception as SimplePieException;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Exception" class is deprecated since SimplePie 1.7.0, use "SimplePie\Exception" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Exception" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/File.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\File;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_File" class is deprecated since SimplePie 1.7.0, use "SimplePie\File" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\File" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/HTTP/Parser.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\HTTP\Parser;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_HTTP_Parser" class is deprecated since SimplePie 1.7.0, use "SimplePie\HTTP\Parser" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    52     /** @deprecated since SimplePie 1.7.0, use "SimplePie\HTTP\Parser" instead */
     16    /**
     17     * @deprecated since SimplePie 1.7.0, use "SimplePie\HTTP\Parser" instead
     18     * @template Psr7Compatible of bool
     19     * @extends Parser<Psr7Compatible>
     20     */
    5321    class SimplePie_HTTP_Parser extends Parser
    5422    {
  • trunk/src/wp-includes/SimplePie/library/SimplePie/IRI.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\IRI;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_IRI" class is deprecated since SimplePie 1.7.0, use "SimplePie\IRI" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\IRI" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Item.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Item;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Item" class is deprecated since SimplePie 1.7.0, use "SimplePie\Item" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Item" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Locator.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Locator;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Locator" class is deprecated since SimplePie 1.7.0, use "SimplePie\Locator" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Locator" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Misc.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Misc;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Misc" class is deprecated since SimplePie 1.7.0, use "SimplePie\Misc" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Misc" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Net/IPv6.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Net\IPv6;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Net_IPv6" class is deprecated since SimplePie 1.7.0, use "SimplePie\Net\IPv6" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Net\IPv6" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Parse/Date.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Parse\Date;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Parse_Date" class is deprecated since SimplePie 1.7.0, use "SimplePie\Parse\Date" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Parse\Date" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Parser.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Parser;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Parser" class is deprecated since SimplePie 1.7.0, use "SimplePie\Parser" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Parser" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Rating.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Rating;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Rating" class is deprecated since SimplePie 1.7.0, use "SimplePie\Rating" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Rating" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Registry.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Registry;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Registry" class is deprecated since SimplePie 1.7.0, use "SimplePie\Registry" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Registry" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Restriction.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Restriction;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Restriction" class is deprecated since SimplePie 1.7.0, use "SimplePie\Restriction" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Restriction" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Sanitize.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Sanitize;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Sanitize" class is deprecated since SimplePie 1.7.0, use "SimplePie\Sanitize" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Sanitize" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/Source.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\Source;
     
    4912// @trigger_error(sprintf('Using the "SimplePie_Source" class is deprecated since SimplePie 1.7.0, use "SimplePie\Source" instead.'), \E_USER_DEPRECATED);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\Source" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/XML/Declaration/Parser.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458use SimplePie\XML\Declaration\Parser;
     
    4912// @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);
    5013
     14/** @phpstan-ignore-next-line */
    5115if (\false) {
    5216    /** @deprecated since SimplePie 1.7.0, use "SimplePie\XML\Declaration\Parser" instead */
  • trunk/src/wp-includes/SimplePie/library/SimplePie/gzdecode.php

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

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
     
    5114 *
    5215 * This class can be overloaded with {@see SimplePie::set_author_class()}
    53  *
    54  * @package SimplePie
    55  * @subpackage API
    5616 */
    5717class Author
     
    6020     * Author's name
    6121     *
    62      * @var string
     22     * @var ?string
    6323     * @see get_name()
    6424     */
     
    6828     * Author's link
    6929     *
    70      * @var string
     30     * @var ?string
    7131     * @see get_link()
    7232     */
     
    7636     * Author's email address
    7737     *
    78      * @var string
     38     * @var ?string
    7939     * @see get_email()
    8040     */
     
    8343    /**
    8444     * Constructor, used to input the data
    85      *
    86      * @param string $name
    87      * @param string $link
    88      * @param string $email
    8945     */
    90     public function __construct($name = null, $link = null, $email = null)
    91     {
     46    public function __construct(
     47        ?string $name = null,
     48        ?string $link = null,
     49        ?string $email = null
     50    ) {
    9251        $this->name = $name;
    9352        $this->link = $link;
  • trunk/src/wp-includes/SimplePie/src/Cache.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
     
    5417 * via {@see register()}
    5518 *
    56  * @package SimplePie
    57  * @subpackage Caching
    5819 * @deprecated since SimplePie 1.8.0, use "SimplePie\SimplePie::set_cache()" instead
    5920 */
     
    6526     * These receive 3 parameters to their constructor, as documented in
    6627     * {@see register()}
    67      * @var array
     28     * @var array<string, class-string<Base>>
    6829     */
    6930    protected static $handlers = [
    70         'mysql'     => 'SimplePie\Cache\MySQL',
    71         'memcache'  => 'SimplePie\Cache\Memcache',
    72         'memcached' => 'SimplePie\Cache\Memcached',
    73         'redis'     => 'SimplePie\Cache\Redis'
     31        'mysql'     => Cache\MySQL::class,
     32        'memcache'  => Cache\Memcache::class,
     33        'memcached' => Cache\Memcached::class,
     34        'redis'     => Cache\Redis::class,
    7435    ];
    7536
     
    8950     * @return Base Type of object depends on scheme of `$location`
    9051     */
    91     public static function get_handler($location, $filename, $extension)
     52    public static function get_handler(string $location, string $filename, $extension)
    9253    {
    9354        $type = explode(':', $location, 2);
     
    10566     *
    10667     * @deprecated since SimplePie 1.3.1, use {@see get_handler()} instead
     68     * @param string $location
     69     * @param string $filename
     70     * @param Base::TYPE_FEED|Base::TYPE_IMAGE $extension
     71     * @return Base
    10772     */
    108     public function create($location, $filename, $extension)
     73    public function create(string $location, string $filename, $extension)
    10974    {
    11075        trigger_error('Cache::create() has been replaced with Cache::get_handler() since SimplePie 1.3.1, use the registry system instead.', \E_USER_DEPRECATED);
     
    11883     * @param string $type DSN type to register for
    11984     * @param class-string<Base> $class Name of handler class. Must implement Base
     85     * @return void
    12086     */
    121     public static function register($type, $class)
     87    public static function register(string $type, $class)
    12288    {
    12389        self::$handlers[$type] = $class;
     
    12894     *
    12995     * @param string $url
    130      * @return array
     96     * @return array<string, mixed>
    13197     */
    132     public static function parse_URL($url)
     98    public static function parse_URL(string $url)
    13399    {
    134         $params = parse_url($url);
    135         $params['extras'] = [];
     100        $parsedUrl = parse_url($url);
     101
     102        if ($parsedUrl === false) {
     103            return [];
     104        }
     105
     106        $params = array_merge($parsedUrl, ['extras' => []]);
    136107        if (isset($params['query'])) {
    137108            parse_str($params['query'], $params['extras']);
  • trunk/src/wp-includes/SimplePie/src/Cache/Base.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie\Cache;
     
    5114 * to implement this interface.
    5215 *
    53  * @package SimplePie
    54  * @subpackage Caching
    5516 * @deprecated since SimplePie 1.8.0, use "Psr\SimpleCache\CacheInterface" instead
    5617 */
     
    7839     * @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
    7940     */
    80     public function __construct($location, $name, $type);
     41    public function __construct(string $location, string $name, $type);
    8142
    8243    /**
    8344     * Save data to the cache
    8445     *
    85      * @param array|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
     46     * @param array<mixed>|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
    8647     * @return bool Successfulness
    8748     */
     
    9152     * Retrieve the data saved to the cache
    9253     *
    93      * @return array Data for SimplePie::$data
     54     * @return array<mixed> Data for SimplePie::$data
    9455     */
    9556    public function load();
  • trunk/src/wp-includes/SimplePie/src/Cache/BaseDataCache.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2022 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie\Cache;
     
    5013 * Adapter for deprecated \SimplePie\Cache\Base implementations
    5114 *
    52  * @package SimplePie
    53  * @subpackage Caching
    5415 * @internal
    5516 */
     
    11576     *
    11677     * @param string   $key   The key of the item to store.
    117      * @param array    $value The value of the item to store, must be serializable.
     78     * @param array<mixed> $value The value of the item to store, must be serializable.
    11879     * @param null|int $ttl   Optional. The TTL value of this item. If no value is sent and
    11980     *                                      the driver supports TTL then the library may set a default value
  • trunk/src/wp-includes/SimplePie/src/Cache/CallableNameFilter.php

    r59141 r60771  
    11<?php
    2 /**
    3  * SimplePie
    4  *
    5  * A PHP-Based RSS and Atom Feed Framework.
    6  * Takes the hard work out of managing a complete RSS/Atom solution.
    7  *
    8  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    9  * All rights reserved.
    10  *
    11  * Redistribution and use in source and binary forms, with or without modification, are
    12  * permitted provided that the following conditions are met:
    13  *
    14  *  * Redistributions of source code must retain the above copyright notice, this list of
    15  *    conditions and the following disclaimer.
    16  *
    17  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    18  *    of conditions and the following disclaimer in the documentation and/or other materials
    19  *    provided with the distribution.
    20  *
    21  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    22  *    to endorse or promote products derived from this software without specific prior
    23  *    written permission.
    24  *
    25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    26  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    27  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    28  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    30  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    32  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    33  * POSSIBILITY OF SUCH DAMAGE.
    34  *
    35  * @package SimplePie
    36  * @copyright 2004-2022 Ryan Parman, Sam Sneddon, Ryan McCue
    37  * @author Ryan Parman
    38  * @author Sam Sneddon
    39  * @author Ryan McCue
    40  * @link http://simplepie.org/ SimplePie
    41  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    42  */
     2
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    437
    448namespace SimplePie\Cache;
     
    4610/**
    4711 * Creating a cache filename with callables
    48  *
    49  * @package SimplePie
    50  * @subpackage Caching
    5112 */
    5213final class CallableNameFilter implements NameFilter
    5314{
    5415    /**
    55      * @var callable
     16     * @var callable(string): string
    5617     */
    5718    private $callable;
    5819
     20    /**
     21     * @param callable(string): string $callable
     22     */
    5923    public function __construct(callable $callable)
    6024    {
     
    7943     * minimum.
    8044     *
    81      * @param string $name The name for the cache will be most likly an url with query string
     45     * @param string $name The name for the cache will be most likely an url with query string
    8246     *
    8347     * @return string the new cache name
  • trunk/src/wp-includes/SimplePie/src/Cache/DB.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie\Cache;
     9
     10use SimplePie\Item;
    4611
    4712/**
    4813 * Base class for database-based caches
    4914 *
    50  * @package SimplePie
    51  * @subpackage Caching
    5215 * @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead
    5316 */
     
    6023     *
    6124     * @param \SimplePie\SimplePie $data
    62      * @return array First item is the serialized data for storage, second item is the unique ID for this item
     25     * @return array{string, array<string, Item>} First item is the serialized data for storage, second item is the unique ID for this item
    6326     */
    64     protected static function prepare_simplepie_object_for_cache($data)
     27    protected static function prepare_simplepie_object_for_cache(\SimplePie\SimplePie $data)
    6528    {
    6629        $items = $data->get_items();
  • trunk/src/wp-includes/SimplePie/src/Cache/DataCache.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2022 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie\Cache;
     
    5619 * methods of \Psr\SimpleCache\CacheInterface.
    5720 *
    58  * @package SimplePie
    59  * @subpackage Caching
    6021 * @internal
    6122 */
     
    8950     *
    9051     * @param string   $key   The key of the item to store.
    91      * @param array    $value The value of the item to store, must be serializable.
     52     * @param array<mixed> $value The value of the item to store, must be serializable.
    9253     * @param null|int $ttl   Optional. The TTL value of this item. If no value is sent and
    9354     *                                      the driver supports TTL then the library may set a default value
  • trunk/src/wp-includes/SimplePie/src/Cache/File.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie\Cache;
     
    4811 * Caches data to the filesystem
    4912 *
    50  * @package SimplePie
    51  * @subpackage Caching
    5213 * @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead
    5314 */
     
    9051     * @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
    9152     */
    92     public function __construct($location, $name, $type)
     53    public function __construct(string $location, string $name, $type)
    9354    {
    9455        $this->location = $location;
     
    10162     * Save data to the cache
    10263     *
    103      * @param array|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
     64     * @param array<mixed>|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
    10465     * @return bool Successfulness
    10566     */
     
    12081     * Retrieve the data saved to the cache
    12182     *
    122      * @return array Data for SimplePie::$data
     83     * @return array<mixed>|false Data for SimplePie::$data
    12384     */
    12485    public function load()
    12586    {
    12687        if (file_exists($this->name) && is_readable($this->name)) {
    127             return unserialize(file_get_contents($this->name));
     88            return unserialize((string) file_get_contents($this->name));
    12889        }
    12990        return false;
     
    13394     * Retrieve the last modified time for the cache
    13495     *
    135      * @return int Timestamp
     96     * @return int|false Timestamp
    13697     */
    13798    public function mtime()
  • trunk/src/wp-includes/SimplePie/src/Cache/Memcache.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie\Cache;
     
    5619 * prefixed with `sp_` and data will expire after 3600 seconds
    5720 *
    58  * @package SimplePie
    59  * @subpackage Caching
    6021 * @uses Memcache
    6122 * @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead
     
    6627     * Memcache instance
    6728     *
    68      * @var Memcache
     29     * @var NativeMemcache
    6930     */
    7031    protected $cache;
     
    7334     * Options
    7435     *
    75      * @var array
     36     * @var array<string, mixed>
    7637     */
    7738    protected $options;
     
    9152     * @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
    9253     */
    93     public function __construct($location, $name, $type)
     54    public function __construct(string $location, string $name, $type)
    9455    {
    9556        $this->options = [
     
    11273     * Save data to the cache
    11374     *
    114      * @param array|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
     75     * @param array<mixed>|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
    11576     * @return bool Successfulness
    11677     */
     
    12687     * Retrieve the data saved to the cache
    12788     *
    128      * @return array Data for SimplePie::$data
     89     * @return array<mixed>|false Data for SimplePie::$data
    12990     */
    13091    public function load()
     
    141102     * Retrieve the last modified time for the cache
    142103     *
    143      * @return int Timestamp
     104     * @return int|false Timestamp
    144105     */
    145106    public function mtime()
  • trunk/src/wp-includes/SimplePie/src/Cache/Memcached.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-FileCopyrightText: 2015 Paul L. McNeely
     5// SPDX-License-Identifier: BSD-3-Clause
     6
     7declare(strict_types=1);
    448
    459namespace SimplePie\Cache;
     
    5620 * prefixed with `sp_` and data will expire after 3600 seconds
    5721 *
    58  * @package    SimplePie
    59  * @subpackage Caching
    60  * @author     Paul L. McNeely
    6122 * @uses       Memcached
    6223 * @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead
     
    7233    /**
    7334     * Options
    74      * @var array
     35     * @var array<string, mixed>
    7536     */
    7637    protected $options;
     
    8849     * @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
    8950     */
    90     public function __construct($location, $name, $type)
     51    public function __construct(string $location, string $name, $type)
    9152    {
    9253        $this->options = [
     
    10869    /**
    10970     * Save data to the cache
    110      * @param array|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
     71     * @param array<mixed>|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
    11172     * @return bool Successfulness
    11273     */
     
    12283    /**
    12384     * Retrieve the data saved to the cache
    124      * @return array Data for SimplePie::$data
     85     * @return array<mixed>|false Data for SimplePie::$data
    12586     */
    12687    public function load()
     
    165126    /**
    166127     * Set the last modified time and data to NativeMemcached
     128     * @param string|false $data
    167129     * @return bool Success status
    168130     */
    169     private function setData($data)
     131    private function setData($data): bool
    170132    {
    171133        if ($data !== false) {
  • trunk/src/wp-includes/SimplePie/src/Cache/MySQL.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie\Cache;
     
    5417 * `root` and the password `password`. All tables will be prefixed with `sp_`
    5518 *
    56  * @package SimplePie
    57  * @subpackage Caching
    5819 * @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead
    5920 */
     
    6324     * PDO instance
    6425     *
    65      * @var \PDO
     26     * @var \PDO|null
    6627     */
    6728    protected $mysql;
     
    7031     * Options
    7132     *
    72      * @var array
     33     * @var array<string, mixed>
    7334     */
    7435    protected $options;
     
    8849     * @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
    8950     */
    90     public function __construct($location, $name, $type)
     51    public function __construct(string $location, string $name, $type)
    9152    {
    9253        $this->options = [
     
    148109     * Save data to the cache
    149110     *
    150      * @param array|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
     111     * @param array<string>|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
    151112     * @return bool Successfulness
    152113     */
     
    269230     * Retrieve the data saved to the cache
    270231     *
    271      * @return array Data for SimplePie::$data
     232     * @return array<string>|false Data for SimplePie::$data
    272233     */
    273234    public function load()
     
    311272                    if ($query->execute()) {
    312273                        while ($row = $query->fetchColumn()) {
    313                             $feed['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['entry'][] = unserialize($row);
     274                            $feed['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['entry'][] = unserialize((string) $row);
    314275                        }
    315276                    } else {
     
    326287     * Retrieve the last modified time for the cache
    327288     *
    328      * @return int Timestamp
     289     * @return int|false Timestamp
    329290     */
    330291    public function mtime()
     
    337298        $query->bindValue(':id', $this->id);
    338299        if ($query->execute() && ($time = $query->fetchColumn())) {
    339             return $time;
     300            return (int) $time;
    340301        }
    341302
  • trunk/src/wp-includes/SimplePie/src/Cache/NameFilter.php

    r59141 r60771  
    11<?php
    2 /**
    3  * SimplePie
    4  *
    5  * A PHP-Based RSS and Atom Feed Framework.
    6  * Takes the hard work out of managing a complete RSS/Atom solution.
    7  *
    8  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    9  * All rights reserved.
    10  *
    11  * Redistribution and use in source and binary forms, with or without modification, are
    12  * permitted provided that the following conditions are met:
    13  *
    14  *  * Redistributions of source code must retain the above copyright notice, this list of
    15  *    conditions and the following disclaimer.
    16  *
    17  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    18  *    of conditions and the following disclaimer in the documentation and/or other materials
    19  *    provided with the distribution.
    20  *
    21  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    22  *    to endorse or promote products derived from this software without specific prior
    23  *    written permission.
    24  *
    25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    26  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    27  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    28  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    30  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    32  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    33  * POSSIBILITY OF SUCH DAMAGE.
    34  *
    35  * @package SimplePie
    36  * @copyright 2004-2022 Ryan Parman, Sam Sneddon, Ryan McCue
    37  * @author Ryan Parman
    38  * @author Sam Sneddon
    39  * @author Ryan McCue
    40  * @link http://simplepie.org/ SimplePie
    41  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    42  */
     2
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    437
    448namespace SimplePie\Cache;
     
    4610/**
    4711 * Interface for creating a cache filename
    48  *
    49  * @package SimplePie
    50  * @subpackage Caching
    5112 */
    5213interface NameFilter
     
    6930     * minimum.
    7031     *
    71      * @param string $name The name for the cache will be most likly an url with query string
     32     * @param string $name The name for the cache will be most likely an url with query string
    7233     *
    7334     * @return string the new cache name
  • trunk/src/wp-includes/SimplePie/src/Cache/Psr16.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2022 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie\Cache;
     
    4710use Psr\SimpleCache\CacheInterface;
    4811use Psr\SimpleCache\InvalidArgumentException;
     12use Throwable;
    4913
    5014/**
    5115 * Caches data into a PSR-16 cache implementation
    5216 *
    53  * @package SimplePie
    54  * @subpackage Caching
    5517 * @internal
    5618 */
     
    8749     * @return array|mixed The value of the item from the cache, or $default in case of cache miss.
    8850     *
    89      * @throws InvalidArgumentException
     51     * @throws InvalidArgumentException&Throwable
    9052     *   MUST be thrown if the $key string is not a legal value.
    9153     */
     
    11072     *
    11173     * @param string   $key   The key of the item to store.
    112      * @param array    $value The value of the item to store, must be serializable.
     74     * @param array<mixed> $value The value of the item to store, must be serializable.
    11375     * @param null|int $ttl   Optional. The TTL value of this item. If no value is sent and
    11476     *                                      the driver supports TTL then the library may set a default value
     
    11779     * @return bool True on success and false on failure.
    11880     *
    119      * @throws InvalidArgumentException
     81     * @throws InvalidArgumentException&Throwable
    12082     *   MUST be thrown if the $key string is not a legal value.
    12183     */
     
    13799     * @return bool True if the item was successfully removed. False if there was an error.
    138100     *
    139      * @throws InvalidArgumentException
     101     * @throws InvalidArgumentException&Throwable
    140102     *   MUST be thrown if the $key string is not a legal value.
    141103     */
  • trunk/src/wp-includes/SimplePie/src/Cache/Redis.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-FileCopyrightText: 2015 Jan Kozak <galvani78@gmail.com>
     5// SPDX-License-Identifier: BSD-3-Clause
     6
     7declare(strict_types=1);
    448
    459namespace SimplePie\Cache;
     
    5620 * prefixed with `simple_primary-` and data will expire after 3600 seconds
    5721 *
    58  * @package SimplePie
    59  * @subpackage Caching
    6022 * @uses Redis
    6123 * @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead
     
    7335     * Options
    7436     *
    75      * @var array
     37     * @var array<string, mixed>
    7638     */
    7739    protected $options;
     
    8951     * @param string $location Location string (from SimplePie::$cache_location)
    9052     * @param string $name Unique ID for the cache
    91      * @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
     53     * @param Base::TYPE_FEED|Base::TYPE_IMAGE|array<string, mixed>|null $options Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
    9254     */
    93     public function __construct($location, $name, $options = null)
     55    public function __construct(string $location, string $name, $options = null)
    9456    {
    9557        //$this->cache = \flow\simple\cache\Redis::getRedisClientInstance();
     
    11981    /**
    12082     * @param NativeRedis $cache
     83     * @return void
    12184     */
    12285    public function setRedisClient(NativeRedis $cache)
     
    12891     * Save data to the cache
    12992     *
    130      * @param array|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
     93     * @param array<mixed>|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
    13194     * @return bool Successfulness
    13295     */
     
    147110     * Retrieve the data saved to the cache
    148111     *
    149      * @return array Data for SimplePie::$data
     112     * @return array<mixed>|false Data for SimplePie::$data
    150113     */
    151114    public function load()
     
    162125     * Retrieve the last modified time for the cache
    163126     *
    164      * @return int Timestamp
     127     * @return int|false Timestamp
    165128     */
    166129    public function mtime()
  • trunk/src/wp-includes/SimplePie/src/Caption.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
     
    5114 *
    5215 * This class can be overloaded with {@see \SimplePie\SimplePie::set_caption_class()}
    53  *
    54  * @package SimplePie
    55  * @subpackage API
    5616 */
    5717class Caption
     
    6020     * Content type
    6121     *
    62      * @var string
     22     * @var ?string
    6323     * @see get_type()
    6424     */
     
    6828     * Language
    6929     *
    70      * @var string
     30     * @var ?string
    7131     * @see get_language()
    7232     */
     
    7636     * Start time
    7737     *
    78      * @var string
     38     * @var ?string
    7939     * @see get_starttime()
    8040     */
     
    8444     * End time
    8545     *
    86      * @var string
     46     * @var ?string
    8747     * @see get_endtime()
    8848     */
     
    9252     * Caption text
    9353     *
    94      * @var string
     54     * @var ?string
    9555     * @see get_text()
    9656     */
     
    10363     * properties and their accessors
    10464     */
    105     public function __construct($type = null, $lang = null, $startTime = null, $endTime = null, $text = null)
    106     {
     65    public function __construct(
     66        ?string $type = null,
     67        ?string $lang = null,
     68        ?string $startTime = null,
     69        ?string $endTime = null,
     70        ?string $text = null
     71    ) {
    10772        $this->type = $type;
    10873        $this->lang = $lang;
  • trunk/src/wp-includes/SimplePie/src/Category.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
     
    5114 *
    5215 * This class can be overloaded with {@see \SimplePie\SimplePie::set_category_class()}
    53  *
    54  * @package SimplePie
    55  * @subpackage API
    5616 */
    5717class Category
     
    10060     * @param string|null $type
    10161     */
    102     public function __construct($term = null, $scheme = null, $label = null, $type = null)
     62    public function __construct(?string $term = null, ?string $scheme = null, ?string $label = null, ?string $type = null)
    10363    {
    10464        $this->term = $term;
     
    145105     * @return string|null
    146106     */
    147     public function get_label($strict = false)
     107    public function get_label(bool $strict = false)
    148108    {
    149109        if ($this->label === null && $strict !== true) {
  • trunk/src/wp-includes/SimplePie/src/Content/Type/Sniffer.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie\Content\Type;
     9
     10use InvalidArgumentException;
     11use SimplePie\File;
     12use SimplePie\HTTP\Response;
    4613
    4714/**
     
    5522 *
    5623 * This class can be overloaded with {@see \SimplePie\SimplePie::set_content_type_sniffer_class()}
    57  *
    58  * @package SimplePie
    59  * @subpackage HTTP
    6024 */
    6125class Sniffer
     
    6428     * File object
    6529     *
    66      * @var \SimplePie\File
     30     * @var File|Response
    6731     */
    6832    public $file;
     
    7135     * Create an instance of the class with the input file
    7236     *
    73      * @param Sniffer $file Input file
    74      */
    75     public function __construct($file)
    76     {
     37     * @param File|Response $file Input file
     38     */
     39    public function __construct(/* File */ $file)
     40    {
     41        if (!is_object($file) || !$file instanceof Response) {
     42            // For BC we're asking for `File`, but internally we accept every `Response` implementation
     43            throw new InvalidArgumentException(sprintf(
     44                '%s(): Argument #1 ($file) must be of type %s',
     45                __METHOD__,
     46                File::class
     47            ), 1);
     48        }
     49
    7750        $this->file = $file;
    7851    }
     
    8558    public function get_type()
    8659    {
    87         if (isset($this->file->headers['content-type'])) {
    88             if (!isset($this->file->headers['content-encoding'])
    89                 && ($this->file->headers['content-type'] === 'text/plain'
    90                     || $this->file->headers['content-type'] === 'text/plain; charset=ISO-8859-1'
    91                     || $this->file->headers['content-type'] === 'text/plain; charset=iso-8859-1'
    92                     || $this->file->headers['content-type'] === 'text/plain; charset=UTF-8')) {
     60        $content_type = $this->file->has_header('content-type') ? $this->file->get_header_line('content-type') : null;
     61        $content_encoding = $this->file->has_header('content-encoding') ? $this->file->get_header_line('content-encoding') : null;
     62        if ($content_type !== null) {
     63            if ($content_encoding === null
     64                && ($content_type === 'text/plain'
     65                    || $content_type === 'text/plain; charset=ISO-8859-1'
     66                    || $content_type === 'text/plain; charset=iso-8859-1'
     67                    || $content_type === 'text/plain; charset=UTF-8')) {
    9368                return $this->text_or_binary();
    9469            }
    9570
    96             if (($pos = strpos($this->file->headers['content-type'], ';')) !== false) {
    97                 $official = substr($this->file->headers['content-type'], 0, $pos);
     71            if (($pos = strpos($content_type, ';')) !== false) {
     72                $official = substr($content_type, 0, $pos);
    9873            } else {
    99                 $official = $this->file->headers['content-type'];
     74                $official = $content_type;
    10075            }
    10176            $official = trim(strtolower($official));
     
    131106    public function text_or_binary()
    132107    {
    133         if (substr($this->file->body, 0, 2) === "\xFE\xFF"
    134             || substr($this->file->body, 0, 2) === "\xFF\xFE"
    135             || substr($this->file->body, 0, 4) === "\x00\x00\xFE\xFF"
    136             || substr($this->file->body, 0, 3) === "\xEF\xBB\xBF") {
     108        $body = $this->file->get_body_content();
     109
     110        if (substr($body, 0, 2) === "\xFE\xFF"
     111            || substr($body, 0, 2) === "\xFF\xFE"
     112            || substr($body, 0, 4) === "\x00\x00\xFE\xFF"
     113            || substr($body, 0, 3) === "\xEF\xBB\xBF") {
    137114            return 'text/plain';
    138         } elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/', $this->file->body)) {
     115        } elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/', $body)) {
    139116            return 'application/octet-stream';
    140117        }
     
    150127    public function unknown()
    151128    {
    152         $ws = strspn($this->file->body, "\x09\x0A\x0B\x0C\x0D\x20");
    153         if (strtolower(substr($this->file->body, $ws, 14)) === '<!doctype html'
    154             || strtolower(substr($this->file->body, $ws, 5)) === '<html'
    155             || strtolower(substr($this->file->body, $ws, 7)) === '<script') {
     129        $body = $this->file->get_body_content();
     130
     131        $ws = strspn($body, "\x09\x0A\x0B\x0C\x0D\x20");
     132        if (strtolower(substr($body, $ws, 14)) === '<!doctype html'
     133            || strtolower(substr($body, $ws, 5)) === '<html'
     134            || strtolower(substr($body, $ws, 7)) === '<script') {
    156135            return 'text/html';
    157         } elseif (substr($this->file->body, 0, 5) === '%PDF-') {
     136        } elseif (substr($body, 0, 5) === '%PDF-') {
    158137            return 'application/pdf';
    159         } elseif (substr($this->file->body, 0, 11) === '%!PS-Adobe-') {
     138        } elseif (substr($body, 0, 11) === '%!PS-Adobe-') {
    160139            return 'application/postscript';
    161         } elseif (substr($this->file->body, 0, 6) === 'GIF87a'
    162             || substr($this->file->body, 0, 6) === 'GIF89a') {
     140        } elseif (substr($body, 0, 6) === 'GIF87a'
     141            || substr($body, 0, 6) === 'GIF89a') {
    163142            return 'image/gif';
    164         } elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") {
     143        } elseif (substr($body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") {
    165144            return 'image/png';
    166         } elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF") {
     145        } elseif (substr($body, 0, 3) === "\xFF\xD8\xFF") {
    167146            return 'image/jpeg';
    168         } elseif (substr($this->file->body, 0, 2) === "\x42\x4D") {
     147        } elseif (substr($body, 0, 2) === "\x42\x4D") {
    169148            return 'image/bmp';
    170         } elseif (substr($this->file->body, 0, 4) === "\x00\x00\x01\x00") {
     149        } elseif (substr($body, 0, 4) === "\x00\x00\x01\x00") {
    171150            return 'image/vnd.microsoft.icon';
    172151        }
     
    178157     * Sniff images
    179158     *
    180      * @return string Actual Content-Type
     159     * @return string|false Actual Content-Type
    181160     */
    182161    public function image()
    183162    {
    184         if (substr($this->file->body, 0, 6) === 'GIF87a'
    185             || substr($this->file->body, 0, 6) === 'GIF89a') {
     163        $body = $this->file->get_body_content();
     164
     165        if (substr($body, 0, 6) === 'GIF87a'
     166            || substr($body, 0, 6) === 'GIF89a') {
    186167            return 'image/gif';
    187         } elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") {
     168        } elseif (substr($body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") {
    188169            return 'image/png';
    189         } elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF") {
     170        } elseif (substr($body, 0, 3) === "\xFF\xD8\xFF") {
    190171            return 'image/jpeg';
    191         } elseif (substr($this->file->body, 0, 2) === "\x42\x4D") {
     172        } elseif (substr($body, 0, 2) === "\x42\x4D") {
    192173            return 'image/bmp';
    193         } elseif (substr($this->file->body, 0, 4) === "\x00\x00\x01\x00") {
     174        } elseif (substr($body, 0, 4) === "\x00\x00\x01\x00") {
    194175            return 'image/vnd.microsoft.icon';
    195176        }
     
    205186    public function feed_or_html()
    206187    {
    207         $len = strlen($this->file->body);
    208         $pos = strspn($this->file->body, "\x09\x0A\x0D\x20\xEF\xBB\xBF");
     188        $body = $this->file->get_body_content();
     189
     190        $len = strlen($body);
     191        $pos = strspn($body, "\x09\x0A\x0D\x20\xEF\xBB\xBF");
    209192
    210193        while ($pos < $len) {
    211             switch ($this->file->body[$pos]) {
     194            switch ($body[$pos]) {
    212195                case "\x09":
    213196                case "\x0A":
    214197                case "\x0D":
    215198                case "\x20":
    216                     $pos += strspn($this->file->body, "\x09\x0A\x0D\x20", $pos);
     199                    $pos += strspn($body, "\x09\x0A\x0D\x20", $pos);
    217200                    continue 2;
    218201
     
    225208            }
    226209
    227             if (substr($this->file->body, $pos, 3) === '!--') {
     210            if (substr($body, $pos, 3) === '!--') {
    228211                $pos += 3;
    229                 if ($pos < $len && ($pos = strpos($this->file->body, '-->', $pos)) !== false) {
     212                if ($pos < $len && ($pos = strpos($body, '-->', $pos)) !== false) {
    230213                    $pos += 3;
    231214                } else {
    232215                    return 'text/html';
    233216                }
    234             } elseif (substr($this->file->body, $pos, 1) === '!') {
    235                 if ($pos < $len && ($pos = strpos($this->file->body, '>', $pos)) !== false) {
     217            } elseif (substr($body, $pos, 1) === '!') {
     218                if ($pos < $len && ($pos = strpos($body, '>', $pos)) !== false) {
    236219                    $pos++;
    237220                } else {
    238221                    return 'text/html';
    239222                }
    240             } elseif (substr($this->file->body, $pos, 1) === '?') {
    241                 if ($pos < $len && ($pos = strpos($this->file->body, '?>', $pos)) !== false) {
     223            } elseif (substr($body, $pos, 1) === '?') {
     224                if ($pos < $len && ($pos = strpos($body, '?>', $pos)) !== false) {
    242225                    $pos += 2;
    243226                } else {
    244227                    return 'text/html';
    245228                }
    246             } elseif (substr($this->file->body, $pos, 3) === 'rss'
    247                 || substr($this->file->body, $pos, 7) === 'rdf:RDF') {
     229            } elseif (substr($body, $pos, 3) === 'rss'
     230                || substr($body, $pos, 7) === 'rdf:RDF') {
    248231                return 'application/rss+xml';
    249             } elseif (substr($this->file->body, $pos, 4) === 'feed') {
     232            } elseif (substr($body, $pos, 4) === 'feed') {
    250233                return 'application/atom+xml';
    251234            } else {
  • trunk/src/wp-includes/SimplePie/src/Copyright.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
     
    5114 *
    5215 * This class can be overloaded with {@see \SimplePie\SimplePie::set_copyright_class()}
    53  *
    54  * @package SimplePie
    55  * @subpackage API
    5616 */
    5717class Copyright
     
    6020     * Copyright URL
    6121     *
    62      * @var string
     22     * @var ?string
    6323     * @see get_url()
    6424     */
     
    6828     * Attribution
    6929     *
    70      * @var string
     30     * @var ?string
    7131     * @see get_attribution()
    7232     */
     
    7939     * properties and their accessors
    8040     */
    81     public function __construct($url = null, $label = null)
    82     {
     41    public function __construct(
     42        ?string $url = null,
     43        ?string $label = null
     44    ) {
    8345        $this->url = $url;
    8446        $this->label = $label;
  • trunk/src/wp-includes/SimplePie/src/Credit.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
     
    5114 *
    5215 * This class can be overloaded with {@see \SimplePie\SimplePie::set_credit_class()}
    53  *
    54  * @package SimplePie
    55  * @subpackage API
    5616 */
    5717class Credit
     
    6020     * Credited role
    6121     *
    62      * @var string
     22     * @var ?string
    6323     * @see get_role()
    6424     */
     
    6828     * Organizational scheme
    6929     *
    70      * @var string
     30     * @var ?string
    7131     * @see get_scheme()
    7232     */
     
    7636     * Credited name
    7737     *
    78      * @var string
     38     * @var ?string
    7939     * @see get_name()
    8040     */
     
    8747     * properties and their accessors
    8848     */
    89     public function __construct($role = null, $scheme = null, $name = null)
    90     {
     49    public function __construct(
     50        ?string $role = null,
     51        ?string $scheme = null,
     52        ?string $name = null
     53    ) {
    9154        $this->role = $role;
    9255        $this->scheme = $scheme;
  • trunk/src/wp-includes/SimplePie/src/Enclosure.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
     
    5114 *
    5215 * This class can be overloaded with {@see \SimplePie\SimplePie::set_enclosure_class()}
    53  *
    54  * @package SimplePie
    55  * @subpackage API
    5616 */
    5717class Enclosure
    5818{
    5919    /**
    60      * @var string
     20     * @var ?string
    6121     * @see get_bitrate()
    6222     */
     
    6424
    6525    /**
    66      * @var array
     26     * @var Caption[]|null
    6727     * @see get_captions()
    6828     */
     
    7030
    7131    /**
    72      * @var array
     32     * @var Category[]|null
    7333     * @see get_categories()
    7434     */
     
    7636
    7737    /**
    78      * @var int
     38     * @var ?int
    7939     * @see get_channels()
    8040     */
     
    8242
    8343    /**
    84      * @var \SimplePie\Copyright
     44     * @var ?Copyright
    8545     * @see get_copyright()
    8646     */
     
    8848
    8949    /**
    90      * @var array
     50     * @var Credit[]|null
    9151     * @see get_credits()
    9252     */
     
    9454
    9555    /**
    96      * @var string
     56     * @var ?string
    9757     * @see get_description()
    9858     */
     
    10060
    10161    /**
    102      * @var int
     62     * @var ?int
    10363     * @see get_duration()
    10464     */
     
    10666
    10767    /**
    108      * @var string
     68     * @var ?string
    10969     * @see get_expression()
    11070     */
     
    11272
    11373    /**
    114      * @var string
     74     * @var ?string
    11575     * @see get_framerate()
    11676     */
     
    11878
    11979    /**
    120      * @var string
     80     * @var ?string
    12181     * @see get_handler()
    12282     */
     
    12484
    12585    /**
    126      * @var array
     86     * @var string[]|null
    12787     * @see get_hashes()
    12888     */
     
    13090
    13191    /**
    132      * @var string
     92     * @var ?string
    13393     * @see get_height()
    13494     */
     
    142102
    143103    /**
    144      * @var array
     104     * @var string[]|null
    145105     * @see get_keywords()
    146106     */
     
    148108
    149109    /**
    150      * @var string
     110     * @var ?string
    151111     * @see get_language()
    152112     */
     
    154114
    155115    /**
    156      * @var string
     116     * @var ?int
    157117     * @see get_length()
    158118     */
     
    160120
    161121    /**
    162      * @var string
     122     * @var ?string
    163123     * @see get_link()
    164124     */
     
    166126
    167127    /**
    168      * @var string
     128     * @var ?string
    169129     * @see get_medium()
    170130     */
     
    172132
    173133    /**
    174      * @var string
     134     * @var ?string
    175135     * @see get_player()
    176136     */
     
    178138
    179139    /**
    180      * @var array
     140     * @var Rating[]|null
    181141     * @see get_ratings()
    182142     */
     
    184144
    185145    /**
    186      * @var array
     146     * @var ?Restriction[]
    187147     * @see get_restrictions()
    188148     */
     
    190150
    191151    /**
    192      * @var string
     152     * @var ?string
    193153     * @see get_sampling_rate()
    194154     */
     
    196156
    197157    /**
    198      * @var array
     158     * @var string[]|null
    199159     * @see get_thumbnails()
    200160     */
     
    202162
    203163    /**
    204      * @var string
     164     * @var ?string
    205165     * @see get_title()
    206166     */
     
    208168
    209169    /**
    210      * @var string
     170     * @var ?string
    211171     * @see get_type()
    212172     */
     
    214174
    215175    /**
    216      * @var string
     176     * @var ?string
    217177     * @see get_width()
    218178     */
     
    225185     * properties and their accessors
    226186     *
    227      * @uses idna_convert If available, this will convert an IDN
    228      */
    229     public function __construct($link = null, $type = null, $length = null, $javascript = null, $bitrate = null, $captions = null, $categories = null, $channels = null, $copyright = null, $credits = null, $description = null, $duration = null, $expression = null, $framerate = null, $hashes = null, $height = null, $keywords = null, $lang = null, $medium = null, $player = null, $ratings = null, $restrictions = null, $samplingrate = null, $thumbnails = null, $title = null, $width = null)
    230     {
     187     * @uses idn_to_ascii If available, this will convert an IDN
     188     *
     189     * @param null $javascript
     190     * @param Caption[]|null $captions
     191     * @param Category[]|null $categories
     192     * @param Credit[]|null $credits
     193     * @param string[]|null $hashes
     194     * @param string[]|null $keywords
     195     * @param Rating[]|null $ratings
     196     * @param Restriction[]|null $restrictions
     197     * @param string[]|null $thumbnails
     198     */
     199    public function __construct(
     200        ?string $link = null,
     201        ?string $type = null,
     202        ?int $length = null,
     203        $javascript = null,
     204        ?string $bitrate = null,
     205        ?array $captions = null,
     206        ?array $categories = null,
     207        ?int $channels = null,
     208        ?Copyright $copyright = null,
     209        ?array $credits = null,
     210        ?string $description = null,
     211        ?int $duration = null,
     212        ?string $expression = null,
     213        ?string $framerate = null,
     214        ?array $hashes = null,
     215        ?string $height = null,
     216        ?array $keywords = null,
     217        ?string $lang = null,
     218        ?string $medium = null,
     219        ?string $player = null,
     220        ?array $ratings = null,
     221        ?array $restrictions = null,
     222        ?string $samplingrate = null,
     223        ?array $thumbnails = null,
     224        ?string $title = null,
     225        ?string $width = null
     226    ) {
    231227        $this->bitrate = $bitrate;
    232228        $this->captions = $captions;
     
    255251        $this->width = $width;
    256252
    257         if (class_exists('idna_convert')) {
    258             $idn = new \idna_convert();
    259             $parsed = \SimplePie\Misc::parse_url($link);
    260             $this->link = \SimplePie\Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
     253        if (function_exists('idn_to_ascii')) {
     254            $parsed = \SimplePie\Misc::parse_url($link ?? '');
     255            if ($parsed['authority'] !== '' && !ctype_print($parsed['authority'])) {
     256                $authority = (string) \idn_to_ascii($parsed['authority'], \IDNA_NONTRANSITIONAL_TO_ASCII, \INTL_IDNA_VARIANT_UTS46);
     257                $this->link = \SimplePie\Misc::compress_parse_url($parsed['scheme'], $authority, $parsed['path'], $parsed['query'], $parsed['fragment']);
     258            }
    261259        }
    262260        $this->handler = $this->get_handler(); // Needs to load last
     
    294292     * @return \SimplePie\Caption|null
    295293     */
    296     public function get_caption($key = 0)
     294    public function get_caption(int $key = 0)
    297295    {
    298296        $captions = $this->get_captions();
     
    307305     * Get all captions
    308306     *
    309      * @return array|null Array of {@see \SimplePie\Caption} objects
     307     * @return Caption[]|null
    310308     */
    311309    public function get_captions()
     
    324322     * @return \SimplePie\Category|null
    325323     */
    326     public function get_category($key = 0)
     324    public function get_category(int $key = 0)
    327325    {
    328326        $categories = $this->get_categories();
     
    337335     * Get all categories
    338336     *
    339      * @return array|null Array of {@see \SimplePie\Category} objects
     337     * @return \SimplePie\Category[]|null
    340338     */
    341339    public function get_categories()
     
    382380     * @return \SimplePie\Credit|null
    383381     */
    384     public function get_credit($key = 0)
     382    public function get_credit(int $key = 0)
    385383    {
    386384        $credits = $this->get_credits();
     
    395393     * Get all credits
    396394     *
    397      * @return array|null Array of {@see \SimplePie\Credit} objects
     395     * @return Credit[]|null
    398396     */
    399397    public function get_credits()
     
    426424     * @return string|int|null 'hh:mm:ss' string if `$convert` was specified, otherwise integer (or null if none found)
    427425     */
    428     public function get_duration($convert = false)
     426    public function get_duration(bool $convert = false)
    429427    {
    430428        if ($this->duration !== null) {
     
    501499     * @return string|null Hash as per `media:hash`, prefixed with "$algo:"
    502500     */
    503     public function get_hash($key = 0)
     501    public function get_hash(int $key = 0)
    504502    {
    505503        $hashes = $this->get_hashes();
     
    514512     * Get all credits
    515513     *
    516      * @return array|null Array of strings, see {@see get_hash()}
     514     * @return string[]|null Array of strings, see {@see get_hash()}
    517515     */
    518516    public function get_hashes()
     
    560558     * @return string|null
    561559     */
    562     public function get_keyword($key = 0)
     560    public function get_keyword(int $key = 0)
    563561    {
    564562        $keywords = $this->get_keywords();
     
    573571     * Get all keywords
    574572     *
    575      * @return array|null Array of strings
     573     * @return string[]|null
    576574     */
    577575    public function get_keywords()
     
    587585     * Get length
    588586     *
    589      * @return float Length in bytes
     587     * @return ?int Length in bytes
    590588     */
    591589    public function get_length()
     
    648646     * @return \SimplePie\Rating|null
    649647     */
    650     public function get_rating($key = 0)
     648    public function get_rating(int $key = 0)
    651649    {
    652650        $ratings = $this->get_ratings();
     
    661659     * Get all ratings
    662660     *
    663      * @return array|null Array of {@see \SimplePie\Rating} objects
     661     * @return Rating[]|null
    664662     */
    665663    public function get_ratings()
     
    678676     * @return \SimplePie\Restriction|null
    679677     */
    680     public function get_restriction($key = 0)
     678    public function get_restriction(int $key = 0)
    681679    {
    682680        $restrictions = $this->get_restrictions();
     
    691689     * Get all restrictions
    692690     *
    693      * @return array|null Array of {@see \SimplePie\Restriction} objects
     691     * @return Restriction[]|null
    694692     */
    695693    public function get_restrictions()
     
    737735     * @return string|null Thumbnail URL
    738736     */
    739     public function get_thumbnail($key = 0)
     737    public function get_thumbnail(int $key = 0)
    740738    {
    741739        $thumbnails = $this->get_thumbnails();
     
    750748     * Get all thumbnails
    751749     *
    752      * @return array|null Array of thumbnail URLs
     750     * @return string[]|null Array of thumbnail URLs
    753751     */
    754752    public function get_thumbnails()
     
    809807     * @deprecated Use the second parameter to {@see embed} instead
    810808     *
    811      * @param array|string $options See first parameter to {@see embed}
     809     * @param array<string, mixed>|string $options See first parameter to {@see embed}
    812810     * @return string HTML string to output
    813811     */
     
    858856     *
    859857     * @todo If the dimensions for media:content are defined, use them when width/height are set to 'auto'.
    860      * @param array|string $options Comma-separated key:value list, or array
     858     * @param array<string, mixed>|string $options Comma-separated key:value list, or array
    861859     * @param bool $native Use `<embed>`
    862860     * @return string HTML string to output
    863861     */
    864     public function embed($options = '', $native = false)
     862    public function embed($options = '', bool $native = false)
    865863    {
    866864        // Set up defaults
     
    934932        }
    935933
    936         $mime = explode('/', $type, 2);
     934        $mime = explode('/', (string) $type, 2);
    937935        $mime = $mime[0];
    938936
     
    995993        // Preferred handler for MP3 file types.
    996994        elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== '')) {
    997             $height += 20;
     995            if (is_numeric($height)) {
     996                $height += 20;
     997            }
     998
    998999            if ($native) {
    9991000                $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>";
     
    10061007        // Only handle MP3's if the Flash Media Player is not present.
    10071008        elseif ($handler === 'quicktime' || ($handler === 'mp3' && $mediaplayer === '')) {
    1008             $height += 16;
     1009            if (is_numeric($height)) {
     1010                $height += 16;
     1011            }
     1012
    10091013            if ($native) {
    10101014                if ($placeholder !== '') {
     
    10201024        // Windows Media
    10211025        elseif ($handler === 'wmedia') {
    1022             $height += 45;
     1026            if (is_numeric($height)) {
     1027                $height += 45;
     1028            }
     1029
    10231030            if ($native) {
    10241031                $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>";
     
    10451052     * @see get_type()
    10461053     * @param bool $find_handler Internal use only, use {@see get_handler()} instead
    1047      * @return string MIME type
    1048      */
    1049     public function get_real_type($find_handler = false)
     1054     * @return string|null MIME type
     1055     */
     1056    public function get_real_type(bool $find_handler = false)
    10501057    {
    10511058        // Mime-types by handler.
     
    10561063        $types_mp3 = ['audio/mp3', 'audio/x-mp3', 'audio/mpeg', 'audio/x-mpeg']; // MP3
    10571064
    1058         if ($this->get_type() !== null) {
    1059             $type = strtolower($this->type);
    1060         } else {
    1061             $type = null;
     1065        $type = $this->get_type();
     1066        if ($type !== null) {
     1067            $type = strtolower($type);
    10621068        }
    10631069
     
    11151121                    break;
    11161122
    1117                     // Video mime-types
    11181123                case '3gp':
    11191124                case '3gpp':
     1125                    // Video mime-types
    11201126                    $type = 'video/3gpp';
    11211127                    break;
     
    11781184                    break;
    11791185
     1186                case 'spl':
    11801187                    // Flash mime-types
    1181                 case 'spl':
    11821188                    $type = 'application/futuresplash';
    11831189                    break;
  • trunk/src/wp-includes/SimplePie/src/Exception.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
     
    4912/**
    5013 * General SimplePie exception class
    51  *
    52  * @package SimplePie
    5314 */
    5415class Exception extends NativeException
  • trunk/src/wp-includes/SimplePie/src/File.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
     9
     10use SimplePie\HTTP\Response;
    4611
    4712/**
     
    5217 * This class can be overloaded with {@see \SimplePie\SimplePie::set_file_class()}
    5318 *
    54  * @package SimplePie
    55  * @subpackage HTTP
    5619 * @todo Move to properly supporting RFC2616 (HTTP/1.1)
    5720 */
    58 class File
     21class File implements Response
    5922{
     23    /**
     24     * @var string The final URL after following all redirects
     25     * @deprecated Use `get_final_requested_uri()` method.
     26     */
    6027    public $url;
     28
     29    /**
     30     * @var ?string User agent to use in requests
     31     * @deprecated Set the user agent in constructor.
     32     */
    6133    public $useragent;
     34
     35    /** @var bool */
    6236    public $success = true;
     37
     38    /** @var array<string, non-empty-array<string>> Canonical representation of headers */
     39    private $parsed_headers = [];
     40    /** @var array<string, string> Last known value of $headers property (used to detect external modification) */
     41    private $last_headers = [];
     42    /**
     43     * @var array<string, string> Headers as string for BC
     44     * @deprecated Use `get_headers()` method.
     45     */
    6346    public $headers = [];
     47
     48    /**
     49     * @var ?string Body of the HTTP response
     50     * @deprecated Use `get_body_content()` method.
     51     */
    6452    public $body;
     53
     54    /**
     55     * @var int Status code of the HTTP response
     56     * @deprecated Use `get_status_code()` method.
     57     */
    6558    public $status_code = 0;
     59
     60    /** @var non-negative-int Number of redirect that were already performed during this request sequence. */
    6661    public $redirects = 0;
     62
     63    /** @var ?string */
    6764    public $error;
     65
     66    /**
     67     * @var int-mask-of<SimplePie::FILE_SOURCE_*> Bit mask representing the method used to fetch the file and whether it is a local file or remote file obtained over HTTP.
     68     * @deprecated Backend is implementation detail which you should not care about; to see if the file was retrieved over HTTP, check if `get_final_requested_uri()` with `Misc::is_remote_uri()`.
     69     */
    6870    public $method = \SimplePie\SimplePie::FILE_SOURCE_NONE;
     71
     72    /**
     73     * @var string The permanent URL or the resource (first URL after the prefix of (only) permanent redirects)
     74     * @deprecated Use `get_permanent_uri()` method.
     75     */
    6976    public $permanent_url;
    70 
    71     public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false, $curl_options = [])
    72     {
    73         if (class_exists('idna_convert')) {
    74             $idn = new \idna_convert();
     77    /** @var bool Whether the permanent URL is still writeable (prefix of permanent redirects has not ended) */
     78    private $permanentUrlMutable = true;
     79
     80    /**
     81     * @param string $url
     82     * @param int $timeout
     83     * @param int $redirects
     84     * @param ?array<string, string> $headers
     85     * @param ?string $useragent
     86     * @param bool $force_fsockopen
     87     * @param array<int, mixed> $curl_options
     88     */
     89    public function __construct(string $url, int $timeout = 10, int $redirects = 5, ?array $headers = null, ?string $useragent = null, bool $force_fsockopen = false, array $curl_options = [])
     90    {
     91        if (function_exists('idn_to_ascii')) {
    7592            $parsed = \SimplePie\Misc::parse_url($url);
    76             $url = \SimplePie\Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], null);
     93            if ($parsed['authority'] !== '' && !ctype_print($parsed['authority'])) {
     94                $authority = (string) \idn_to_ascii($parsed['authority'], \IDNA_NONTRANSITIONAL_TO_ASCII, \INTL_IDNA_VARIANT_UTS46);
     95                $url = \SimplePie\Misc::compress_parse_url($parsed['scheme'], $authority, $parsed['path'], $parsed['query'], null);
     96            }
    7797        }
    7898        $this->url = $url;
    79         $this->permanent_url = $url;
     99        if ($this->permanentUrlMutable) {
     100            $this->permanent_url = $url;
     101        }
    80102        $this->useragent = $useragent;
    81103        if (preg_match('/^http(s)?:\/\//i', $url)) {
    82104            if ($useragent === null) {
    83                 $useragent = ini_get('user_agent');
     105                $useragent = (string) ini_get('user_agent');
    84106                $this->useragent = $useragent;
    85107            }
     
    94116                    $headers2[] = "$key: $value";
    95117                }
     118                if (isset($curl_options[CURLOPT_HTTPHEADER])) {
     119                    if (is_array($curl_options[CURLOPT_HTTPHEADER])) {
     120                        $headers2 = array_merge($headers2, $curl_options[CURLOPT_HTTPHEADER]);
     121                    }
     122                    unset($curl_options[CURLOPT_HTTPHEADER]);
     123                }
    96124                if (version_compare(\SimplePie\Misc::get_curl_version(), '7.10.5', '>=')) {
    97125                    curl_setopt($fp, CURLOPT_ENCODING, '');
     
    110138                }
    111139
    112                 $this->headers = curl_exec($fp);
    113                 if (curl_errno($fp) === 23 || curl_errno($fp) === 61) {
     140                $responseHeaders = curl_exec($fp);
     141                if (curl_errno($fp) === CURLE_WRITE_ERROR || curl_errno($fp) === CURLE_BAD_CONTENT_ENCODING) {
    114142                    curl_setopt($fp, CURLOPT_ENCODING, 'none');
    115                     $this->headers = curl_exec($fp);
     143                    $responseHeaders = curl_exec($fp);
    116144                }
    117145                $this->status_code = curl_getinfo($fp, CURLINFO_HTTP_CODE);
     
    124152                        $this->url = $info['url'];
    125153                    }
    126                     curl_close($fp);
    127                     $this->headers = \SimplePie\HTTP\Parser::prepareHeaders($this->headers, $info['redirect_count'] + 1);
    128                     $parser = new \SimplePie\HTTP\Parser($this->headers);
     154                    // For PHPStan: We already checked that error did not occur.
     155                    assert(is_array($info) && $info['redirect_count'] >= 0);
     156                    if (\PHP_VERSION_ID < 80000) {
     157                        curl_close($fp);
     158                    }
     159                    $responseHeaders = \SimplePie\HTTP\Parser::prepareHeaders((string) $responseHeaders, $info['redirect_count'] + 1);
     160                    $parser = new \SimplePie\HTTP\Parser($responseHeaders, true);
    129161                    if ($parser->parse()) {
    130                         $this->headers = $parser->headers;
    131                         $this->body = trim($parser->body);
     162                        $this->set_headers($parser->headers);
     163                        $this->body = $parser->body;
    132164                        $this->status_code = $parser->status_code;
    133                         if ((in_array($this->status_code, [300, 301, 302, 303, 307]) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) {
     165                        if ((in_array($this->status_code, [300, 301, 302, 303, 307]) || $this->status_code > 307 && $this->status_code < 400) && ($locationHeader = $this->get_header_line('location')) !== '' && $this->redirects < $redirects) {
    134166                            $this->redirects++;
    135                             $location = \SimplePie\Misc::absolutize_url($this->headers['location'], $url);
    136                             $previousStatusCode = $this->status_code;
     167                            $location = \SimplePie\Misc::absolutize_url($locationHeader, $url);
     168                            if ($location === false) {
     169                                $this->error = "Invalid redirect location, trying to base “{$locationHeader}” onto “{$url}”";
     170                                $this->success = false;
     171                                return;
     172                            }
     173                            $this->permanentUrlMutable = $this->permanentUrlMutable && ($this->status_code == 301 || $this->status_code == 308);
    137174                            $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen, $curl_options);
    138                             $this->permanent_url = ($previousStatusCode == 301) ? $location : $url;
    139175                            return;
    140176                        }
     
    143179            } else {
    144180                $this->method = \SimplePie\SimplePie::FILE_SOURCE_REMOTE | \SimplePie\SimplePie::FILE_SOURCE_FSOCKOPEN;
    145                 $url_parts = parse_url($url);
     181                if (($url_parts = parse_url($url)) === false) {
     182                    throw new \InvalidArgumentException('Malformed URL: ' . $url);
     183                }
     184                if (!isset($url_parts['host'])) {
     185                    throw new \InvalidArgumentException('Missing hostname: ' . $url);
     186                }
    146187                $socket_host = $url_parts['host'];
    147188                if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') {
    148                     $socket_host = "ssl://$url_parts[host]";
     189                    $socket_host = 'ssl://' . $socket_host;
    149190                    $url_parts['port'] = 443;
    150191                }
     
    185226                    $info = stream_get_meta_data($fp);
    186227
    187                     $this->headers = '';
     228                    $responseHeaders = '';
    188229                    while (!$info['eof'] && !$info['timed_out']) {
    189                         $this->headers .= fread($fp, 1160);
     230                        $responseHeaders .= fread($fp, 1160);
    190231                        $info = stream_get_meta_data($fp);
    191232                    }
    192233                    if (!$info['timed_out']) {
    193                         $parser = new \SimplePie\HTTP\Parser($this->headers);
     234                        $parser = new \SimplePie\HTTP\Parser($responseHeaders, true);
    194235                        if ($parser->parse()) {
    195                             $this->headers = $parser->headers;
     236                            $this->set_headers($parser->headers);
    196237                            $this->body = $parser->body;
    197238                            $this->status_code = $parser->status_code;
    198                             if ((in_array($this->status_code, [300, 301, 302, 303, 307]) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) {
     239                            if ((in_array($this->status_code, [300, 301, 302, 303, 307]) || $this->status_code > 307 && $this->status_code < 400) && ($locationHeader = $this->get_header_line('location')) !== '' && $this->redirects < $redirects) {
    199240                                $this->redirects++;
    200                                 $location = \SimplePie\Misc::absolutize_url($this->headers['location'], $url);
    201                                 $previousStatusCode = $this->status_code;
     241                                $location = \SimplePie\Misc::absolutize_url($locationHeader, $url);
     242                                $this->permanentUrlMutable = $this->permanentUrlMutable && ($this->status_code == 301 || $this->status_code == 308);
     243                                if ($location === false) {
     244                                    $this->error = "Invalid redirect location, trying to base “{$locationHeader}” onto “{$url}”";
     245                                    $this->success = false;
     246                                    return;
     247                                }
    202248                                $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen, $curl_options);
    203                                 $this->permanent_url = ($previousStatusCode == 301) ? $location : $url;
    204249                                return;
    205250                            }
    206                             if (isset($this->headers['content-encoding'])) {
     251                            if (($contentEncodingHeader = $this->get_header_line('content-encoding')) !== '') {
    207252                                // Hey, we act dumb elsewhere, so let's do that here too
    208                                 switch (strtolower(trim($this->headers['content-encoding'], "\x09\x0A\x0D\x20"))) {
     253                                switch (strtolower(trim($contentEncodingHeader, "\x09\x0A\x0D\x20"))) {
    209254                                    case 'gzip':
    210255                                    case 'x-gzip':
    211                                         $decoder = new \SimplePie\Gzdecode($this->body);
    212                                         if (!$decoder->parse()) {
     256                                        if (($decompressed = gzdecode($this->body)) === false) {
    213257                                            $this->error = 'Unable to decode HTTP "gzip" stream';
    214258                                            $this->success = false;
    215259                                        } else {
    216                                             $this->body = trim($decoder->data);
     260                                            $this->body = $decompressed;
    217261                                        }
    218262                                        break;
     
    223267                                        } elseif (($decompressed = gzuncompress($this->body)) !== false) {
    224268                                            $this->body = $decompressed;
    225                                         } elseif (function_exists('gzdecode') && ($decompressed = gzdecode($this->body)) !== false) {
     269                                        } elseif (($decompressed = gzdecode($this->body)) !== false) {
    226270                                            $this->body = $decompressed;
    227271                                        } else {
     
    246290        } else {
    247291            $this->method = \SimplePie\SimplePie::FILE_SOURCE_LOCAL | \SimplePie\SimplePie::FILE_SOURCE_FILE_GET_CONTENTS;
    248             if (empty($url) || !($this->body = trim(file_get_contents($url)))) {
    249                 $this->error = 'file_get_contents could not read the file';
     292            if (empty($url) || !is_readable($url) ||  false === $filebody = file_get_contents($url)) {
     293                $this->body = '';
     294                $this->error = sprintf('file "%s" is not readable', $url);
    250295                $this->success = false;
     296            } else {
     297                $this->body = $filebody;
     298                $this->status_code = 200;
    251299            }
    252300        }
     301        if ($this->success) {
     302            assert($this->body !== null); // For PHPStan
     303            // Leading whitespace may cause XML parsing errors (XML declaration cannot be preceded by anything other than BOM) so we trim it.
     304            // Note that unlike built-in `trim` function’s default settings, we do not trim `\x00` to avoid breaking characters in UTF-16 or UTF-32 encoded strings.
     305            // We also only do that when the whitespace is followed by `<`, so that we do not break e.g. UTF-16LE encoded whitespace like `\n\x00` in half.
     306            $this->body = preg_replace('/^[ \n\r\t\v]+</', '<', $this->body);
     307        }
     308    }
     309
     310    public function get_permanent_uri(): string
     311    {
     312        return (string) $this->permanent_url;
     313    }
     314
     315    public function get_final_requested_uri(): string
     316    {
     317        return (string) $this->url;
     318    }
     319
     320    public function get_status_code(): int
     321    {
     322        return (int) $this->status_code;
     323    }
     324
     325    public function get_headers(): array
     326    {
     327        $this->maybe_update_headers();
     328        return $this->parsed_headers;
     329    }
     330
     331    public function has_header(string $name): bool
     332    {
     333        $this->maybe_update_headers();
     334        return $this->get_header($name) !== [];
     335    }
     336
     337    public function get_header(string $name): array
     338    {
     339        $this->maybe_update_headers();
     340        return $this->parsed_headers[strtolower($name)] ?? [];
     341    }
     342
     343    public function with_header(string $name, $value)
     344    {
     345        $this->maybe_update_headers();
     346        $new = clone $this;
     347
     348        $newHeader = [
     349            strtolower($name) => (array) $value,
     350        ];
     351        $new->set_headers($newHeader + $this->get_headers());
     352
     353        return $new;
     354    }
     355
     356    public function get_header_line(string $name): string
     357    {
     358        $this->maybe_update_headers();
     359        return implode(', ', $this->get_header($name));
     360    }
     361
     362    public function get_body_content(): string
     363    {
     364        return (string) $this->body;
     365    }
     366
     367    /**
     368     * Check if the $headers property was changed and update the internal state accordingly.
     369     */
     370    private function maybe_update_headers(): void
     371    {
     372        if ($this->headers !== $this->last_headers) {
     373            $this->parsed_headers = array_map(
     374                function (string $header_line): array {
     375                    if (strpos($header_line, ',') === false) {
     376                        return [$header_line];
     377                    } else {
     378                        return array_map('trim', explode(',', $header_line));
     379                    }
     380                },
     381                $this->headers
     382            );
     383        }
     384        $this->last_headers = $this->headers;
     385    }
     386
     387    /**
     388     * Sets headers internally.
     389     *
     390     * @param array<string, non-empty-array<string>> $headers
     391     */
     392    private function set_headers(array $headers): void
     393    {
     394        $this->parsed_headers = $headers;
     395        $this->headers = self::flatten_headers($headers);
     396        $this->last_headers = $this->headers;
     397    }
     398
     399    /**
     400     * Converts PSR-7 compatible headers into a legacy format.
     401     *
     402     * @param array<string, non-empty-array<string>> $headers
     403     *
     404     * @return array<string, string>
     405     */
     406    private function flatten_headers(array $headers): array
     407    {
     408        return array_map(function (array $values): string {
     409            return implode(',', $values);
     410        }, $headers);
     411    }
     412
     413    /**
     414     * Create a File instance from another Response
     415     *
     416     * For BC reasons in some places there MUST be a `File` instance
     417     * instead of a `Response` implementation
     418     *
     419     * @see Locator::__construct()
     420     * @internal
     421     */
     422    final public static function fromResponse(Response $response): self
     423    {
     424        $headers = [];
     425
     426        foreach ($response->get_headers() as $name => $header) {
     427            $headers[$name] = implode(', ', $header);
     428        }
     429
     430        /** @var File */
     431        $file = (new \ReflectionClass(File::class))->newInstanceWithoutConstructor();
     432
     433        $file->url = $response->get_final_requested_uri();
     434        $file->useragent = null;
     435        $file->headers = $headers;
     436        $file->body = $response->get_body_content();
     437        $file->status_code = $response->get_status_code();
     438        $file->permanent_url = $response->get_permanent_uri();
     439
     440        return $file;
    253441    }
    254442}
  • trunk/src/wp-includes/SimplePie/src/Gzdecode.php

    r59142 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
     
    4811 * Decode 'gzip' encoded HTTP data
    4912 *
    50  * @package SimplePie
    51  * @subpackage HTTP
    5213 * @link http://www.gzip.org/format.txt
     14 * @link https://www.php.net/manual/en/function.gzdecode.php
     15 * @deprecated since SimplePie 1.9.0, use `gzdecode` function instead.
    5316 */
    5417class Gzdecode
     
    180143     * @param mixed $value
    181144     */
    182     public function __set($name, $value)
     145    public function __set(string $name, $value)
    183146    {
    184147        throw new Exception("Cannot write property $name");
     
    190153     * @param string $data
    191154     */
    192     public function __construct($data)
     155    public function __construct(string $data)
    193156    {
    194157        $this->compressed_data = $data;
     
    225188            $mtime = substr($this->compressed_data, $this->position, 4);
    226189            // Reverse the string if we're on a big-endian arch because l is the only signed long and is machine endianness
    227             if (current(unpack('S', "\x00\x01")) === 1) {
     190            if (current((array) unpack('S', "\x00\x01")) === 1) {
    228191                $mtime = strrev($mtime);
    229192            }
    230             $this->MTIME = current(unpack('l', $mtime));
     193            $this->MTIME = current((array) unpack('l', $mtime));
    231194            $this->position += 4;
    232195
     
    249212
    250213                // Get the length of the extra field
    251                 $len = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
     214                $len = current((array) unpack('v', substr($this->compressed_data, $this->position, 2)));
    252215                $this->position += 2;
    253216
     
    301264                if ($this->compressed_size >= $this->min_compressed_size) {
    302265                    // Read the CRC
    303                     $crc = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
     266                    $crc = current((array) unpack('v', substr($this->compressed_data, $this->position, 2)));
    304267
    305268                    // Check the CRC matches
     
    315278
    316279            // Decompress the actual data
    317             if (($this->data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false) {
    318                 return false;
    319             }
    320 
     280            if (($data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false) {
     281                return false;
     282            }
     283
     284            $this->data = $data;
    321285            $this->position = $this->compressed_size - 8;
    322286
    323287            // Check CRC of data
    324             $crc = current(unpack('V', substr($this->compressed_data, $this->position, 4)));
     288            $crc = current((array) unpack('V', substr($this->compressed_data, $this->position, 4)));
    325289            $this->position += 4;
    326290            /*if (extension_loaded('hash') && sprintf('%u', current(unpack('V', hash('crc32b', $this->data)))) !== sprintf('%u', $crc))
     
    330294
    331295            // Check ISIZE of data
    332             $isize = current(unpack('V', substr($this->compressed_data, $this->position, 4)));
     296            $isize = current((array) unpack('V', substr($this->compressed_data, $this->position, 4)));
    333297            $this->position += 4;
    334298            if (sprintf('%u', strlen($this->data) & 0xFFFFFFFF) !== sprintf('%u', $isize)) {
  • trunk/src/wp-includes/SimplePie/src/HTTP/Parser.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie\HTTP;
     
    4710/**
    4811 * HTTP Response Parser
    49  *
    50  * @package SimplePie
    51  * @subpackage HTTP
     12 * @template Psr7Compatible of bool
    5213 */
    5314class Parser
     
    7536
    7637    /**
     38     * @var Psr7Compatible whether headers are compatible with PSR-7 format.
     39     */
     40    private $psr7Compatible;
     41
     42    /**
    7743     * Key/value pairs of the headers
    7844     *
    79      * @var array
     45     * @var (Psr7Compatible is true ? array<string, non-empty-array<string>> : array<string, string>)
    8046     */
    8147    public $headers = [];
     
    145111
    146112    /**
    147      * Name of the hedaer currently being parsed
     113     * Name of the header currently being parsed
    148114     *
    149115     * @var string
     
    152118
    153119    /**
    154      * Value of the hedaer currently being parsed
     120     * Value of the header currently being parsed
    155121     *
    156122     * @var string
     
    162128     *
    163129     * @param string $data Input data
    164      */
    165     public function __construct($data)
     130     * @param Psr7Compatible $psr7Compatible Whether the data types are in format compatible with PSR-7.
     131     */
     132    public function __construct(string $data, bool $psr7Compatible = false)
    166133    {
    167134        $this->data = $data;
    168135        $this->data_length = strlen($this->data);
     136        $this->psr7Compatible = $psr7Compatible;
    169137    }
    170138
     
    185153        }
    186154
    187         $this->http_version = '';
     155        // Reset the parser state.
     156        $this->http_version = 0.0;
    188157        $this->status_code = 0;
    189158        $this->reason = '';
     
    219188    /**
    220189     * Parse the HTTP version
     190     * @return void
    221191     */
    222192    protected function http_version()
     
    224194        if (strpos($this->data, "\x0A") !== false && strtoupper(substr($this->data, 0, 5)) === 'HTTP/') {
    225195            $len = strspn($this->data, '0123456789.', 5);
    226             $this->http_version = substr($this->data, 5, $len);
     196            $http_version = substr($this->data, 5, $len);
    227197            $this->position += 5 + $len;
    228             if (substr_count($this->http_version, '.') <= 1) {
    229                 $this->http_version = (float) $this->http_version;
     198            if (substr_count($http_version, '.') <= 1) {
     199                $this->http_version = (float) $http_version;
    230200                $this->position += strspn($this->data, "\x09\x20", $this->position);
    231201                $this->state = self::STATE_STATUS;
     
    240210    /**
    241211     * Parse the status code
     212     * @return void
    242213     */
    243214    protected function status()
     
    254225    /**
    255226     * Parse the reason phrase
     227     * @return void
    256228     */
    257229    protected function reason()
     
    263235    }
    264236
     237    private function add_header(string $name, string $value): void
     238    {
     239        if ($this->psr7Compatible) {
     240            // For PHPStan: should be enforced by template parameter but PHPStan is not smart enough.
     241            /** @var array<string, non-empty-array<string>> */
     242            $headers = &$this->headers;
     243            $headers[$name][] = $value;
     244        } else {
     245            // For PHPStan: should be enforced by template parameter but PHPStan is not smart enough.
     246            /** @var array<string, string>) */
     247            $headers = &$this->headers;
     248            $headers[$name] .= ', ' . $value;
     249        }
     250    }
     251
     252    private function replace_header(string $name, string $value): void
     253    {
     254        if ($this->psr7Compatible) {
     255            // For PHPStan: should be enforced by template parameter but PHPStan is not smart enough.
     256            /** @var array<string, non-empty-array<string>> */
     257            $headers = &$this->headers;
     258            $headers[$name] = [$value];
     259        } else {
     260            // For PHPStan: should be enforced by template parameter but PHPStan is not smart enough.
     261            /** @var array<string, string>) */
     262            $headers = &$this->headers;
     263            $headers[$name] = $value;
     264        }
     265    }
     266
    265267    /**
    266268     * Deal with a new line, shifting data around as needed
     269     * @return void
    267270     */
    268271    protected function new_line()
     
    273276            // We should only use the last Content-Type header. c.f. issue #1
    274277            if (isset($this->headers[$this->name]) && $this->name !== 'content-type') {
    275                 $this->headers[$this->name] .= ', ' . $this->value;
     278                $this->add_header($this->name, $this->value);
    276279            } else {
    277                 $this->headers[$this->name] = $this->value;
     280                $this->replace_header($this->name, $this->value);
    278281            }
    279282        }
     
    293296    /**
    294297     * Parse a header name
     298     * @return void
    295299     */
    296300    protected function name()
     
    313317    /**
    314318     * Parse LWS, replacing consecutive LWS characters with a single space
     319     * @return void
    315320     */
    316321    protected function linear_whitespace()
     
    329334    /**
    330335     * See what state to move to while within non-quoted header values
     336     * @return void
    331337     */
    332338    protected function value()
     
    363369    /**
    364370     * Parse a header value while outside quotes
     371     * @return void
    365372     */
    366373    protected function value_char()
     
    374381    /**
    375382     * See what state to move to while within quoted header values
     383     * @return void
    376384     */
    377385    protected function quote()
     
    405413    /**
    406414     * Parse a header value while within quotes
     415     * @return void
    407416     */
    408417    protected function quote_char()
     
    416425    /**
    417426     * Parse an escaped character within quotes
     427     * @return void
    418428     */
    419429    protected function quote_escaped()
     
    426436    /**
    427437     * Parse the body
     438     * @return void
    428439     */
    429440    protected function body()
     
    440451    /**
    441452     * Parsed a "Transfer-Encoding: chunked" body
     453     * @return void
    442454     */
    443455    protected function chunked()
     
    460472
    461473            $length = hexdec(trim($matches[1]));
     474            // For PHPStan: this will only be float when larger than PHP_INT_MAX.
     475            // But even on 32-bit systems, it would mean 2GiB chunk, which sounds unlikely.
     476            \assert(\is_int($length), "Length needs to be shorter than PHP_INT_MAX");
    462477            if ($length === 0) {
    463478                // Ignore trailer headers
     
    486501     *
    487502     * @param string  $headers Raw headers
    488      * @param integer $count  Redirection count. Default to 1.
     503     * @param non-negative-int $count Redirection count. Default to 1.
    489504     *
    490505     * @return string
    491506     */
    492     public static function prepareHeaders($headers, $count = 1)
     507    public static function prepareHeaders(string $headers, int $count = 1)
    493508    {
    494509        $data = explode("\r\n\r\n", $headers, $count);
  • trunk/src/wp-includes/SimplePie/src/IRI.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-FileCopyrightText: 2008 Steve Minutillo
     5// SPDX-License-Identifier: BSD-3-Clause
     6
     7declare(strict_types=1);
    448
    459namespace SimplePie;
     
    4812 * IRI parser/serialiser/normaliser
    4913 *
    50  * @package SimplePie
    51  * @subpackage HTTP
    52  * @author Sam Sneddon
    53  * @author Steve Minutillo
    54  * @author Ryan McCue
    55  * @copyright 2007-2012 Sam Sneddon, Steve Minutillo, Ryan McCue
    56  * @license http://www.opensource.org/licenses/bsd-license.php
     14 * @property ?string $scheme
     15 * @property ?string $userinfo
     16 * @property ?string $host
     17 * @property ?int $port
     18 * @property-write int|string|null $port
     19 * @property ?string $authority
     20 * @property string $path
     21 * @property ?string $query
     22 * @property ?string $fragment
    5723 */
    5824class IRI
     
    6127     * Scheme
    6228     *
     29     * @var ?string
     30     */
     31    protected $scheme = null;
     32
     33    /**
     34     * User Information
     35     *
     36     * @var ?string
     37     */
     38    protected $iuserinfo = null;
     39
     40    /**
     41     * ihost
     42     *
     43     * @var ?string
     44     */
     45    protected $ihost = null;
     46
     47    /**
     48     * Port
     49     *
     50     * @var ?int
     51     */
     52    protected $port = null;
     53
     54    /**
     55     * ipath
     56     *
    6357     * @var string
    6458     */
    65     protected $scheme = null;
    66 
    67     /**
    68      * User Information
    69      *
    70      * @var string
    71      */
    72     protected $iuserinfo = null;
    73 
    74     /**
    75      * ihost
    76      *
    77      * @var string
    78      */
    79     protected $ihost = null;
    80 
    81     /**
    82      * Port
    83      *
    84      * @var string
    85      */
    86     protected $port = null;
    87 
    88     /**
    89      * ipath
    90      *
    91      * @var string
    92      */
    9359    protected $ipath = '';
    9460
     
    9662     * iquery
    9763     *
    98      * @var string
     64     * @var ?string
    9965     */
    10066    protected $iquery = null;
     
    10369     * ifragment
    10470     *
    105      * @var string
     71     * @var ?string
    10672     */
    10773    protected $ifragment = null;
     
    11278     * Each key is the scheme, each value is an array with each key as the IRI
    11379     * part and value as the default value for that part.
     80     *
     81     * @var array<string, array<string, mixed>>
    11482     */
    11583    protected $normalization = [
     
    140108    public function __toString()
    141109    {
    142         return $this->get_iri();
     110        return (string) $this->get_iri();
    143111    }
    144112
     
    148116     * @param string $name Property name
    149117     * @param mixed $value Property value
    150      */
    151     public function __set($name, $value)
    152     {
    153         if (method_exists($this, 'set_' . $name)) {
    154             call_user_func([$this, 'set_' . $name], $value);
     118     * @return void
     119     */
     120    public function __set(string $name, $value)
     121    {
     122        $callable = [$this, 'set_' . $name];
     123        if (is_callable($callable)) {
     124            call_user_func($callable, $value);
    155125        } elseif (
    156126            $name === 'iauthority'
     
    171141     * @return mixed
    172142     */
    173     public function __get($name)
     143    public function __get(string $name)
    174144    {
    175145        // isset() returns false for null, we don't want to do that
     
    188158        }
    189159        // host -> ihost
    190         elseif (($prop = 'i' . $name) && array_key_exists($prop, $props)) {
     160        elseif (array_key_exists($prop = 'i' . $name, $props)) {
    191161            $name = $prop;
    192162            $return = $this->$prop;
     
    214184     * @return bool
    215185     */
    216     public function __isset($name)
     186    public function __isset(string $name)
    217187    {
    218188        return method_exists($this, 'get_' . $name) || isset($this->$name);
     
    223193     *
    224194     * @param string $name Property name
    225      */
    226     public function __unset($name)
    227     {
    228         if (method_exists($this, 'set_' . $name)) {
    229             call_user_func([$this, 'set_' . $name], '');
     195     * @return void
     196     */
     197    public function __unset(string $name)
     198    {
     199        $callable = [$this, 'set_' . $name];
     200        if (is_callable($callable)) {
     201            call_user_func($callable, '');
    230202        }
    231203    }
     
    234206     * Create a new IRI object, from a specified string
    235207     *
    236      * @param string $iri
    237      */
    238     public function __construct($iri = null)
     208     * @param string|null $iri
     209     */
     210    public function __construct(?string $iri = null)
    239211    {
    240212        $this->set_iri($iri);
     
    243215    /**
    244216     * Clean up
     217     * @return void
    245218     */
    246219    public function __destruct()
     
    322295     *
    323296     * @param string $iri
    324      * @return array
    325      */
    326     protected function parse_iri($iri)
     297     * @return array{
     298     *   scheme: string|null,
     299     *   authority: string|null,
     300     *   path: string,
     301     *   query: string|null,
     302     *   fragment: string|null,
     303     * }|false
     304     */
     305    protected function parse_iri(string $iri)
    327306    {
    328307        $iri = trim($iri, "\x20\x09\x0A\x0C\x0D");
    329         if (preg_match('/^((?P<scheme>[^:\/?#]+):)?(\/\/(?P<authority>[^\/?#]*))?(?P<path>[^?#]*)(\?(?P<query>[^#]*))?(#(?P<fragment>.*))?$/', $iri, $match)) {
    330             if ($match[1] === '') {
    331                 $match['scheme'] = null;
    332             }
    333             if (!isset($match[3]) || $match[3] === '') {
    334                 $match['authority'] = null;
    335             }
    336             if (!isset($match[5])) {
    337                 $match['path'] = '';
    338             }
    339             if (!isset($match[6]) || $match[6] === '') {
    340                 $match['query'] = null;
    341             }
    342             if (!isset($match[8]) || $match[8] === '') {
    343                 $match['fragment'] = null;
    344             }
     308        if (preg_match('/^(?:(?P<scheme>[^:\/?#]+):)?(:?\/\/(?P<authority>[^\/?#]*))?(?P<path>[^?#]*)(?:\?(?P<query>[^#]*))?(?:#(?P<fragment>.*))?$/', $iri, $match, \PREG_UNMATCHED_AS_NULL)) {
     309            // TODO: Remove once we require PHP ≥ 7.4.
     310            $match['query'] = $match['query'] ?? null;
     311            $match['fragment'] = $match['fragment'] ?? null;
    345312            return $match;
    346313        }
     
    356323     * @return string
    357324     */
    358     protected function remove_dot_segments($input)
     325    protected function remove_dot_segments(string $input)
    359326    {
    360327        $output = '';
     
    405372     * @return string
    406373     */
    407     protected function replace_invalid_with_pct_encoding($string, $extra_chars, $iprivate = false)
     374    protected function replace_invalid_with_pct_encoding(string $string, string $extra_chars, bool $iprivate = false)
    408375    {
    409376        // Normalize as many pct-encoded sections as possible
    410377        $string = preg_replace_callback('/(?:%[A-Fa-f0-9]{2})+/', [$this, 'remove_iunreserved_percent_encoded'], $string);
     378        \assert(\is_string($string), "For PHPStan: Should not occur, the regex is valid");
    411379
    412380        // Replace invalid percent characters
    413381        $string = preg_replace('/%(?![A-Fa-f0-9]{2})/', '%25', $string);
     382        \assert(\is_string($string), "For PHPStan: Should not occur, the regex is valid");
    414383
    415384        // Add unreserved and % to $extra_chars (the latter is safe because all
     
    526495     * encoded characters in iunreserved
    527496     *
    528      * @param array $match PCRE match
     497     * @param array{string} $match PCRE match, a capture group #0 consisting of a sequence of valid percent-encoded bytes
    529498     * @return string Replacement
    530499     */
    531     protected function remove_iunreserved_percent_encoded($match)
     500    protected function remove_iunreserved_percent_encoded(array $match)
    532501    {
    533502        // As we just have valid percent encoded sequences we can just explode
     
    632601                } else {
    633602                    for ($j = $start; $j <= $i; $j++) {
    634                         $string .= chr(hexdec($bytes[$j]));
     603                        // Cast for PHPStan, this will always be a number between 0 and 0xFF so hexdec will return int.
     604                        $string .= chr((int) hexdec($bytes[$j]));
    635605                    }
    636606                }
     
    649619    }
    650620
     621    /**
     622     * @return void
     623     */
    651624    protected function scheme_normalization()
    652625    {
     
    709682     * are any invalid characters).
    710683     *
    711      * @param string $iri
     684     * @param string|null $iri
    712685     * @return bool
    713686     */
    714     public function set_iri($iri, $clear_cache = false)
     687    public function set_iri(?string $iri, bool $clear_cache = false)
    715688    {
    716689        static $cache;
    717690        if ($clear_cache) {
    718691            $cache = null;
    719             return;
     692            return false;
    720693        }
    721694        if (!$cache) {
     
    769742     * any invalid characters).
    770743     *
    771      * @param string $scheme
     744     * @param string|null $scheme
    772745     * @return bool
    773746     */
    774     public function set_scheme($scheme)
     747    public function set_scheme(?string $scheme)
    775748    {
    776749        if ($scheme === null) {
     
    789762     * any invalid characters).
    790763     *
    791      * @param string $authority
     764     * @param string|null $authority
    792765     * @return bool
    793766     */
    794     public function set_authority($authority, $clear_cache = false)
     767    public function set_authority(?string $authority, bool $clear_cache = false)
    795768    {
    796769        static $cache;
    797770        if ($clear_cache) {
    798771            $cache = null;
    799             return;
     772            return false;
    800773        }
    801774        if (!$cache) {
     
    821794        $remaining = $authority;
    822795        if (($iuserinfo_end = strrpos($remaining, '@')) !== false) {
    823             $iuserinfo = substr($remaining, 0, $iuserinfo_end);
     796            // Cast for PHPStan on PHP < 8.0. It does not detect that
     797            // the range is not flipped so substr cannot return false.
     798            $iuserinfo = (string) substr($remaining, 0, $iuserinfo_end);
    824799            $remaining = substr($remaining, $iuserinfo_end + 1);
    825800        } else {
     
    827802        }
    828803        if (($port_start = strpos($remaining, ':', intval(strpos($remaining, ']')))) !== false) {
    829             if (($port = substr($remaining, $port_start + 1)) === false) {
     804            $port = substr($remaining, $port_start + 1);
     805            if ($port === false) {
    830806                $port = null;
    831807            }
     
    852828     * Set the iuserinfo.
    853829     *
    854      * @param string $iuserinfo
     830     * @param string|null $iuserinfo
    855831     * @return bool
    856832     */
    857     public function set_userinfo($iuserinfo)
     833    public function set_userinfo(?string $iuserinfo)
    858834    {
    859835        if ($iuserinfo === null) {
     
    871847     * any invalid characters).
    872848     *
    873      * @param string $ihost
     849     * @param string|null $ihost
    874850     * @return bool
    875851     */
    876     public function set_host($ihost)
     852    public function set_host(?string $ihost)
    877853    {
    878854        if ($ihost === null) {
     
    915891     * any invalid characters).
    916892     *
    917      * @param string $port
     893     * @param string|int|null $port
    918894     * @return bool
    919895     */
     
    923899            $this->port = null;
    924900            return true;
    925         } elseif (strspn($port, '0123456789') === strlen($port)) {
     901        } elseif (strspn((string) $port, '0123456789') === strlen((string) $port)) {
    926902            $this->port = (int) $port;
    927903            $this->scheme_normalization();
     
    936912     * Set the ipath.
    937913     *
    938      * @param string $ipath
     914     * @param string|null $ipath
    939915     * @return bool
    940916     */
    941     public function set_path($ipath, $clear_cache = false)
     917    public function set_path(?string $ipath, bool $clear_cache = false)
    942918    {
    943919        static $cache;
    944920        if ($clear_cache) {
    945921            $cache = null;
    946             return;
     922            return false;
    947923        }
    948924        if (!$cache) {
     
    969945     * Set the iquery.
    970946     *
    971      * @param string $iquery
     947     * @param string|null $iquery
    972948     * @return bool
    973949     */
    974     public function set_query($iquery)
     950    public function set_query(?string $iquery)
    975951    {
    976952        if ($iquery === null) {
     
    986962     * Set the ifragment.
    987963     *
    988      * @param string $ifragment
     964     * @param string|null $ifragment
    989965     * @return bool
    990966     */
    991     public function set_fragment($ifragment)
     967    public function set_fragment(?string $ifragment)
    992968    {
    993969        if ($ifragment === null) {
     
    1003979     * Convert an IRI to a URI (or parts thereof)
    1004980     *
     981     * @param string $string
    1005982     * @return string
    1006983     */
    1007     public function to_uri($string)
     984    public function to_uri(string $string)
    1008985    {
    1009986        static $non_ascii;
     
    10261003     * Get the complete IRI
    10271004     *
    1028      * @return string
     1005     * @return string|false
    10291006     */
    10301007    public function get_iri()
     
    10631040    public function get_uri()
    10641041    {
    1065         return $this->to_uri($this->get_iri());
     1042        return $this->to_uri((string) $this->get_iri());
    10661043    }
    10671044
     
    10691046     * Get the complete iauthority
    10701047     *
    1071      * @return string
     1048     * @return ?string
    10721049     */
    10731050    protected function get_iauthority()
     
    10931070     * Get the complete authority
    10941071     *
    1095      * @return string
     1072     * @return ?string
    10961073     */
    10971074    protected function get_authority()
  • trunk/src/wp-includes/SimplePie/src/Item.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
     
    5114 *
    5215 * This class can be overloaded with {@see \SimplePie\SimplePie::set_item_class()}
    53  *
    54  * @package \SimplePie\SimplePie
    55  * @subpackage API
    5616 */
    5717class Item implements RegistryAware
     
    6929     *
    7030     * @access private
    71      * @var array
     31     * @var array<string, mixed>
    7232     */
    7333    public $data = [];
     
    8242
    8343    /**
     44     * @var Sanitize|null
     45     */
     46    private $sanitize = null;
     47
     48    /**
    8449     * Create a new item object
    8550     *
     
    8853     *
    8954     * @param \SimplePie\SimplePie $feed Parent feed
    90      * @param array $data Raw data
    91      */
    92     public function __construct($feed, $data)
     55     * @param array<string, mixed> $data Raw data
     56     */
     57    public function __construct(\SimplePie\SimplePie $feed, array $data)
    9358    {
    9459        $this->feed = $feed;
     
    10368     * @since 1.3
    10469     * @param \SimplePie\Registry $registry
    105      */
    106     public function set_registry(\SimplePie\Registry $registry)/* : void */
     70     * @return void
     71     */
     72    public function set_registry(\SimplePie\Registry $registry)
    10773    {
    10874        $this->registry = $registry;
     
    141107     * @param string $namespace The URL of the XML namespace of the elements you're trying to access
    142108     * @param string $tag Tag name
    143      * @return array
    144      */
    145     public function get_item_tags($namespace, $tag)
     109     * @return array<array<string, mixed>>|null
     110     */
     111    public function get_item_tags(string $namespace, string $tag)
    146112    {
    147113        if (isset($this->data['child'][$namespace][$tag])) {
     
    153119
    154120    /**
     121     * Get base URL of the item itself.
     122     * Returns `<xml:base>` or feed base URL.
     123     * Similar to `Item::get_base()` but can safely be used during initialisation methods
     124     * such as `Item::get_links()` (`Item::get_base()` and `Item::get_links()` call each-other)
     125     * and is not affected by enclosures.
     126     *
     127     * @param array<string, mixed> $element
     128     * @see get_base
     129     */
     130    private function get_own_base(array $element = []): string
     131    {
     132        if (!empty($element['xml_base_explicit']) && isset($element['xml_base'])) {
     133            return $element['xml_base'];
     134        }
     135        return $this->feed->get_base();
     136    }
     137
     138    /**
    155139     * Get the base URL value.
    156      * Uses `<xml:base>`, or item link, or feed base URL.
    157      *
    158      * @param array $element
     140     * Uses `<xml:base>`, or item link, or enclosure link, or feed base URL.
     141     *
     142     * @param array<string, mixed> $element
    159143     * @return string
    160144     */
    161     public function get_base($element = [])
     145    public function get_base(array $element = [])
    162146    {
    163147        if (!empty($element['xml_base_explicit']) && isset($element['xml_base'])) {
     
    177161     * @see \SimplePie\SimplePie::sanitize()
    178162     * @param string $data Data to sanitize
    179      * @param int $type One of the \SimplePie\SimplePie::CONSTRUCT_* constants
     163     * @param int-mask-of<SimplePie::CONSTRUCT_*> $type
    180164     * @param string $base Base URL to resolve URLs against
    181165     * @return string Sanitized data
    182166     */
    183     public function sanitize($data, $type, $base = '')
    184     {
     167    public function sanitize(string $data, int $type, string $base = '')
     168    {
     169        // This really returns string|false but changing encoding is uncommon and we are going to deprecate it, so let’s just lie to PHPStan in the interest of cleaner annotations.
    185170        return $this->feed->sanitize($data, $type, $base);
    186171    }
     
    210195     *
    211196     * @since Beta 2
    212      * @param boolean $hash Should we force using a hash instead of the supplied ID?
     197     * @param bool $hash Should we force using a hash instead of the supplied ID?
    213198     * @param string|false $fn User-supplied function to generate an hash
    214199     * @return string|null
    215200     */
    216     public function get_id($hash = false, $fn = 'md5')
     201    public function get_id(bool $hash = false, $fn = 'md5')
    217202    {
    218203        if (!$hash) {
     
    287272     *
    288273     * @since 0.8
    289      * @param boolean $description_only Should we avoid falling back to the content?
     274     * @param bool $description_only Should we avoid falling back to the content?
    290275     * @return string|null
    291276     */
    292     public function get_description($description_only = false)
     277    public function get_description(bool $description_only = false)
    293278    {
    294279        if (($tags = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'summary')) &&
     
    337322     *
    338323     * @since 1.0
    339      * @param boolean $content_only Should we avoid falling back to the description?
     324     * @param bool $content_only Should we avoid falling back to the description?
    340325     * @return string|null
    341326     */
    342     public function get_content($content_only = false)
     327    public function get_content(bool $content_only = false)
    343328    {
    344329        if (($tags = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'content')) &&
     
    364349     *
    365350     *
    366      * @return array|null
     351     * @return array{url: string, height?: string, width?: string, time?: string}|null
    367352     */
    368353    public function get_thumbnail()
     
    391376     * @return \SimplePie\Category|null
    392377     */
    393     public function get_category($key = 0)
     378    public function get_category(int $key = 0)
    394379    {
    395380        $categories = $this->get_categories();
     
    463448     * @return \SimplePie\Author|null
    464449     */
    465     public function get_author($key = 0)
     450    public function get_author(int $key = 0)
    466451    {
    467452        $authors = $this->get_authors();
     
    480465     * @return \SimplePie\Author|null
    481466     */
    482     public function get_contributor($key = 0)
     467    public function get_contributor(int $key = 0)
    483468    {
    484469        $contributors = $this->get_contributors();
     
    509494            }
    510495            if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'])) {
    511                 $uri = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]));
     496                $uri = $contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0];
     497                $uri = $this->sanitize($uri['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($uri));
    512498            }
    513499            if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'])) {
     
    526512            }
    527513            if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'])) {
    528                 $url = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]));
     514                $url = $contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0];
     515                $url = $this->sanitize($url['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($url));
    529516            }
    530517            if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'])) {
     
    562549            }
    563550            if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'])) {
    564                 $uri = $this->sanitize($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]));
     551                $uri = $author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0];
     552                $uri = $this->sanitize($uri['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($uri));
    565553            }
    566554            if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'])) {
     
    579567            }
    580568            if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'])) {
    581                 $url = $this->sanitize($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]));
     569                $url = $author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0];
     570                $url = $this->sanitize($url['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($url));
    582571            }
    583572            if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'])) {
     
    618607     *
    619608     * @since 1.1
    620      * @return string
     609     * @return string|null
    621610     */
    622611    public function get_copyright()
     
    645634     *
    646635     * @param string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data)
    647      * @return int|string|null
    648      */
    649     public function get_date($date_format = 'j F Y, g:i a')
     636     * @return ($date_format is 'U' ? ?int : ?string)
     637     */
     638    public function get_date(string $date_format = 'j F Y, g:i a')
    650639    {
    651640        if (!isset($this->data['date'])) {
     
    676665        }
    677666        if ($this->data['date']) {
    678             $date_format = (string) $date_format;
    679667            switch ($date_format) {
    680668                case '':
     
    701689     *
    702690     * @param string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data)
    703      * @return int|string|null
    704      */
    705     public function get_updated_date($date_format = 'j F Y, g:i a')
     691     * @return ($date_format is 'U' ? ?int : ?string)
     692     */
     693    public function get_updated_date(string $date_format = 'j F Y, g:i a')
    706694    {
    707695        if (!isset($this->data['updated'])) {
     
    718706        }
    719707        if ($this->data['updated']) {
    720             $date_format = (string) $date_format;
    721708            switch ($date_format) {
    722709                case '':
     
    745732     *
    746733     * @param string $date_format Supports any PHP date format from {@see http://php.net/strftime} (empty for the raw data)
    747      * @return int|string|null
    748      */
    749     public function get_local_date($date_format = '%c')
    750     {
    751         if (!$date_format) {
    752             return $this->sanitize($this->get_date(''), \SimplePie\SimplePie::CONSTRUCT_TEXT);
     734     * @return string|null|false see `strftime` for when this can return `false`
     735     */
     736    public function get_local_date(string $date_format = '%c')
     737    {
     738        if ($date_format === '') {
     739            if (($raw_date = $this->get_date('')) === null) {
     740                return null;
     741            }
     742
     743            return $this->sanitize($raw_date, \SimplePie\SimplePie::CONSTRUCT_TEXT);
    753744        } elseif (($date = $this->get_date('U')) !== null && $date !== false) {
    754745            return strftime($date_format, $date);
     
    763754     * @see get_date
    764755     * @param string $date_format Supports any PHP date format from {@see http://php.net/date}
    765      * @return int|string|null
    766      */
    767     public function get_gmdate($date_format = 'j F Y, g:i a')
     756     * @return string|null
     757     */
     758    public function get_gmdate(string $date_format = 'j F Y, g:i a')
    768759    {
    769760        $date = $this->get_date('U');
     
    780771     * @see get_updated_date
    781772     * @param string $date_format Supports any PHP date format from {@see http://php.net/date}
    782      * @return int|string|null
    783      */
    784     public function get_updated_gmdate($date_format = 'j F Y, g:i a')
     773     * @return string|null
     774     */
     775    public function get_updated_gmdate(string $date_format = 'j F Y, g:i a')
    785776    {
    786777        $date = $this->get_updated_date('U');
     
    823814     * @return string|null Link URL
    824815     */
    825     public function get_link($key = 0, $rel = 'alternate')
     816    public function get_link(int $key = 0, string $rel = 'alternate')
    826817    {
    827818        $links = $this->get_links($rel);
     
    840831     * @since Beta 2
    841832     * @param string $rel The relationship of links to return
    842      * @return array|null Links found for the item (strings)
    843      */
    844     public function get_links($rel = 'alternate')
     833     * @return array<string>|null Links found for the item (strings)
     834     */
     835    public function get_links(string $rel = 'alternate')
    845836    {
    846837        if (!isset($this->data['links'])) {
     
    849840                if (isset($link['attribs']['']['href'])) {
    850841                    $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
    851                     $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($link));
     842                    $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($link));
    852843                }
    853844            }
     
    855846                if (isset($link['attribs']['']['href'])) {
    856847                    $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
    857                     $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($link));
     848                    $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($link));
    858849                }
    859850            }
    860851            if ($links = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_10, 'link')) {
    861                 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($links[0]));
     852                $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($links[0]));
    862853            }
    863854            if ($links = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_090, 'link')) {
    864                 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($links[0]));
     855                $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($links[0]));
    865856            }
    866857            if ($links = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'link')) {
    867                 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($links[0]));
     858                $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($links[0]));
    868859            }
    869860            if ($links = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'guid')) {
    870861                if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true') {
    871                     $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($links[0]));
     862                    $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($links[0]));
    872863                }
    873864            }
     
    882873                        $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] = &$this->data['links'][$key];
    883874                    }
    884                 } elseif (substr($key, 0, 41) === \SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY) {
    885                     $this->data['links'][substr($key, 41)] = &$this->data['links'][$key];
     875                } elseif (substr((string) $key, 0, 41) === \SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY) {
     876                    $this->data['links'][substr((string) $key, 41)] = &$this->data['links'][$key];
    886877                }
    887878                $this->data['links'][$key] = array_unique($this->data['links'][$key]);
     
    905896     * @return \SimplePie\Enclosure|null
    906897     */
    907     public function get_enclosure($key = 0, $prefer = null)
     898    public function get_enclosure(int $key = 0)
    908899    {
    909900        $enclosures = $this->get_enclosures();
     
    945936            $player_parent = null;
    946937            $ratings_parent = null;
    947             $restrictions_parent = null;
     938            $restrictions_parent = [];
    948939            $thumbnails_parent = null;
    949940            $title_parent = null;
     
    11401131
    11411132            // DURATION
    1142             if ($duration_parent = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'duration')) {
     1133            $duration_tags = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'duration');
     1134            if ($duration_tags !== null) {
    11431135                $seconds = null;
    11441136                $minutes = null;
    11451137                $hours = null;
    1146                 if (isset($duration_parent[0]['data'])) {
    1147                     $temp = explode(':', $this->sanitize($duration_parent[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT));
    1148                     if (sizeof($temp) > 0) {
    1149                         $seconds = (int) array_pop($temp);
    1150                     }
    1151                     if (sizeof($temp) > 0) {
     1138                if (isset($duration_tags[0]['data'])) {
     1139                    $temp = explode(':', $this->sanitize($duration_tags[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT));
     1140                    $seconds = (int) array_pop($temp);
     1141                    if (count($temp) > 0) {
    11521142                        $minutes = (int) array_pop($temp);
    11531143                        $seconds += $minutes * 60;
    11541144                    }
    1155                     if (sizeof($temp) > 0) {
     1145                    if (count($temp) > 0) {
    11561146                        $hours = (int) array_pop($temp);
    11571147                        $seconds += $hours * 3600;
     
    12371227            if ($player_parent = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_MEDIARSS, 'player')) {
    12381228                if (isset($player_parent[0]['attribs']['']['url'])) {
    1239                     $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
     1229                    $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($player_parent[0]));
    12401230                }
    12411231            } elseif ($player_parent = $parent->get_channel_tags(\SimplePie\SimplePie::NAMESPACE_MEDIARSS, 'player')) {
    12421232                if (isset($player_parent[0]['attribs']['']['url'])) {
    1243                     $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
     1233                    $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($player_parent[0]));
    12441234                }
    12451235            }
     
    13161306            } elseif ($restrictions = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'block')) {
    13171307                foreach ($restrictions as $restriction) {
    1318                     $restriction_relationship = 'allow';
     1308                    $restriction_relationship = Restriction::RELATIONSHIP_ALLOW;
    13191309                    $restriction_type = null;
    13201310                    $restriction_value = 'itunes';
    13211311                    if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') {
    1322                         $restriction_relationship = 'deny';
     1312                        $restriction_relationship = Restriction::RELATIONSHIP_DENY;
    13231313                    }
    13241314                    $restrictions_parent[] = $this->registry->create(Restriction::class, [$restriction_relationship, $restriction_type, $restriction_value]);
     
    13421332            } elseif ($restrictions = $parent->get_channel_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'block')) {
    13431333                foreach ($restrictions as $restriction) {
    1344                     $restriction_relationship = 'allow';
     1334                    $restriction_relationship = Restriction::RELATIONSHIP_ALLOW;
    13451335                    $restriction_type = null;
    13461336                    $restriction_value = 'itunes';
    13471337                    if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') {
    1348                         $restriction_relationship = 'deny';
     1338                        $restriction_relationship = Restriction::RELATIONSHIP_DENY;
    13491339                    }
    13501340                    $restrictions_parent[] = $this->registry->create(Restriction::class, [$restriction_relationship, $restriction_type, $restriction_value]);
    13511341                }
    13521342            }
    1353             if (is_array($restrictions_parent)) {
     1343            if (count($restrictions_parent) > 0) {
    13541344                $restrictions_parent = array_values(array_unique($restrictions_parent));
    13551345            } else {
    1356                 $restrictions_parent = [new \SimplePie\Restriction('allow', null, 'default')];
     1346                $restrictions_parent = [new \SimplePie\Restriction(Restriction::RELATIONSHIP_ALLOW, null, 'default')];
    13571347            }
    13581348
     
    13611351                foreach ($thumbnails as $thumbnail) {
    13621352                    if (isset($thumbnail['attribs']['']['url'])) {
    1363                         $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
     1353                        $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($thumbnail));
    13641354                    }
    13651355                }
     
    13671357                foreach ($thumbnails as $thumbnail) {
    13681358                    if (isset($thumbnail['attribs']['']['url'])) {
    1369                         $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
     1359                        $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($thumbnail));
    13701360                    }
    13711361                }
     
    14911481                                $width = $this->sanitize($content['attribs']['']['width'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
    14921482                            }
    1493                             $url = $this->sanitize($content['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
     1483                            $url = $this->sanitize($content['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($content));
    14941484
    14951485                            // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
     
    17501740                            // PLAYER
    17511741                            if (isset($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'])) {
    1752                                 $player = $this->sanitize($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
     1742                                $playerElem = $content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0];
     1743                                $player = $this->sanitize($playerElem['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($playerElem));
    17531744                            } elseif (isset($group['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'])) {
    1754                                 $player = $this->sanitize($group['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
     1745                                $playerElem = $group['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0];
     1746                                $player = $this->sanitize($playerElem['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($playerElem));
    17551747                            } else {
    17561748                                $player = $player_parent;
     
    18421834                            if (isset($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['thumbnail'])) {
    18431835                                foreach ($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) {
    1844                                     $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
     1836                                    $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($thumbnail));
    18451837                                }
    18461838                                if (is_array($thumbnails)) {
     
    18491841                            } elseif (isset($group['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['thumbnail'])) {
    18501842                                foreach ($group['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) {
    1851                                     $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
     1843                                    $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($thumbnail));
    18521844                                }
    18531845                                if (is_array($thumbnails)) {
     
    19471939                        }
    19481940                        if (isset($content['attribs']['']['url'])) {
    1949                             $url = $this->sanitize($content['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
     1941                            $url = $this->sanitize($content['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($content));
    19501942                        }
    19511943                        // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
     
    21022094                        if (isset($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'])) {
    21032095                            if (isset($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'])) {
    2104                                 $player = $this->sanitize($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
     2096                                $playerElem = $content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['player'][0];
     2097                                $player = $this->sanitize($playerElem['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($playerElem));
    21052098                            }
    21062099                        } else {
     
    21582151                            foreach ($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) {
    21592152                                if (isset($thumbnail['attribs']['']['url'])) {
    2160                                     $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI);
     2153                                    $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($thumbnail));
    21612154                                }
    21622155                            }
     
    21982191                    $width = null;
    21992192
    2200                     $url = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($link));
     2193                    $url = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($link));
    22012194                    if (isset($link['attribs']['']['type'])) {
    22022195                        $type = $this->sanitize($link['attribs']['']['type'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
     
    22342227                    $width = null;
    22352228
    2236                     $url = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($link));
     2229                    $url = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($link));
    22372230                    if (isset($link['attribs']['']['type'])) {
    22382231                        $type = $this->sanitize($link['attribs']['']['type'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
     
    22652258                    $width = null;
    22662259
    2267                     $url = $this->sanitize($enclosure['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($enclosure));
    2268                     $url = $this->feed->sanitize->https_url($url);
     2260                    $url = $this->sanitize($enclosure['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_own_base($enclosure));
     2261                    $url = $this->get_sanitize()->https_url($url);
    22692262                    if (isset($enclosure['attribs']['']['type'])) {
    22702263                        $type = $this->sanitize($enclosure['attribs']['']['type'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
     
    22792272            }
    22802273
    2281             if (sizeof($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width)) {
     2274            if (count($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $samplingrate || $thumbnails_parent || $title_parent || $width)) {
    22822275                // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
    22832276                $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]);
     
    23032296     * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo
    23042297     * @link http://www.georss.org/ GeoRSS
    2305      * @return string|null
     2298     * @return float|null
    23062299     */
    23072300    public function get_latitude()
     
    23262319     * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo
    23272320     * @link http://www.georss.org/ GeoRSS
    2328      * @return string|null
     2321     * @return float|null
    23292322     */
    23302323    public function get_longitude()
     
    23552348        return null;
    23562349    }
     2350
     2351    public function set_sanitize(Sanitize $sanitize): void
     2352    {
     2353        $this->sanitize = $sanitize;
     2354    }
     2355
     2356    protected function get_sanitize(): Sanitize
     2357    {
     2358        if ($this->sanitize === null) {
     2359            $this->sanitize = new Sanitize();
     2360        }
     2361
     2362        return $this->sanitize;
     2363    }
    23572364}
    23582365
  • trunk/src/wp-includes/SimplePie/src/Locator.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
     9
     10use DomDocument;
     11use Psr\Http\Client\ClientInterface;
     12use Psr\Http\Message\RequestFactoryInterface;
     13use Psr\Http\Message\UriFactoryInterface;
     14use SimplePie\HTTP\Client;
     15use SimplePie\HTTP\ClientException;
     16use SimplePie\HTTP\FileClient;
     17use SimplePie\HTTP\Psr18Client;
     18use SimplePie\HTTP\Response;
    4619
    4720/**
     
    5023 *
    5124 * This class can be overloaded with {@see \SimplePie\SimplePie::set_locator_class()}
    52  *
    53  * @package SimplePie
    5425 */
    5526class Locator implements RegistryAware
    5627{
    57     public $useragent;
    58     public $timeout;
     28    /** @var ?string */
     29    public $useragent = null;
     30    /** @var int */
     31    public $timeout = 10;
     32    /** @var File */
    5933    public $file;
     34    /** @var string[] */
    6035    public $local = [];
     36    /** @var string[] */
    6137    public $elsewhere = [];
     38    /** @var array<mixed> */
    6239    public $cached_entities = [];
     40    /** @var string */
    6341    public $http_base;
     42    /** @var string */
    6443    public $base;
     44    /** @var int */
    6545    public $base_location = 0;
     46    /** @var int */
    6647    public $checked_feeds = 0;
     48    /** @var int */
    6749    public $max_checked_feeds = 10;
     50    /** @var bool */
    6851    public $force_fsockopen = false;
     52    /** @var array<int, mixed> */
    6953    public $curl_options = [];
     54    /** @var ?\DomDocument */
    7055    public $dom;
     56    /** @var ?Registry */
    7157    protected $registry;
    7258
    73     public function __construct(\SimplePie\File $file, $timeout = 10, $useragent = null, $max_checked_feeds = 10, $force_fsockopen = false, $curl_options = [])
     59    /**
     60     * @var Client|null
     61     */
     62    private $http_client = null;
     63
     64    /**
     65     * @param array<int, mixed> $curl_options
     66     */
     67    public function __construct(File $file, int $timeout = 10, ?string $useragent = null, int $max_checked_feeds = 10, bool $force_fsockopen = false, array $curl_options = [])
    7468    {
    7569        $this->file = $file;
     
    8074        $this->curl_options = $curl_options;
    8175
    82         if (class_exists('DOMDocument') && $this->file->body != '') {
     76        $body = $this->file->get_body_content();
     77
     78        if (class_exists('DOMDocument') && $body != '') {
    8379            $this->dom = new \DOMDocument();
    8480
    85             set_error_handler(['SimplePie\Misc', 'silence_errors']);
     81            set_error_handler([Misc::class, 'silence_errors']);
    8682            try {
    87                 $this->dom->loadHTML($this->file->body);
     83                $this->dom->loadHTML($body);
    8884            } catch (\Throwable $ex) {
    8985                $this->dom = null;
     
    9591    }
    9692
    97     public function set_registry(\SimplePie\Registry $registry)/* : void */
     93    /**
     94     * Set a PSR-18 client and PSR-17 factories
     95     *
     96     * Allows you to use your own HTTP client implementations.
     97     */
     98    final public function set_http_client(
     99        ClientInterface $http_client,
     100        RequestFactoryInterface $request_factory,
     101        UriFactoryInterface $uri_factory
     102    ): void {
     103        $this->http_client = new Psr18Client($http_client, $request_factory, $uri_factory);
     104    }
     105
     106    /**
     107     * @return void
     108     */
     109    public function set_registry(\SimplePie\Registry $registry)
    98110    {
    99111        $this->registry = $registry;
    100112    }
    101113
    102     public function find($type = \SimplePie\SimplePie::LOCATOR_ALL, &$working = null)
    103     {
     114    /**
     115     * @param SimplePie::LOCATOR_* $type
     116     * @param array<Response>|null $working
     117     * @return Response|null
     118     */
     119    public function find(int $type = \SimplePie\SimplePie::LOCATOR_ALL, ?array &$working = null)
     120    {
     121        assert($this->registry !== null);
     122
    104123        if ($this->is_feed($this->file)) {
    105124            return $this->file;
    106125        }
    107126
    108         if ($this->file->method & \SimplePie\SimplePie::FILE_SOURCE_REMOTE) {
     127        if (Misc::is_remote_uri($this->file->get_final_requested_uri())) {
    109128            $sniffer = $this->registry->create(Content\Type\Sniffer::class, [$this->file]);
    110129            if ($sniffer->get_type() !== 'text/html') {
     
    141160    }
    142161
    143     public function is_feed($file, $check_html = false)
    144     {
    145         if ($file->method & \SimplePie\SimplePie::FILE_SOURCE_REMOTE) {
     162    /**
     163     * @return bool
     164     */
     165    public function is_feed(Response $file, bool $check_html = false)
     166    {
     167        assert($this->registry !== null);
     168
     169        if (Misc::is_remote_uri($file->get_final_requested_uri())) {
    146170            $sniffer = $this->registry->create(Content\Type\Sniffer::class, [$file]);
    147171            $sniffed = $sniffer->get_type();
     
    154178
    155179            return in_array($sniffed, $mime_types);
    156         } elseif ($file->method & \SimplePie\SimplePie::FILE_SOURCE_LOCAL) {
     180        } elseif (is_file($file->get_final_requested_uri())) {
    157181            return true;
    158182        } else {
     
    161185    }
    162186
     187    /**
     188     * @return void
     189     */
    163190    public function get_base()
    164191    {
     192        assert($this->registry !== null);
     193
    165194        if ($this->dom === null) {
    166195            throw new \SimplePie\Exception('DOMDocument not found, unable to use locator');
    167196        }
    168         $this->http_base = $this->file->url;
     197        $this->http_base = $this->file->get_final_requested_uri();
    169198        $this->base = $this->http_base;
    170199        $elements = $this->dom->getElementsByTagName('base');
     
    182211    }
    183212
     213    /**
     214     * @return array<Response>|null
     215     */
    184216    public function autodiscovery()
    185217    {
     
    197229    }
    198230
    199     protected function search_elements_by_tag($name, &$done, $feeds)
    200     {
     231    /**
     232     * @param string[] $done
     233     * @param array<string, Response> $feeds
     234     * @return array<string, Response>
     235     */
     236    protected function search_elements_by_tag(string $name, array &$done, array $feeds)
     237    {
     238        assert($this->registry !== null);
     239
    201240        if ($this->dom === null) {
    202241            throw new \SimplePie\Exception('DOMDocument not found, unable to use locator');
     
    224263                    $this->checked_feeds++;
    225264                    $headers = [
    226                         'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
     265                        'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER,
    227266                    ];
    228                     $feed = $this->registry->create(File::class, [$href, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options]);
    229                     if ($feed->success && ($feed->method & \SimplePie\SimplePie::FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed, true)) {
    230                         $feeds[$href] = $feed;
     267
     268                    try {
     269                        $feed = $this->get_http_client()->request(Client::METHOD_GET, $href, $headers);
     270
     271                        if ((!Misc::is_remote_uri($feed->get_final_requested_uri()) || ($feed->get_status_code() === 200 || $feed->get_status_code() > 206 && $feed->get_status_code() < 300)) && $this->is_feed($feed, true)) {
     272                            $feeds[$href] = $feed;
     273                        }
     274                    } catch (ClientException $th) {
     275                        // Just mark it as done and continue.
    231276                    }
    232277                }
     
    238283    }
    239284
     285    /**
     286     * @return true|null
     287     */
    240288    public function get_links()
    241289    {
     290        assert($this->registry !== null);
     291
    242292        if ($this->dom === null) {
    243293            throw new \SimplePie\Exception('DOMDocument not found, unable to use locator');
     
    259309                    }
    260310
    261                     $current = $this->registry->call(Misc::class, 'parse_url', [$this->file->url]);
     311                    $current = $this->registry->call(Misc::class, 'parse_url', [$this->file->get_final_requested_uri()]);
    262312
    263313                    if ($parsed['authority'] === '' || $parsed['authority'] === $current['authority']) {
     
    277327    }
    278328
    279     public function get_rel_link($rel)
    280     {
     329    /**
     330     * Extracts first `link` element with given `rel` attribute inside the `head` element.
     331     *
     332     * @return string|null
     333     */
     334    public function get_rel_link(string $rel)
     335    {
     336        assert($this->registry !== null);
     337
    281338        if ($this->dom === null) {
    282339            throw new \SimplePie\Exception('DOMDocument not found, unable to use '.
     
    289346
    290347        $xpath = new \DOMXpath($this->dom);
    291         $query = '//a[@rel and @href] | //link[@rel and @href]';
    292         foreach ($xpath->query($query) as $link) {
     348        $query = '(//head)[1]/link[@rel and @href]';
     349        /** @var \DOMNodeList<\DOMElement> */
     350        $queryResult = $xpath->query($query);
     351        foreach ($queryResult as $link) {
    293352            $href = trim($link->getAttribute('href'));
    294353            $parsed = $this->registry->call(Misc::class, 'parse_url', [$href]);
     
    318377            }
    319378        }
    320         return null;
    321     }
    322 
    323     public function extension(&$array)
     379
     380        return null;
     381    }
     382
     383    /**
     384     * @param string[] $array
     385     * @return array<Response>|null
     386     */
     387    public function extension(array &$array)
    324388    {
    325389        foreach ($array as $key => $value) {
     
    327391                break;
    328392            }
    329             if (in_array(strtolower(strrchr($value, '.')), ['.rss', '.rdf', '.atom', '.xml'])) {
     393            $extension = strrchr($value, '.');
     394            if ($extension !== false && in_array(strtolower($extension), ['.rss', '.rdf', '.atom', '.xml'])) {
    330395                $this->checked_feeds++;
    331396
    332397                $headers = [
    333                     'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
     398                    'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER,
    334399                ];
    335                 $feed = $this->registry->create(File::class, [$value, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options]);
    336                 if ($feed->success && ($feed->method & \SimplePie\SimplePie::FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) {
    337                     return [$feed];
    338                 } else {
    339                     unset($array[$key]);
    340                 }
    341             }
    342         }
    343         return null;
    344     }
    345 
    346     public function body(&$array)
     400
     401                try {
     402                    $feed = $this->get_http_client()->request(Client::METHOD_GET, $value, $headers);
     403
     404                    if ((!Misc::is_remote_uri($feed->get_final_requested_uri()) || ($feed->get_status_code() === 200 || $feed->get_status_code() > 206 && $feed->get_status_code() < 300)) && $this->is_feed($feed)) {
     405                        return [$feed];
     406                    }
     407                } catch (ClientException $th) {
     408                    // Just unset and continue.
     409                }
     410
     411                unset($array[$key]);
     412            }
     413        }
     414        return null;
     415    }
     416
     417    /**
     418     * @param string[] $array
     419     * @return array<Response>|null
     420     */
     421    public function body(array &$array)
    347422    {
    348423        foreach ($array as $key => $value) {
     
    353428                $this->checked_feeds++;
    354429                $headers = [
    355                     'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
     430                    'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER,
    356431                ];
    357                 $feed = $this->registry->create(File::class, [$value, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen, $this->curl_options]);
    358                 if ($feed->success && ($feed->method & \SimplePie\SimplePie::FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) {
    359                     return [$feed];
    360                 } else {
    361                     unset($array[$key]);
    362                 }
    363             }
    364         }
    365         return null;
     432
     433                try {
     434                    $feed = $this->get_http_client()->request(Client::METHOD_GET, $value, $headers);
     435
     436                    if ((!Misc::is_remote_uri($feed->get_final_requested_uri()) || ($feed->get_status_code() === 200 || $feed->get_status_code() > 206 && $feed->get_status_code() < 300)) && $this->is_feed($feed)) {
     437                        return [$feed];
     438                    }
     439                } catch (ClientException $th) {
     440                    // Just unset and continue.
     441                }
     442
     443                unset($array[$key]);
     444            }
     445        }
     446        return null;
     447    }
     448
     449    /**
     450     * Get a HTTP client
     451     */
     452    private function get_http_client(): Client
     453    {
     454        assert($this->registry !== null);
     455
     456        if ($this->http_client === null) {
     457            $options = [
     458                'timeout' => $this->timeout,
     459                'redirects' => 5,
     460                'force_fsockopen' => $this->force_fsockopen,
     461                'curl_options' => $this->curl_options,
     462            ];
     463
     464            if ($this->useragent !== null) {
     465                $options['useragent'] = $this->useragent;
     466            }
     467
     468            return new FileClient(
     469                $this->registry,
     470                $options
     471            );
     472        }
     473
     474        return $this->http_client;
    366475    }
    367476}
  • trunk/src/wp-includes/SimplePie/src/Misc.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
     
    4912/**
    5013 * Miscellaneous utilities
    51  *
    52  * @package SimplePie
    5314 */
    5415class Misc
    5516{
     17    /** @var int|null */
    5618    private static $SIMPLEPIE_BUILD = null;
    5719
    58     public static function time_hms($seconds)
     20    /**
     21     * @return string
     22     */
     23    public static function time_hms(int $seconds)
    5924    {
    6025        $time = '';
     
    8146    }
    8247
    83     public static function absolutize_url($relative, $base)
     48    /**
     49     * @return string|false
     50     */
     51    public static function absolutize_url(string $relative, string $base)
    8452    {
    8553        $iri = \SimplePie\IRI::absolutize(new \SimplePie\IRI($base), $relative);
     
    8856        }
    8957        return $iri->get_uri();
     58    }
     59
     60    /**
     61     * @internal
     62     */
     63    public static function is_remote_uri(string $uri): bool
     64    {
     65        return preg_match('/^https?:\/\//i', $uri) === 1;
    9066    }
    9167
     
    9672     * @param string $realname Element name (including namespace prefix if applicable)
    9773     * @param string $string HTML document
    98      * @return array
    99      */
    100     public static function get_element($realname, $string)
     74     * @return array<array{tag: string, self_closing: bool, attribs: array<string, array{data: string}>, content?: string}>
     75     */
     76    public static function get_element(string $realname, string $string)
    10177    {
    10278        // trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.3, use "DOMDocument" instead.'), \E_USER_DEPRECATED);
     
    11793                $return[$i]['attribs'] = [];
    11894                if (isset($matches[$i][2][0]) && preg_match_all('/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*)(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?/', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER)) {
    119                     for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++) {
    120                         if (count($attribs[$j]) === 2) {
    121                             $attribs[$j][2] = $attribs[$j][1];
     95                    foreach ($attribs as $attrib) {
     96                        if (count($attrib) === 2) {
     97                            $attrib[2] = $attrib[1];
    12298                        }
    123                         $return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = Misc::entities_decode(end($attribs[$j]));
     99                        $return[$i]['attribs'][strtolower($attrib[1])]['data'] = Misc::entities_decode(end($attrib));
    124100                    }
    125101                }
     
    129105    }
    130106
    131     public static function element_implode($element)
    132     {
    133         $full = "<$element[tag]";
     107    /**
     108     * @deprecated since SimplePie 1.9.0. If you need it, you can copy the function to your codebase. But you should consider using `DOMDocument` for any DOM wrangling.
     109     * @param array{tag: string, self_closing: bool, attribs: array<string, array{data: string}>, content: string} $element
     110     * @return string
     111     */
     112    public static function element_implode(array $element)
     113    {
     114        // trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.9.'), \E_USER_DEPRECATED);
     115
     116        $full = "<{$element['tag']}";
    134117        foreach ($element['attribs'] as $key => $value) {
    135118            $key = strtolower($key);
     
    139122            $full .= ' />';
    140123        } else {
    141             $full .= ">$element[content]</$element[tag]>";
     124            $full .= ">{$element['content']}</{$element['tag']}>";
    142125        }
    143126        return $full;
    144127    }
    145128
    146     public static function error($message, $level, $file, $line)
     129    /**
     130     * @param string $message
     131     * @param int $level
     132     * @param string $file
     133     * @param int $line
     134     * @return string
     135     */
     136    public static function error(string $message, int $level, string $file, int $line)
    147137    {
    148138        if ((error_reporting() & $level) > 0) {
     
    180170    }
    181171
    182     public static function fix_protocol($url, $http = 1)
     172    /**
     173     * @return string
     174     */
     175    public static function fix_protocol(string $url, int $http = 1)
    183176    {
    184177        $url = Misc::normalize_url($url);
     
    205198    /**
    206199     * @deprecated since SimplePie 1.8.0, use PHP native array_replace_recursive() instead.
    207      */
    208     public static function array_merge_recursive($array1, $array2)
     200     * @param array<mixed> $array1
     201     * @param array<mixed> $array2
     202     * @return array<mixed>
     203     */
     204    public static function array_merge_recursive(array $array1, array $array2)
    209205    {
    210206        foreach ($array2 as $key => $value) {
     
    219215    }
    220216
    221     public static function parse_url($url)
     217    /**
     218     * @return array<string, string>
     219     */
     220    public static function parse_url(string $url)
    222221    {
    223222        $iri = new \SimplePie\IRI($url);
     
    231230    }
    232231
    233     public static function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '')
     232    /**
     233     * @return string
     234     */
     235    public static function compress_parse_url(string $scheme = '', string $authority = '', string $path = '', string $query = '', ?string $fragment = '')
    234236    {
    235237        $iri = new \SimplePie\IRI('');
     
    242244    }
    243245
    244     public static function normalize_url($url)
     246    /**
     247     * @return string
     248     */
     249    public static function normalize_url(string $url)
    245250    {
    246251        $iri = new \SimplePie\IRI($url);
     
    248253    }
    249254
    250     public static function percent_encoding_normalization($match)
     255    /**
     256     * @deprecated since SimplePie 1.9.0. This functionality is part of `IRI` – if you need it standalone, consider copying the function to your codebase.
     257     * @param array<int, string> $match
     258     * @return string
     259     */
     260    public static function percent_encoding_normalization(array $match)
    251261    {
    252262        $integer = hexdec($match[1]);
    253263        if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E) {
    254             return chr($integer);
     264            // Cast for PHPStan, the value would only be float when above PHP_INT_MAX, which would not go in this branch.
     265            return chr((int) $integer);
    255266        }
    256267
     
    265276     * @return string UTF-8 encoded string
    266277     */
    267     public static function windows_1252_to_utf8($string)
     278    public static function windows_1252_to_utf8(string $string)
    268279    {
    269280        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"];
     
    278289     * @param string $input Encoding of $data
    279290     * @param string $output Encoding you want
    280      * @return string|boolean False if we can't convert it
    281      */
    282     public static function change_encoding($data, $input, $output)
     291     * @return string|false False if we can't convert it
     292     */
     293    public static function change_encoding(string $data, string $input, string $output)
    283294    {
    284295        $input = Misc::encoding($input);
     
    287298        // We fail to fail on non US-ASCII bytes
    288299        if ($input === 'US-ASCII') {
    289             static $non_ascii_octects = '';
    290             if (!$non_ascii_octects) {
     300            static $non_ascii_octets = '';
     301            if (!$non_ascii_octets) {
    291302                for ($i = 0x80; $i <= 0xFF; $i++) {
    292                     $non_ascii_octects .= chr($i);
     303                    $non_ascii_octets .= chr($i);
    293304                }
    294305            }
    295             $data = substr($data, 0, strcspn($data, $non_ascii_octects));
     306            $data = substr($data, 0, strcspn($data, $non_ascii_octets));
    296307        }
    297308
     
    317328    }
    318329
    319     protected static function change_encoding_mbstring($data, $input, $output)
     330    /**
     331     * @return string|false
     332     */
     333    protected static function change_encoding_mbstring(string $data, string $input, string $output)
    320334    {
    321335        if ($input === 'windows-949') {
     
    349363    }
    350364
    351     protected static function change_encoding_iconv($data, $input, $output)
     365    /**
     366     * @return string|false
     367     */
     368    protected static function change_encoding_iconv(string $data, string $input, string $output)
    352369    {
    353370        return @iconv($input, $output, $data);
     
    355372
    356373    /**
    357      * @param string $data
    358      * @param string $input
    359      * @param string $output
    360374     * @return string|false
    361375     */
    362     protected static function change_encoding_uconverter($data, $input, $output)
     376    protected static function change_encoding_uconverter(string $data, string $input, string $output)
    363377    {
    364378        return @\UConverter::transcode($data, $output, $input);
     
    376390     * @return string Standardised name
    377391     */
    378     public static function encoding($charset)
     392    public static function encoding(string $charset)
    379393    {
    380394        // Normalization from UTS #22
    381         switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset))) {
     395        // Cast for PHPStan, the regex should not fail.
     396        switch (strtolower((string) preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset))) {
    382397            case 'adobestandardencoding':
    383398            case 'csadobestandardencoding':
     
    16881703    }
    16891704
     1705    /**
     1706     * @return string
     1707     */
    16901708    public static function get_curl_version()
    16911709    {
    16921710        if (is_array($curl = curl_version())) {
    16931711            $curl = $curl['version'];
    1694         } elseif (substr($curl, 0, 5) === 'curl/') {
    1695             $curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5));
    1696         } elseif (substr($curl, 0, 8) === 'libcurl/') {
    1697             $curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8));
    16981712        } else {
    1699             $curl = 0;
     1713            $curl = '0';
    17001714        }
    17011715        return $curl;
     
    17051719     * Strip HTML comments
    17061720     *
     1721     * @deprecated since SimplePie 1.9.0. If you need it, you can copy the function to your codebase. But you should consider using `DOMDocument` for any DOM wrangling.
    17071722     * @param string $data Data to strip comments from
    17081723     * @return string Comment stripped string
    17091724     */
    1710     public static function strip_comments($data)
    1711     {
     1725    public static function strip_comments(string $data)
     1726    {
     1727        // trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.9.'), \E_USER_DEPRECATED);
     1728
    17121729        $output = '';
    17131730        while (($start = strpos($data, '<!--')) !== false) {
     
    17221739    }
    17231740
    1724     public static function parse_date($dt)
     1741    /**
     1742     * @return int|false
     1743     */
     1744    public static function parse_date(string $dt)
    17251745    {
    17261746        $parser = \SimplePie\Parse\Date::get();
     
    17351755     * @return string Output data
    17361756     */
    1737     public static function entities_decode($data)
     1757    public static function entities_decode(string $data)
    17381758    {
    17391759        // trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.3, use "DOMDocument" instead.'), \E_USER_DEPRECATED);
     
    17461766     * Remove RFC822 comments
    17471767     *
    1748      * @param string $data Data to strip comments from
     1768     * @deprecated since SimplePie 1.9.0. If you need it, consider copying the function to your codebase.
     1769     * @param string $string Data to strip comments from
    17491770     * @return string Comment stripped string
    17501771     */
    1751     public static function uncomment_rfc822($string)
    1752     {
    1753         $string = (string) $string;
     1772    public static function uncomment_rfc822(string $string)
     1773    {
     1774        // trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.9.'), \E_USER_DEPRECATED);
     1775
    17541776        $position = 0;
    17551777        $length = strlen($string);
     
    17921814    }
    17931815
    1794     public static function parse_mime($mime)
     1816    /**
     1817     * @return string
     1818     */
     1819    public static function parse_mime(string $mime)
    17951820    {
    17961821        if (($pos = strpos($mime, ';')) === false) {
     
    18011826    }
    18021827
    1803     public static function atom_03_construct_type($attribs)
     1828    /**
     1829     * @param array<string, array<string, string>> $attribs
     1830     * @return int-mask-of<SimplePie::CONSTRUCT_*>
     1831     */
     1832    public static function atom_03_construct_type(array $attribs)
    18041833    {
    18051834        if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode'])) === 'base64') {
     
    18301859    }
    18311860
    1832     public static function atom_10_construct_type($attribs)
     1861    /**
     1862     * @param array<string, array<string, string>> $attribs
     1863     * @return int-mask-of<SimplePie::CONSTRUCT_*>
     1864     */
     1865    public static function atom_10_construct_type(array $attribs)
    18331866    {
    18341867        if (isset($attribs['']['type'])) {
     
    18501883    }
    18511884
    1852     public static function atom_10_content_construct_type($attribs)
     1885    /**
     1886     * @param array<string, array<string, string>> $attribs
     1887     * @return int-mask-of<SimplePie::CONSTRUCT_*>
     1888     */
     1889    public static function atom_10_content_construct_type(array $attribs)
    18531890    {
    18541891        if (isset($attribs['']['type'])) {
     
    18741911    }
    18751912
    1876     public static function is_isegment_nz_nc($string)
     1913    /**
     1914     * @return bool
     1915     */
     1916    public static function is_isegment_nz_nc(string $string)
    18771917    {
    18781918        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);
    18791919    }
    18801920
    1881     public static function space_separated_tokens($string)
     1921    /**
     1922     * @return string[]
     1923     */
     1924    public static function space_separated_tokens(string $string)
    18821925    {
    18831926        $space_characters = "\x20\x09\x0A\x0B\x0C\x0D";
     
    19021945     * @static
    19031946     * @param int $codepoint Unicode codepoint
    1904      * @return string UTF-8 character
    1905      */
    1906     public static function codepoint_to_utf8($codepoint)
    1907     {
    1908         $codepoint = (int) $codepoint;
     1947     * @return string|false UTF-8 character
     1948     */
     1949    public static function codepoint_to_utf8(int $codepoint)
     1950    {
    19091951        if ($codepoint < 0) {
    19101952            return false;
     
    19291971     * array of values that have used the same name
    19301972     *
     1973     * @deprecated since SimplePie 1.9.0. If you need it, consider copying the function to your codebase.
    19311974     * @static
    19321975     * @param string $str The input string.
    1933      * @return array
    1934      */
    1935     public static function parse_str($str)
    1936     {
     1976     * @return array<string, array<string|null>>
     1977     */
     1978    public static function parse_str(string $str)
     1979    {
     1980        // trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.9.'), \E_USER_DEPRECATED);
     1981
    19371982        $return = [];
    19381983        $str = explode('&', $str);
     
    19562001     * @param string $data XML data
    19572002     * @param \SimplePie\Registry $registry Class registry
    1958      * @return array Possible encodings
    1959      */
    1960     public static function xml_encoding($data, $registry)
     2003     * @return array<string> Possible encodings
     2004     */
     2005    public static function xml_encoding(string $data, \SimplePie\Registry $registry)
    19612006    {
    19622007        // UTF-32 Big Endian BOM
     
    20372082    }
    20382083
     2084    /**
     2085     * @return void
     2086     */
    20392087    public static function output_javascript()
    20402088    {
     
    20462094        header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
    20472095
    2048         $body = <<<END
     2096        $body = <<<JS
    20492097function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
    20502098    if (placeholder != '') {
     
    20672115    document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
    20682116}
    2069 END;
     2117JS;
    20702118        echo $body;
    20712119    }
     
    20762124     * Uses the git index if it exists, otherwise uses the modification time
    20772125     * of the newest file.
     2126     *
     2127     * @return int
    20782128     */
    20792129    public static function get_build()
    20802130    {
    2081         if (static::$SIMPLEPIE_BUILD !== null) {
    2082             return static::$SIMPLEPIE_BUILD;
     2131        if (self::$SIMPLEPIE_BUILD !== null) {
     2132            return self::$SIMPLEPIE_BUILD;
    20832133        }
    20842134
    20852135        $root = dirname(__FILE__, 2);
    20862136        if (file_exists($root . '/.git/index')) {
    2087             static::$SIMPLEPIE_BUILD = filemtime($root . '/.git/index');
    2088 
    2089             return static::$SIMPLEPIE_BUILD;
    2090         } elseif (file_exists($root . '/SimplePie')) {
     2137            self::$SIMPLEPIE_BUILD = (int) filemtime($root . '/.git/index');
     2138
     2139            return self::$SIMPLEPIE_BUILD;
     2140        } elseif (file_exists($root . '/src')) {
    20912141            $time = 0;
    2092             foreach (glob($root . '/SimplePie/*.php') as $file) {
     2142            foreach (glob($root . '/src/*.php') ?: [] as $file) {
    20932143                if (($mtime = filemtime($file)) > $time) {
    20942144                    $time = $mtime;
    20952145                }
    20962146            }
    2097             static::$SIMPLEPIE_BUILD = $time;
    2098 
    2099             return static::$SIMPLEPIE_BUILD;
    2100         } elseif (file_exists(dirname(__FILE__) . '/Core.php')) {
    2101             static::$SIMPLEPIE_BUILD = filemtime(dirname(__FILE__) . '/Core.php');
    2102 
    2103             return static::$SIMPLEPIE_BUILD;
    2104         }
    2105 
    2106         static::$SIMPLEPIE_BUILD = filemtime(__FILE__);
    2107 
    2108         return static::$SIMPLEPIE_BUILD;
     2147
     2148            self::$SIMPLEPIE_BUILD = $time;
     2149
     2150            return self::$SIMPLEPIE_BUILD;
     2151        }
     2152
     2153        self::$SIMPLEPIE_BUILD = (int) filemtime(__FILE__);
     2154
     2155        return self::$SIMPLEPIE_BUILD;
    21092156    }
    21102157
     
    21212168    /**
    21222169     * Format debugging information
    2123      */
    2124     public static function debug(&$sp)
     2170     *
     2171     * @return string
     2172     */
     2173    public static function debug(SimplePie &$sp)
    21252174    {
    21262175        $info = 'SimplePie ' . \SimplePie\SimplePie::VERSION . ' Build ' . static::get_build() . "\n";
    21272176        $info .= 'PHP ' . PHP_VERSION . "\n";
    21282177        if ($sp->error() !== null) {
    2129             $info .= 'Error occurred: ' . $sp->error() . "\n";
     2178            // TODO: Remove cast with multifeeds.
     2179            $info .= 'Error occurred: ' . implode(', ', (array) $sp->error()) . "\n";
    21302180        } else {
    21312181            $info .= "No error found.\n";
     
    21412191                        break;
    21422192                    case 'curl':
    2143                         $version = curl_version();
     2193                        $version = (array) curl_version();
    21442194                        $info .= '      Version ' . $version['version'] . "\n";
    2145                         break;
    2146                     case 'mbstring':
    2147                         $info .= '      Overloading: ' . mb_get_info('func_overload') . "\n";
    21482195                        break;
    21492196                    case 'iconv':
     
    21612208    }
    21622209
    2163     public static function silence_errors($num, $str)
     2210    /**
     2211     * @return bool
     2212     */
     2213    public static function silence_errors(int $num, string $str)
    21642214    {
    21652215        // No-op
     2216        return true;
    21662217    }
    21672218
     
    21712222     * @return string the same URL without HTTP credentials.
    21722223     */
    2173     public static function url_remove_credentials($url)
    2174     {
    2175         return preg_replace('#^(https?://)[^/:@]+:[^/:@]+@#i', '$1', $url);
     2224    public static function url_remove_credentials(string $url)
     2225    {
     2226        // Cast for PHPStan: I do not think this can fail.
     2227        // The regex is valid and there should be no backtracking.
     2228        // https://github.com/phpstan/phpstan/issues/11547
     2229        return (string) preg_replace('#^(https?://)[^/:@]+:[^/:@]+@#i', '$1', $url);
    21762230    }
    21772231}
  • trunk/src/wp-includes/SimplePie/src/Net/IPv6.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie\Net;
     
    4811 * Class to validate and to work with IPv6 addresses.
    4912 *
    50  * @package SimplePie
    51  * @subpackage HTTP
    5213 * @copyright 2003-2005 The PHP Group
    5314 * @license http://www.opensource.org/licenses/bsd-license.php
     
    6324     * Uncompresses an IPv6 address
    6425     *
    65      * RFC 4291 allows you to compress concecutive zero pieces in an address to
     26     * RFC 4291 allows you to compress consecutive zero pieces in an address to
    6627     * '::'. This method expects a valid IPv6 address and expands the '::' to
    6728     * the required number of zero pieces.
     
    7839     * @return string The uncompressed IPv6 address
    7940     */
    80     public static function uncompress($ip)
     41    public static function uncompress(string $ip)
    8142    {
    8243        $c1 = -1;
     
    12384     * Compresses an IPv6 address
    12485     *
    125      * RFC 4291 allows you to compress concecutive zero pieces in an address to
     86     * RFC 4291 allows you to compress consecutive zero pieces in an address to
    12687     * '::'. This method expects a valid IPv6 address and compresses consecutive
    12788     * zero pieces to '::'.
     
    13495     * @return string The compressed IPv6 address
    13596     */
    136     public static function compress($ip)
     97    public static function compress(string $ip)
    13798    {
    13899        // Prepare the IP to be compressed
     
    141102
    142103        // Replace all leading zeros
    143         $ip_parts[0] = preg_replace('/(^|:)0+([0-9])/', '\1\2', $ip_parts[0]);
     104        $ip_parts[0] = (string) preg_replace('/(^|:)0+([0-9])/', '\1\2', $ip_parts[0]);
    144105
    145106        // Find bunches of zeros
     
    154115            }
    155116
     117            assert($pos !== null, 'For PHPStan: Since the regex matched, there is at least one match. And because the pattern is non-empty, the loop will always end with $pos ≥ 1.');
    156118            $ip_parts[0] = substr_replace($ip_parts[0], '::', $pos, $max);
    157119        }
     
    174136     *
    175137     * @param string $ip An IPv6 address
    176      * @return array [0] contains the IPv6 represented part, and [1] the IPv4 represented part
    177      */
    178     private static function split_v6_v4($ip)
     138     * @return array{string, string} [0] contains the IPv6 represented part, and [1] the IPv4 represented part
     139     */
     140    private static function split_v6_v4(string $ip): array
    179141    {
    180142        if (strpos($ip, '.') !== false) {
    181143            $pos = strrpos($ip, ':');
     144            assert($pos !== false, 'For PHPStan: IPv6 address must contain colon, since split_v6_v4 is only ever called after uncompress.');
    182145            $ipv6_part = substr($ip, 0, $pos);
    183146            $ipv4_part = substr($ip, $pos + 1);
     
    196159     * @return bool true if $ip is a valid IPv6 address
    197160     */
    198     public static function check_ipv6($ip)
     161    public static function check_ipv6(string $ip)
    199162    {
    200163        $ip = self::uncompress($ip);
     
    222185                // Check the value is valid
    223186                $value = hexdec($ipv6_part);
    224                 if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF) {
     187                if ($value < 0 || $value > 0xFFFF) {
     188                    return false;
     189                }
     190                assert(is_int($value), 'For PHPStan: $value is only float when $ipv6_part > PHP_INT_MAX');
     191                if (dechex($value) !== strtolower($ipv6_part)) {
    225192                    return false;
    226193                }
     
    249216     * @return bool true if $ip is a valid IPv6 address
    250217     */
    251     public static function checkIPv6($ip)
     218    public static function checkIPv6(string $ip)
    252219    {
    253220        return self::check_ipv6($ip);
  • trunk/src/wp-includes/SimplePie/src/Parse/Date.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie\Parse;
     
    4710/**
    4811 * Date Parser
    49  *
    50  * @package SimplePie
    51  * @subpackage Parsing
    5212 */
    5313class Date
     
    6525     *
    6626     * @access protected
    67      * @var array
     27     * @var array<string, int<1,7>>
    6828     */
    6929    public $day = [
     
    170130     *
    171131     * @access protected
    172      * @var array
     132     * @var array<string, int<1,12>>
    173133     */
    174134    public $month = [
     
    202162        'februari' => 2,
    203163        'maart' => 3,
    204         'april' => 4,
     164        // 'april' => 4,
    205165        'mei' => 5,
    206166        'juni' => 6,
    207167        'juli' => 7,
    208168        'augustus' => 8,
    209         'september' => 9,
     169        // 'september' => 9,
    210170        'oktober' => 10,
    211         'november' => 11,
    212         'december' => 12,
     171        // 'november' => 11,
     172        // 'december' => 12,
    213173        // French
    214174        'janvier' => 1,
     
    226186        // German
    227187        'januar' => 1,
    228         'jan' => 1,
     188        // 'jan' => 1,
    229189        'februar' => 2,
    230         'feb' => 2,
     190        // 'feb' => 2,
    231191        'märz' => 3,
    232192        'mär' => 3,
    233         'april' => 4,
    234         'apr' => 4,
    235         'mai' => 5, // no short form for may
    236         'juni' => 6,
    237         'jun' => 6,
    238         'juli' => 7,
    239         'jul' => 7,
    240         'august' => 8,
    241         'aug' => 8,
    242         'september' => 9,
    243         'sep' => 9,
    244         'oktober' => 10,
     193        // 'april' => 4,
     194        // 'apr' => 4,
     195        // 'mai' => 5, // no short form for may
     196        // 'juni' => 6,
     197        // 'jun' => 6,
     198        // 'juli' => 7,
     199        // 'jul' => 7,
     200        // 'august' => 8,
     201        // 'aug' => 8,
     202        // 'september' => 9,
     203        // 'sep' => 9,
     204        // 'oktober' => 10,
    245205        'okt' => 10,
    246         'november' => 11,
    247         'nov' => 11,
     206        // 'november' => 11,
     207        // 'nov' => 11,
    248208        'dezember' => 12,
    249209        'dez' => 12,
     
    259219        'settembre' => 9,
    260220        'ottobre' => 10,
    261         'novembre' => 11,
     221        // 'novembre' => 11,
    262222        'dicembre' => 12,
    263223        // Spanish
    264224        'enero' => 1,
    265225        'febrero' => 2,
    266         'marzo' => 3,
     226        // 'marzo' => 3,
    267227        'abril' => 4,
    268228        'mayo' => 5,
    269229        'junio' => 6,
    270230        'julio' => 7,
    271         'agosto' => 8,
     231        // 'agosto' => 8,
    272232        'septiembre' => 9,
    273233        'setiembre' => 9,
     
    299259        'szeptember' => 9,
    300260        'október' => 10,
    301         'november' => 11,
    302         'december' => 12,
     261        // 'november' => 11,
     262        // 'december' => 12,
    303263        // Greek
    304264        'Ιαν' => 1,
     
    352312     *
    353313     * @access protected
    354      * @var array
     314     * @var array<string, int>
    355315     */
    356316    public $timezone = [
     
    423383        'GIT' => -32400,
    424384        'GST' => 14400,
    425         'GST' => -7200,
     385        // 'GST' => -7200,
    426386        'GYT' => -14400,
    427387        'HAA' => -10800,
     
    577537     *
    578538     * @access private
    579      * @var array
     539     * @var array<string>
    580540     */
    581541    public $built_in = [];
     
    585545     *
    586546     * @access private
    587      * @var array
     547     * @var array<callable(string): (int|false)>
    588548     */
    589549    public $user = [];
     
    620580     *
    621581     * @access public
     582     * @return Date
    622583     */
    623584    public static function get()
     
    636597     * @access public
    637598     * @param string $date Date to parse
    638      * @return int Timestamp corresponding to date string, or false on failure
    639      */
    640     public function parse($date)
     599     * @return int|false Timestamp corresponding to date string, or false on failure
     600     */
     601    public function parse(string $date)
    641602    {
    642603        foreach ($this->user as $method) {
    643604            if (($returned = call_user_func($method, $date)) !== false) {
    644                 return $returned;
     605                return (int) $returned;
    645606            }
    646607        }
    647608
    648609        foreach ($this->built_in as $method) {
    649             if (($returned = call_user_func([$this, $method], $date)) !== false) {
     610            // TODO: we should really check this in constructor but that would require private properties.
     611            /** @var callable(string): (int|false) */
     612            $callable = [$this, $method];
     613            if (($returned = call_user_func($callable, $date)) !== false) {
    650614                return $returned;
    651615            }
     
    661625     * @access public
    662626     * @param callable $callback
    663      */
    664     public function add_callback($callback)
     627     * @return void
     628     */
     629    public function add_callback(callable $callback)
    665630    {
    666         if (is_callable($callback)) {
    667             $this->user[] = $callback;
    668         } else {
    669             trigger_error('User-supplied function must be a valid callback', E_USER_WARNING);
    670         }
     631        $this->user[] = $callback;
    671632    }
    672633
     
    677638     *
    678639     * @access protected
    679      * @return int Timestamp
    680      */
    681     public function date_w3cdtf($date)
     640     * @param string $date
     641     * @return int|false Timestamp
     642     */
     643    public function date_w3cdtf(string $date)
    682644    {
    683645        $pcre = <<<'PCRE'
     
    750712     *
    751713     * @access protected
    752      * @param string $data Data to strip comments from
     714     * @param string $string Data to strip comments from
    753715     * @return string Comment stripped string
    754716     */
    755     public function remove_rfc2822_comments($string)
     717    public function remove_rfc2822_comments(string $string)
    756718    {
    757         $string = (string) $string;
    758719        $position = 0;
    759720        $length = strlen($string);
     
    800761     *
    801762     * @access protected
    802      * @return int Timestamp
    803      */
    804     public function date_rfc2822($date)
     763     * @param string $date
     764     * @return int|false Timestamp
     765     */
     766    public function date_rfc2822(string $date)
    805767    {
    806768        static $pcre;
     
    835797            */
    836798
     799            $day = (int) $match[2];
    837800            // Find the month number
    838801            $month = $this->month[strtolower($match[3])];
     802            $year = (int) $match[4];
     803            $hour = (int) $match[5];
     804            $minute = (int) $match[6];
     805            // Second is optional, if it is empty set it to zero
     806            $second = (int) $match[7];
     807
     808            $tz_sign = $match[8];
     809            $tz_hour = (int) $match[9];
     810            $tz_minute = (int) $match[10];
     811            $tz_code = isset($match[11]) ? strtoupper($match[11]) : '';
    839812
    840813            // Numeric timezone
    841             if ($match[8] !== '') {
    842                 $timezone = $match[9] * 3600;
    843                 $timezone += $match[10] * 60;
    844                 if ($match[8] === '-') {
     814            if ($tz_sign !== '') {
     815                $timezone = $tz_hour * 3600;
     816                $timezone += $tz_minute * 60;
     817                if ($tz_sign === '-') {
    845818                    $timezone = 0 - $timezone;
    846819                }
    847820            }
    848821            // Character timezone
    849             elseif (isset($this->timezone[strtoupper($match[11])])) {
    850                 $timezone = $this->timezone[strtoupper($match[11])];
     822            elseif (isset($this->timezone[$tz_code])) {
     823                $timezone = $this->timezone[$tz_code];
    851824            }
    852825            // Assume everything else to be -0000
     
    856829
    857830            // Deal with 2/3 digit years
    858             if ($match[4] < 50) {
    859                 $match[4] += 2000;
    860             } elseif ($match[4] < 1000) {
    861                 $match[4] += 1900;
    862             }
    863 
    864             // Second is optional, if it is empty set it to zero
    865             if ($match[7] !== '') {
    866                 $second = $match[7];
    867             } else {
    868                 $second = 0;
    869             }
    870 
    871             return gmmktime(intval($match[5]), intval($match[6]), intval($second), intval($month), intval($match[2]), intval($match[4])) - $timezone;
     831            if ($year < 50) {
     832                $year += 2000;
     833            } elseif ($year < 1000) {
     834                $year += 1900;
     835            }
     836
     837            return gmmktime($hour, $minute, $second, $month, $day, $year) - $timezone;
    872838        }
    873839
     
    879845     *
    880846     * @access protected
    881      * @return int Timestamp
    882      */
    883     public function date_rfc850($date)
     847     * @param string $date
     848     * @return int|false Timestamp
     849     */
     850    public function date_rfc850(string $date)
    884851    {
    885852        static $pcre;
     
    906873            */
    907874
     875            $day = (int) $match[2];
    908876            // Month
    909877            $month = $this->month[strtolower($match[3])];
     878            $year = (int) $match[4];
     879            $hour = (int) $match[5];
     880            $minute = (int) $match[6];
     881            // Second is optional, if it is empty set it to zero
     882            $second = (int) $match[7];
     883
     884            $tz_code = strtoupper($match[8]);
    910885
    911886            // Character timezone
    912             if (isset($this->timezone[strtoupper($match[8])])) {
    913                 $timezone = $this->timezone[strtoupper($match[8])];
     887            if (isset($this->timezone[$tz_code])) {
     888                $timezone = $this->timezone[$tz_code];
    914889            }
    915890            // Assume everything else to be -0000
     
    919894
    920895            // Deal with 2 digit year
    921             if ($match[4] < 50) {
    922                 $match[4] += 2000;
     896            if ($year < 50) {
     897                $year += 2000;
    923898            } else {
    924                 $match[4] += 1900;
    925             }
    926 
    927             return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone;
     899                $year += 1900;
     900            }
     901
     902            return gmmktime($hour, $minute, $second, $month, $day, $year) - $timezone;
    928903        }
    929904
     
    935910     *
    936911     * @access protected
    937      * @return int Timestamp
    938      */
    939     public function date_asctime($date)
     912     * @param string $date
     913     * @return int|false Timestamp
     914     */
     915    public function date_asctime(string $date)
    940916    {
    941917        static $pcre;
     
    973949     *
    974950     * @access protected
    975      * @return int Timestamp
    976      */
    977     public function date_strtotime($date)
     951     * @param string $date
     952     * @return int|false Timestamp
     953     */
     954    public function date_strtotime(string $date)
    978955    {
    979956        $strtotime = strtotime($date);
  • trunk/src/wp-includes/SimplePie/src/Parser.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
    469
    4710use SimplePie\XML\Declaration\Parser as DeclarationParser;
     11use XMLParser;
    4812
    4913/**
     
    5216 *
    5317 * This class can be overloaded with {@see \SimplePie\SimplePie::set_parser_class()}
    54  *
    55  * @package SimplePie
    56  * @subpackage Parsing
    5718 */
    5819class Parser implements RegistryAware
    5920{
     21    /** @var int */
    6022    public $error_code;
     23    /** @var string */
    6124    public $error_string;
     25    /** @var int */
    6226    public $current_line;
     27    /** @var int */
    6328    public $current_column;
     29    /** @var int */
    6430    public $current_byte;
     31    /** @var string */
    6532    public $separator = ' ';
     33    /** @var string[] */
    6634    public $namespace = [''];
     35    /** @var string[] */
    6736    public $element = [''];
     37    /** @var string[] */
    6838    public $xml_base = [''];
     39    /** @var bool[] */
    6940    public $xml_base_explicit = [false];
     41    /** @var string[] */
    7042    public $xml_lang = [''];
     43    /** @var array<string, mixed> */
    7144    public $data = [];
     45    /** @var array<array<string, mixed>> */
    7246    public $datas = [[]];
     47    /** @var int */
    7348    public $current_xhtml_construct = -1;
     49    /** @var string */
    7450    public $encoding;
     51    /** @var Registry */
    7552    protected $registry;
    7653
    77     public function set_registry(\SimplePie\Registry $registry)/* : void */
     54    /**
     55     * @return void
     56     */
     57    public function set_registry(\SimplePie\Registry $registry)
    7858    {
    7959        $this->registry = $registry;
    8060    }
    8161
    82     public function parse(&$data, $encoding, $url = '')
     62    /**
     63     * @return bool
     64     */
     65    public function parse(string &$data, string $encoding, string $url = '')
    8366    {
    8467        if (class_exists('DOMXpath') && function_exists('Mf2\parse')) {
     
    9073            $query = '//*[contains(concat(" ", @class, " "), " h-feed ") or '.
    9174                'contains(concat(" ", @class, " "), " h-entry ")]';
     75            /** @var \DOMNodeList<\DOMElement> $result */
    9276            $result = $xpath->query($query);
    9377            if ($result->length !== 0) {
     
    129113            if ($declaration->parse()) {
    130114                $data = substr($data, $pos + 2);
    131                 $data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' ."\n". $this->declare_html_entities() . $data;
     115                $data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . "\n" .
     116                    self::set_doctype($data);
    132117            } else {
    133118                $this->error_string = 'SimplePie bug! Please report this!';
    134119                return false;
    135120            }
     121        } else {
     122            $data = self::set_doctype($data);
    136123        }
    137124
     
    142129            $parser_check = xml_parser_create();
    143130            xml_parse_into_struct($parser_check, '<foo>&amp;</foo>', $values);
    144             xml_parser_free($parser_check);
     131            if (\PHP_VERSION_ID < 80000) {
     132                xml_parser_free($parser_check);
     133            }
    145134            $xml_is_sane = isset($values[0]['value']);
    146135        }
     
    161150                //Parse by chunks not to use too much memory
    162151                do {
    163                     $stream_data = fread($stream, 1048576);
    164                     if (!xml_parse($xml, $stream_data === false ? '' : $stream_data, feof($stream))) {
     152                    $stream_data = (string) fread($stream, 1048576);
     153
     154                    if (!xml_parse($xml, $stream_data, feof($stream))) {
    165155                        $this->error_code = xml_get_error_code($xml);
    166                         $this->error_string = xml_error_string($this->error_code);
     156                        $this->error_string = xml_error_string($this->error_code) ?: "Unknown";
    167157                        $return = false;
    168158                        break;
     
    177167            $this->current_column = xml_get_current_column_number($xml);
    178168            $this->current_byte = xml_get_current_byte_index($xml);
    179             xml_parser_free($xml);
     169            if (\PHP_VERSION_ID < 80000) {
     170                xml_parser_free($xml);
     171            }
    180172            return $return;
    181173        }
     
    186178        while (@$xml->read()) {
    187179            switch ($xml->nodeType) {
    188                 case constant('XMLReader::END_ELEMENT'):
     180                case \XMLReader::END_ELEMENT:
    189181                    if ($xml->namespaceURI !== '') {
    190182                        $tagName = $xml->namespaceURI . $this->separator . $xml->localName;
     
    194186                    $this->tag_close(null, $tagName);
    195187                    break;
    196                 case constant('XMLReader::ELEMENT'):
     188                case \XMLReader::ELEMENT:
    197189                    $empty = $xml->isEmptyElement;
    198190                    if ($xml->namespaceURI !== '') {
     
    215207                    }
    216208                    break;
    217                 case constant('XMLReader::TEXT'):
    218 
    219                 case constant('XMLReader::CDATA'):
     209                case \XMLReader::TEXT:
     210
     211                case \XMLReader::CDATA:
    220212                    $this->cdata(null, $xml->value);
    221213                    break;
     
    233225    }
    234226
     227    /**
     228     * @return int
     229     */
    235230    public function get_error_code()
    236231    {
     
    238233    }
    239234
     235    /**
     236     * @return string
     237     */
    240238    public function get_error_string()
    241239    {
     
    243241    }
    244242
     243    /**
     244     * @return int
     245     */
    245246    public function get_current_line()
    246247    {
     
    248249    }
    249250
     251    /**
     252     * @return int
     253     */
    250254    public function get_current_column()
    251255    {
     
    253257    }
    254258
     259    /**
     260     * @return int
     261     */
    255262    public function get_current_byte()
    256263    {
     
    258265    }
    259266
     267    /**
     268     * @return array<string, mixed>
     269     */
    260270    public function get_data()
    261271    {
     
    263273    }
    264274
    265     public function tag_open($parser, $tag, $attributes)
     275    /**
     276     * @param XMLParser|resource|null $parser
     277     * @param array<string, string> $attributes
     278     * @return void
     279     */
     280    public function tag_open($parser, string $tag, array $attributes)
    266281    {
    267282        [$this->namespace[], $this->element[]] = $this->split_ns($tag);
     
    280295            }
    281296        } else {
    282             $this->xml_base[] = end($this->xml_base);
     297            $this->xml_base[] = end($this->xml_base) ?: '';
    283298            $this->xml_base_explicit[] = end($this->xml_base_explicit);
    284299        }
     
    287302            $this->xml_lang[] = $attribs[\SimplePie\SimplePie::NAMESPACE_XML]['lang'];
    288303        } else {
    289             $this->xml_lang[] = end($this->xml_lang);
     304            $this->xml_lang[] = end($this->xml_lang) ?: '';
    290305        }
    291306
     
    315330    }
    316331
    317     public function cdata($parser, $cdata)
     332    /**
     333     * @param XMLParser|resource|null $parser
     334     * @return void
     335     */
     336    public function cdata($parser, string $cdata)
    318337    {
    319338        if ($this->current_xhtml_construct >= 0) {
     
    324343    }
    325344
    326     public function tag_close($parser, $tag)
     345    /**
     346     * @param XMLParser|resource|null $parser
     347     * @return void
     348     */
     349    public function tag_close($parser, string $tag)
    327350    {
    328351        if ($this->current_xhtml_construct >= 0) {
     
    344367    }
    345368
    346     public function split_ns($string)
     369    /**
     370     * @return array{string, string}
     371     */
     372    public function split_ns(string $string)
    347373    {
    348374        static $cache = [];
     
    375401    }
    376402
    377     private function parse_hcard($data, $category = false)
     403    /**
     404     * @param array<string, mixed> $data
     405     */
     406    private function parse_hcard(array $data, bool $category = false): string
    378407    {
    379408        $name = '';
     
    399428    }
    400429
    401     private function parse_microformats(&$data, $url)
    402     {
     430    /**
     431     * @return true
     432     */
     433    private function parse_microformats(string &$data, string $url): bool
     434    {
     435        // For PHPStan, we already check that in call site.
     436        \assert(function_exists('Mf2\parse'));
     437        \assert(function_exists('Mf2\fetch'));
    403438        $feed_title = '';
    404439        $feed_author = null;
     
    486521                            $author = $author_cache[$author];
    487522                        } else {
    488                             $mf = \Mf2\fetch($author);
    489                             foreach ($mf['items'] as $hcard) {
    490                                 // Only interested in an h-card by itself in this case.
    491                                 if (!in_array('h-card', $hcard['type'])) {
    492                                     continue;
     523                            if ($mf = \Mf2\fetch($author)) {
     524                                foreach ($mf['items'] as $hcard) {
     525                                    // Only interested in an h-card by itself in this case.
     526                                    if (!in_array('h-card', $hcard['type'])) {
     527                                        continue;
     528                                    }
     529                                    // It must have a url property matching what we fetched.
     530                                    if (!isset($hcard['properties']['url']) ||
     531                                            !(in_array($author, $hcard['properties']['url']))) {
     532                                        continue;
     533                                    }
     534                                    // Save parse_hcard the trouble of finding the correct url.
     535                                    $hcard['properties']['url'][0] = $author;
     536                                    // Cache this h-card for the next h-entry to check.
     537                                    $author_cache[$author] = $this->parse_hcard($hcard);
     538                                    $author = $author_cache[$author];
     539                                    break;
    493540                                }
    494                                 // It must have a url property matching what we fetched.
    495                                 if (!isset($hcard['properties']['url']) ||
    496                                         !(in_array($author, $hcard['properties']['url']))) {
    497                                     continue;
    498                                 }
    499                                 // Save parse_hcard the trouble of finding the correct url.
    500                                 $hcard['properties']['url'][0] = $author;
    501                                 // Cache this h-card for the next h-entry to check.
    502                                 $author_cache[$author] = $this->parse_hcard($hcard);
    503                                 $author = $author_cache[$author];
    504                                 break;
    505541                            }
    506542                        }
     
    620656    }
    621657
    622     private function declare_html_entities()
     658    private static function set_doctype(string $data): string
     659    {
     660        // Strip DOCTYPE except if containing an [internal subset]
     661        $data = preg_replace('/^\\s*<!DOCTYPE\\s[^>\\[\\]]*>\s*/', '', $data) ?? $data;
     662        // Declare HTML entities only if no remaining DOCTYPE
     663        $doctype = preg_match('/^\\s*<!DOCTYPE\\s/', $data) ? '' : self::declare_html_entities();
     664        return $doctype . $data;
     665    }
     666
     667    private static function declare_html_entities(): string
    623668    {
    624669        // This is required because the RSS specification says that entity-encoded
    625670        // html is allowed, but the xml specification says they must be declared.
    626         return '<!DOCTYPE html [ <!ENTITY nbsp "&#x00A0;"> <!ENTITY iexcl "&#x00A1;"> <!ENTITY cent "&#x00A2;"> <!ENTITY pound "&#x00A3;"> <!ENTITY curren "&#x00A4;"> <!ENTITY yen "&#x00A5;"> <!ENTITY brvbar "&#x00A6;"> <!ENTITY sect "&#x00A7;"> <!ENTITY uml "&#x00A8;"> <!ENTITY copy "&#x00A9;"> <!ENTITY ordf "&#x00AA;"> <!ENTITY laquo "&#x00AB;"> <!ENTITY not "&#x00AC;"> <!ENTITY shy "&#x00AD;"> <!ENTITY reg "&#x00AE;"> <!ENTITY macr "&#x00AF;"> <!ENTITY deg "&#x00B0;"> <!ENTITY plusmn "&#x00B1;"> <!ENTITY sup2 "&#x00B2;"> <!ENTITY sup3 "&#x00B3;"> <!ENTITY acute "&#x00B4;"> <!ENTITY micro "&#x00B5;"> <!ENTITY para "&#x00B6;"> <!ENTITY middot "&#x00B7;"> <!ENTITY cedil "&#x00B8;"> <!ENTITY sup1 "&#x00B9;"> <!ENTITY ordm "&#x00BA;"> <!ENTITY raquo "&#x00BB;"> <!ENTITY frac14 "&#x00BC;"> <!ENTITY frac12 "&#x00BD;"> <!ENTITY frac34 "&#x00BE;"> <!ENTITY iquest "&#x00BF;"> <!ENTITY Agrave "&#x00C0;"> <!ENTITY Aacute "&#x00C1;"> <!ENTITY Acirc "&#x00C2;"> <!ENTITY Atilde "&#x00C3;"> <!ENTITY Auml "&#x00C4;"> <!ENTITY Aring "&#x00C5;"> <!ENTITY AElig "&#x00C6;"> <!ENTITY Ccedil "&#x00C7;"> <!ENTITY Egrave "&#x00C8;"> <!ENTITY Eacute "&#x00C9;"> <!ENTITY Ecirc "&#x00CA;"> <!ENTITY Euml "&#x00CB;"> <!ENTITY Igrave "&#x00CC;"> <!ENTITY Iacute "&#x00CD;"> <!ENTITY Icirc "&#x00CE;"> <!ENTITY Iuml "&#x00CF;"> <!ENTITY ETH "&#x00D0;"> <!ENTITY Ntilde "&#x00D1;"> <!ENTITY Ograve "&#x00D2;"> <!ENTITY Oacute "&#x00D3;"> <!ENTITY Ocirc "&#x00D4;"> <!ENTITY Otilde "&#x00D5;"> <!ENTITY Ouml "&#x00D6;"> <!ENTITY times "&#x00D7;"> <!ENTITY Oslash "&#x00D8;"> <!ENTITY Ugrave "&#x00D9;"> <!ENTITY Uacute "&#x00DA;"> <!ENTITY Ucirc "&#x00DB;"> <!ENTITY Uuml "&#x00DC;"> <!ENTITY Yacute "&#x00DD;"> <!ENTITY THORN "&#x00DE;"> <!ENTITY szlig "&#x00DF;"> <!ENTITY agrave "&#x00E0;"> <!ENTITY aacute "&#x00E1;"> <!ENTITY acirc "&#x00E2;"> <!ENTITY atilde "&#x00E3;"> <!ENTITY auml "&#x00E4;"> <!ENTITY aring "&#x00E5;"> <!ENTITY aelig "&#x00E6;"> <!ENTITY ccedil "&#x00E7;"> <!ENTITY egrave "&#x00E8;"> <!ENTITY eacute "&#x00E9;"> <!ENTITY ecirc "&#x00EA;"> <!ENTITY euml "&#x00EB;"> <!ENTITY igrave "&#x00EC;"> <!ENTITY iacute "&#x00ED;"> <!ENTITY icirc "&#x00EE;"> <!ENTITY iuml "&#x00EF;"> <!ENTITY eth "&#x00F0;"> <!ENTITY ntilde "&#x00F1;"> <!ENTITY ograve "&#x00F2;"> <!ENTITY oacute "&#x00F3;"> <!ENTITY ocirc "&#x00F4;"> <!ENTITY otilde "&#x00F5;"> <!ENTITY ouml "&#x00F6;"> <!ENTITY divide "&#x00F7;"> <!ENTITY oslash "&#x00F8;"> <!ENTITY ugrave "&#x00F9;"> <!ENTITY uacute "&#x00FA;"> <!ENTITY ucirc "&#x00FB;"> <!ENTITY uuml "&#x00FC;"> <!ENTITY yacute "&#x00FD;"> <!ENTITY thorn "&#x00FE;"> <!ENTITY yuml "&#x00FF;"> <!ENTITY OElig "&#x0152;"> <!ENTITY oelig "&#x0153;"> <!ENTITY Scaron "&#x0160;"> <!ENTITY scaron "&#x0161;"> <!ENTITY Yuml "&#x0178;"> <!ENTITY fnof "&#x0192;"> <!ENTITY circ "&#x02C6;"> <!ENTITY tilde "&#x02DC;"> <!ENTITY Alpha "&#x0391;"> <!ENTITY Beta "&#x0392;"> <!ENTITY Gamma "&#x0393;"> <!ENTITY Epsilon "&#x0395;"> <!ENTITY Zeta "&#x0396;"> <!ENTITY Eta "&#x0397;"> <!ENTITY Theta "&#x0398;"> <!ENTITY Iota "&#x0399;"> <!ENTITY Kappa "&#x039A;"> <!ENTITY Lambda "&#x039B;"> <!ENTITY Mu "&#x039C;"> <!ENTITY Nu "&#x039D;"> <!ENTITY Xi "&#x039E;"> <!ENTITY Omicron "&#x039F;"> <!ENTITY Pi "&#x03A0;"> <!ENTITY Rho "&#x03A1;"> <!ENTITY Sigma "&#x03A3;"> <!ENTITY Tau "&#x03A4;"> <!ENTITY Upsilon "&#x03A5;"> <!ENTITY Phi "&#x03A6;"> <!ENTITY Chi "&#x03A7;"> <!ENTITY Psi "&#x03A8;"> <!ENTITY Omega "&#x03A9;"> <!ENTITY alpha "&#x03B1;"> <!ENTITY beta "&#x03B2;"> <!ENTITY gamma "&#x03B3;"> <!ENTITY delta "&#x03B4;"> <!ENTITY epsilon "&#x03B5;"> <!ENTITY zeta "&#x03B6;"> <!ENTITY eta "&#x03B7;"> <!ENTITY theta "&#x03B8;"> <!ENTITY iota "&#x03B9;"> <!ENTITY kappa "&#x03BA;"> <!ENTITY lambda "&#x03BB;"> <!ENTITY mu "&#x03BC;"> <!ENTITY nu "&#x03BD;"> <!ENTITY xi "&#x03BE;"> <!ENTITY omicron "&#x03BF;"> <!ENTITY pi "&#x03C0;"> <!ENTITY rho "&#x03C1;"> <!ENTITY sigmaf "&#x03C2;"> <!ENTITY sigma "&#x03C3;"> <!ENTITY tau "&#x03C4;"> <!ENTITY upsilon "&#x03C5;"> <!ENTITY phi "&#x03C6;"> <!ENTITY chi "&#x03C7;"> <!ENTITY psi "&#x03C8;"> <!ENTITY omega "&#x03C9;"> <!ENTITY thetasym "&#x03D1;"> <!ENTITY upsih "&#x03D2;"> <!ENTITY piv "&#x03D6;"> <!ENTITY ensp "&#x2002;"> <!ENTITY emsp "&#x2003;"> <!ENTITY thinsp "&#x2009;"> <!ENTITY zwnj "&#x200C;"> <!ENTITY zwj "&#x200D;"> <!ENTITY lrm "&#x200E;"> <!ENTITY rlm "&#x200F;"> <!ENTITY ndash "&#x2013;"> <!ENTITY mdash "&#x2014;"> <!ENTITY lsquo "&#x2018;"> <!ENTITY rsquo "&#x2019;"> <!ENTITY sbquo "&#x201A;"> <!ENTITY ldquo "&#x201C;"> <!ENTITY rdquo "&#x201D;"> <!ENTITY bdquo "&#x201E;"> <!ENTITY dagger "&#x2020;"> <!ENTITY Dagger "&#x2021;"> <!ENTITY bull "&#x2022;"> <!ENTITY hellip "&#x2026;"> <!ENTITY permil "&#x2030;"> <!ENTITY prime "&#x2032;"> <!ENTITY Prime "&#x2033;"> <!ENTITY lsaquo "&#x2039;"> <!ENTITY rsaquo "&#x203A;"> <!ENTITY oline "&#x203E;"> <!ENTITY frasl "&#x2044;"> <!ENTITY euro "&#x20AC;"> <!ENTITY image "&#x2111;"> <!ENTITY weierp "&#x2118;"> <!ENTITY real "&#x211C;"> <!ENTITY trade "&#x2122;"> <!ENTITY alefsym "&#x2135;"> <!ENTITY larr "&#x2190;"> <!ENTITY uarr "&#x2191;"> <!ENTITY rarr "&#x2192;"> <!ENTITY darr "&#x2193;"> <!ENTITY harr "&#x2194;"> <!ENTITY crarr "&#x21B5;"> <!ENTITY lArr "&#x21D0;"> <!ENTITY uArr "&#x21D1;"> <!ENTITY rArr "&#x21D2;"> <!ENTITY dArr "&#x21D3;"> <!ENTITY hArr "&#x21D4;"> <!ENTITY forall "&#x2200;"> <!ENTITY part "&#x2202;"> <!ENTITY exist "&#x2203;"> <!ENTITY empty "&#x2205;"> <!ENTITY nabla "&#x2207;"> <!ENTITY isin "&#x2208;"> <!ENTITY notin "&#x2209;"> <!ENTITY ni "&#x220B;"> <!ENTITY prod "&#x220F;"> <!ENTITY sum "&#x2211;"> <!ENTITY minus "&#x2212;"> <!ENTITY lowast "&#x2217;"> <!ENTITY radic "&#x221A;"> <!ENTITY prop "&#x221D;"> <!ENTITY infin "&#x221E;"> <!ENTITY ang "&#x2220;"> <!ENTITY and "&#x2227;"> <!ENTITY or "&#x2228;"> <!ENTITY cap "&#x2229;"> <!ENTITY cup "&#x222A;"> <!ENTITY int "&#x222B;"> <!ENTITY there4 "&#x2234;"> <!ENTITY sim "&#x223C;"> <!ENTITY cong "&#x2245;"> <!ENTITY asymp "&#x2248;"> <!ENTITY ne "&#x2260;"> <!ENTITY equiv "&#x2261;"> <!ENTITY le "&#x2264;"> <!ENTITY ge "&#x2265;"> <!ENTITY sub "&#x2282;"> <!ENTITY sup "&#x2283;"> <!ENTITY nsub "&#x2284;"> <!ENTITY sube "&#x2286;"> <!ENTITY supe "&#x2287;"> <!ENTITY oplus "&#x2295;"> <!ENTITY otimes "&#x2297;"> <!ENTITY perp "&#x22A5;"> <!ENTITY sdot "&#x22C5;"> <!ENTITY lceil "&#x2308;"> <!ENTITY rceil "&#x2309;"> <!ENTITY lfloor "&#x230A;"> <!ENTITY rfloor "&#x230B;"> <!ENTITY lang "&#x2329;"> <!ENTITY rang "&#x232A;"> <!ENTITY loz "&#x25CA;"> <!ENTITY spades "&#x2660;"> <!ENTITY clubs "&#x2663;"> <!ENTITY hearts "&#x2665;"> <!ENTITY diams "&#x2666;"> ]>';
     671        return '<!DOCTYPE rss [ <!ENTITY nbsp "&#x00A0;"> <!ENTITY iexcl "&#x00A1;"> <!ENTITY cent "&#x00A2;"> <!ENTITY pound "&#x00A3;"> <!ENTITY curren "&#x00A4;"> <!ENTITY yen "&#x00A5;"> <!ENTITY brvbar "&#x00A6;"> <!ENTITY sect "&#x00A7;"> <!ENTITY uml "&#x00A8;"> <!ENTITY copy "&#x00A9;"> <!ENTITY ordf "&#x00AA;"> <!ENTITY laquo "&#x00AB;"> <!ENTITY not "&#x00AC;"> <!ENTITY shy "&#x00AD;"> <!ENTITY reg "&#x00AE;"> <!ENTITY macr "&#x00AF;"> <!ENTITY deg "&#x00B0;"> <!ENTITY plusmn "&#x00B1;"> <!ENTITY sup2 "&#x00B2;"> <!ENTITY sup3 "&#x00B3;"> <!ENTITY acute "&#x00B4;"> <!ENTITY micro "&#x00B5;"> <!ENTITY para "&#x00B6;"> <!ENTITY middot "&#x00B7;"> <!ENTITY cedil "&#x00B8;"> <!ENTITY sup1 "&#x00B9;"> <!ENTITY ordm "&#x00BA;"> <!ENTITY raquo "&#x00BB;"> <!ENTITY frac14 "&#x00BC;"> <!ENTITY frac12 "&#x00BD;"> <!ENTITY frac34 "&#x00BE;"> <!ENTITY iquest "&#x00BF;"> <!ENTITY Agrave "&#x00C0;"> <!ENTITY Aacute "&#x00C1;"> <!ENTITY Acirc "&#x00C2;"> <!ENTITY Atilde "&#x00C3;"> <!ENTITY Auml "&#x00C4;"> <!ENTITY Aring "&#x00C5;"> <!ENTITY AElig "&#x00C6;"> <!ENTITY Ccedil "&#x00C7;"> <!ENTITY Egrave "&#x00C8;"> <!ENTITY Eacute "&#x00C9;"> <!ENTITY Ecirc "&#x00CA;"> <!ENTITY Euml "&#x00CB;"> <!ENTITY Igrave "&#x00CC;"> <!ENTITY Iacute "&#x00CD;"> <!ENTITY Icirc "&#x00CE;"> <!ENTITY Iuml "&#x00CF;"> <!ENTITY ETH "&#x00D0;"> <!ENTITY Ntilde "&#x00D1;"> <!ENTITY Ograve "&#x00D2;"> <!ENTITY Oacute "&#x00D3;"> <!ENTITY Ocirc "&#x00D4;"> <!ENTITY Otilde "&#x00D5;"> <!ENTITY Ouml "&#x00D6;"> <!ENTITY times "&#x00D7;"> <!ENTITY Oslash "&#x00D8;"> <!ENTITY Ugrave "&#x00D9;"> <!ENTITY Uacute "&#x00DA;"> <!ENTITY Ucirc "&#x00DB;"> <!ENTITY Uuml "&#x00DC;"> <!ENTITY Yacute "&#x00DD;"> <!ENTITY THORN "&#x00DE;"> <!ENTITY szlig "&#x00DF;"> <!ENTITY agrave "&#x00E0;"> <!ENTITY aacute "&#x00E1;"> <!ENTITY acirc "&#x00E2;"> <!ENTITY atilde "&#x00E3;"> <!ENTITY auml "&#x00E4;"> <!ENTITY aring "&#x00E5;"> <!ENTITY aelig "&#x00E6;"> <!ENTITY ccedil "&#x00E7;"> <!ENTITY egrave "&#x00E8;"> <!ENTITY eacute "&#x00E9;"> <!ENTITY ecirc "&#x00EA;"> <!ENTITY euml "&#x00EB;"> <!ENTITY igrave "&#x00EC;"> <!ENTITY iacute "&#x00ED;"> <!ENTITY icirc "&#x00EE;"> <!ENTITY iuml "&#x00EF;"> <!ENTITY eth "&#x00F0;"> <!ENTITY ntilde "&#x00F1;"> <!ENTITY ograve "&#x00F2;"> <!ENTITY oacute "&#x00F3;"> <!ENTITY ocirc "&#x00F4;"> <!ENTITY otilde "&#x00F5;"> <!ENTITY ouml "&#x00F6;"> <!ENTITY divide "&#x00F7;"> <!ENTITY oslash "&#x00F8;"> <!ENTITY ugrave "&#x00F9;"> <!ENTITY uacute "&#x00FA;"> <!ENTITY ucirc "&#x00FB;"> <!ENTITY uuml "&#x00FC;"> <!ENTITY yacute "&#x00FD;"> <!ENTITY thorn "&#x00FE;"> <!ENTITY yuml "&#x00FF;"> <!ENTITY OElig "&#x0152;"> <!ENTITY oelig "&#x0153;"> <!ENTITY Scaron "&#x0160;"> <!ENTITY scaron "&#x0161;"> <!ENTITY Yuml "&#x0178;"> <!ENTITY fnof "&#x0192;"> <!ENTITY circ "&#x02C6;"> <!ENTITY tilde "&#x02DC;"> <!ENTITY Alpha "&#x0391;"> <!ENTITY Beta "&#x0392;"> <!ENTITY Gamma "&#x0393;"> <!ENTITY Epsilon "&#x0395;"> <!ENTITY Zeta "&#x0396;"> <!ENTITY Eta "&#x0397;"> <!ENTITY Theta "&#x0398;"> <!ENTITY Iota "&#x0399;"> <!ENTITY Kappa "&#x039A;"> <!ENTITY Lambda "&#x039B;"> <!ENTITY Mu "&#x039C;"> <!ENTITY Nu "&#x039D;"> <!ENTITY Xi "&#x039E;"> <!ENTITY Omicron "&#x039F;"> <!ENTITY Pi "&#x03A0;"> <!ENTITY Rho "&#x03A1;"> <!ENTITY Sigma "&#x03A3;"> <!ENTITY Tau "&#x03A4;"> <!ENTITY Upsilon "&#x03A5;"> <!ENTITY Phi "&#x03A6;"> <!ENTITY Chi "&#x03A7;"> <!ENTITY Psi "&#x03A8;"> <!ENTITY Omega "&#x03A9;"> <!ENTITY alpha "&#x03B1;"> <!ENTITY beta "&#x03B2;"> <!ENTITY gamma "&#x03B3;"> <!ENTITY delta "&#x03B4;"> <!ENTITY epsilon "&#x03B5;"> <!ENTITY zeta "&#x03B6;"> <!ENTITY eta "&#x03B7;"> <!ENTITY theta "&#x03B8;"> <!ENTITY iota "&#x03B9;"> <!ENTITY kappa "&#x03BA;"> <!ENTITY lambda "&#x03BB;"> <!ENTITY mu "&#x03BC;"> <!ENTITY nu "&#x03BD;"> <!ENTITY xi "&#x03BE;"> <!ENTITY omicron "&#x03BF;"> <!ENTITY pi "&#x03C0;"> <!ENTITY rho "&#x03C1;"> <!ENTITY sigmaf "&#x03C2;"> <!ENTITY sigma "&#x03C3;"> <!ENTITY tau "&#x03C4;"> <!ENTITY upsilon "&#x03C5;"> <!ENTITY phi "&#x03C6;"> <!ENTITY chi "&#x03C7;"> <!ENTITY psi "&#x03C8;"> <!ENTITY omega "&#x03C9;"> <!ENTITY thetasym "&#x03D1;"> <!ENTITY upsih "&#x03D2;"> <!ENTITY piv "&#x03D6;"> <!ENTITY ensp "&#x2002;"> <!ENTITY emsp "&#x2003;"> <!ENTITY thinsp "&#x2009;"> <!ENTITY zwnj "&#x200C;"> <!ENTITY zwj "&#x200D;"> <!ENTITY lrm "&#x200E;"> <!ENTITY rlm "&#x200F;"> <!ENTITY ndash "&#x2013;"> <!ENTITY mdash "&#x2014;"> <!ENTITY lsquo "&#x2018;"> <!ENTITY rsquo "&#x2019;"> <!ENTITY sbquo "&#x201A;"> <!ENTITY ldquo "&#x201C;"> <!ENTITY rdquo "&#x201D;"> <!ENTITY bdquo "&#x201E;"> <!ENTITY dagger "&#x2020;"> <!ENTITY Dagger "&#x2021;"> <!ENTITY bull "&#x2022;"> <!ENTITY hellip "&#x2026;"> <!ENTITY permil "&#x2030;"> <!ENTITY prime "&#x2032;"> <!ENTITY Prime "&#x2033;"> <!ENTITY lsaquo "&#x2039;"> <!ENTITY rsaquo "&#x203A;"> <!ENTITY oline "&#x203E;"> <!ENTITY frasl "&#x2044;"> <!ENTITY euro "&#x20AC;"> <!ENTITY image "&#x2111;"> <!ENTITY weierp "&#x2118;"> <!ENTITY real "&#x211C;"> <!ENTITY trade "&#x2122;"> <!ENTITY alefsym "&#x2135;"> <!ENTITY larr "&#x2190;"> <!ENTITY uarr "&#x2191;"> <!ENTITY rarr "&#x2192;"> <!ENTITY darr "&#x2193;"> <!ENTITY harr "&#x2194;"> <!ENTITY crarr "&#x21B5;"> <!ENTITY lArr "&#x21D0;"> <!ENTITY uArr "&#x21D1;"> <!ENTITY rArr "&#x21D2;"> <!ENTITY dArr "&#x21D3;"> <!ENTITY hArr "&#x21D4;"> <!ENTITY forall "&#x2200;"> <!ENTITY part "&#x2202;"> <!ENTITY exist "&#x2203;"> <!ENTITY empty "&#x2205;"> <!ENTITY nabla "&#x2207;"> <!ENTITY isin "&#x2208;"> <!ENTITY notin "&#x2209;"> <!ENTITY ni "&#x220B;"> <!ENTITY prod "&#x220F;"> <!ENTITY sum "&#x2211;"> <!ENTITY minus "&#x2212;"> <!ENTITY lowast "&#x2217;"> <!ENTITY radic "&#x221A;"> <!ENTITY prop "&#x221D;"> <!ENTITY infin "&#x221E;"> <!ENTITY ang "&#x2220;"> <!ENTITY and "&#x2227;"> <!ENTITY or "&#x2228;"> <!ENTITY cap "&#x2229;"> <!ENTITY cup "&#x222A;"> <!ENTITY int "&#x222B;"> <!ENTITY there4 "&#x2234;"> <!ENTITY sim "&#x223C;"> <!ENTITY cong "&#x2245;"> <!ENTITY asymp "&#x2248;"> <!ENTITY ne "&#x2260;"> <!ENTITY equiv "&#x2261;"> <!ENTITY le "&#x2264;"> <!ENTITY ge "&#x2265;"> <!ENTITY sub "&#x2282;"> <!ENTITY sup "&#x2283;"> <!ENTITY nsub "&#x2284;"> <!ENTITY sube "&#x2286;"> <!ENTITY supe "&#x2287;"> <!ENTITY oplus "&#x2295;"> <!ENTITY otimes "&#x2297;"> <!ENTITY perp "&#x22A5;"> <!ENTITY sdot "&#x22C5;"> <!ENTITY lceil "&#x2308;"> <!ENTITY rceil "&#x2309;"> <!ENTITY lfloor "&#x230A;"> <!ENTITY rfloor "&#x230B;"> <!ENTITY lang "&#x2329;"> <!ENTITY rang "&#x232A;"> <!ENTITY loz "&#x25CA;"> <!ENTITY spades "&#x2660;"> <!ENTITY clubs "&#x2663;"> <!ENTITY hearts "&#x2665;"> <!ENTITY diams "&#x2666;"> ]>';
    627672    }
    628673}
  • trunk/src/wp-includes/SimplePie/src/Rating.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
     
    5114 *
    5215 * This class can be overloaded with {@see \SimplePie\SimplePie::set_rating_class()}
    53  *
    54  * @package SimplePie
    55  * @subpackage API
    5616 */
    5717class Rating
     
    6020     * Rating scheme
    6121     *
    62      * @var string
     22     * @var ?string
    6323     * @see get_scheme()
    6424     */
     
    6828     * Rating value
    6929     *
    70      * @var string
     30     * @var ?string
    7131     * @see get_value()
    7232     */
     
    7939     * properties and their accessors
    8040     */
    81     public function __construct($scheme = null, $value = null)
    82     {
     41    public function __construct(
     42        ?string $scheme = null,
     43        ?string $value = null
     44    ) {
    8345        $this->scheme = $scheme;
    8446        $this->value = $value;
  • trunk/src/wp-includes/SimplePie/src/Registry.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
    469
     10use InvalidArgumentException;
    4711use SimplePie\Content\Type\Sniffer;
    4812use SimplePie\Parse\Date;
     
    5317 *
    5418 * Access this via {@see \SimplePie\SimplePie::get_registry()}
    55  *
    56  * @package SimplePie
    5719 */
    5820class Registry
     
    9153     *
    9254     * @see register()
    93      * @var array
     55     * @var array<string, class-string>
    9456     */
    9557    protected $classes = [];
     
    148110     * @return bool Successfulness
    149111     */
    150     public function register($type, $class, $legacy = false)
     112    public function register(string $type, $class, bool $legacy = false)
    151113    {
    152114        if (array_key_exists($type, $this->legacyTypes)) {
     
    201163        }
    202164
     165        // For PHPStan: values in $default should be subtypes of keys.
     166        /** @var class-string<T> */
    203167        $class = $this->default[$type];
    204168
    205169        if (array_key_exists($type, $this->classes)) {
     170            // For PHPStan: values in $classes should be subtypes of keys.
     171            /** @var class-string<T> */
    206172            $class = $this->classes[$type];
    207173        }
     
    215181     * @template T class-string $type
    216182     * @param class-string<T> $type
    217      * @param array $parameters Parameters to pass to the constructor
     183     * @param array<mixed> $parameters Parameters to pass to the constructor
    218184     * @return T Instance of class
    219185     */
    220     public function &create($type, $parameters = [])
     186    public function &create($type, array $parameters = [])
    221187    {
    222188        $class = $this->get_class($type);
     189        if ($class === null) {
     190            throw new InvalidArgumentException(sprintf(
     191                '%s(): Argument #1 ($type) "%s" not found in class list.',
     192                __METHOD__,
     193                $type
     194            ), 1);
     195        }
    223196
    224197        if (!method_exists($class, '__construct')) {
     
    226199        } else {
    227200            $reflector = new \ReflectionClass($class);
     201            // For PHPStan: $class is T.
     202            /** @var T */
    228203            $instance = $reflector->newInstanceArgs($parameters);
    229204        }
     
    235210            $instance->set_registry($this);
    236211        }
     212
    237213        return $instance;
    238214    }
     
    243219     * @param class-string $type
    244220     * @param string $method
    245      * @param array $parameters
     221     * @param array<mixed> $parameters
    246222     * @return mixed
    247223     */
    248     public function &call($type, $method, $parameters = [])
     224    public function &call($type, string $method, array $parameters = [])
    249225    {
    250226        $class = $this->get_class($type);
     227        if ($class === null) {
     228            throw new InvalidArgumentException(sprintf(
     229                '%s(): Argument #1 ($type) "%s" not found in class list.',
     230                __METHOD__,
     231                $type
     232            ), 1);
     233        }
    251234
    252235        if (in_array($class, $this->legacy)) {
     
    257240                    // No longer supported as of PHP 8.0.
    258241                    if ($method === 'get_handler') {
     242                        // Fixing this PHPStan error breaks CacheTest::testDirectOverrideLegacy()
     243                        /** @phpstan-ignore argument.type */
    259244                        $result = @call_user_func_array([$class, 'create'], $parameters);
    260245                        return $result;
     
    264249        }
    265250
    266         $result = call_user_func_array([$class, $method], $parameters);
     251        $callable = [$class, $method];
     252        assert(is_callable($callable), 'For PHPstan');
     253        $result = call_user_func_array($callable, $parameters);
    267254        return $result;
    268255    }
  • trunk/src/wp-includes/SimplePie/src/RegistryAware.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2022 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
     
    4912 *
    5013 * {@see \SimplePie\SimplePie::get_registry()}
    51  *
    52  * @package SimplePie
    5314 */
    5415interface RegistryAware
     
    5718     * Set the Registry into the class
    5819     *
    59      * @param Registry $registry
    60      *
    6120     * @return void
    6221     */
    63     public function set_registry(Registry $registry)/* : void */;
     22    public function set_registry(Registry $registry);
    6423}
  • trunk/src/wp-includes/SimplePie/src/Restriction.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
     
    5114 *
    5215 * This class can be overloaded with {@see \SimplePie\SimplePie::set_restriction_class()}
    53  *
    54  * @package SimplePie
    55  * @subpackage API
    5616 */
    5717class Restriction
    5818{
     19    public const RELATIONSHIP_ALLOW = 'allow';
     20    public const RELATIONSHIP_DENY = 'deny';
     21
    5922    /**
    6023     * Relationship ('allow'/'deny')
    6124     *
    62      * @var string
     25     * @var self::RELATIONSHIP_*|null
    6326     * @see get_relationship()
    6427     */
     
    6831     * Type of restriction
    6932     *
    70      * @var string
     33     * @var string|null
    7134     * @see get_type()
    7235     */
     
    7639     * Restricted values
    7740     *
    78      * @var string
     41     * @var string|null
    7942     * @see get_value()
    8043     */
     
    8649     * For documentation on all the parameters, see the corresponding
    8750     * properties and their accessors
     51     *
     52     * @param ?self::RELATIONSHIP_* $relationship
    8853     */
    89     public function __construct($relationship = null, $type = null, $value = null)
     54    public function __construct(?string $relationship = null, ?string $type = null, ?string $value = null)
    9055    {
    9156        $this->relationship = $relationship;
     
    10873     * Get the relationship
    10974     *
    110      * @return string|null Either 'allow' or 'deny'
     75     * @return ?self::RELATIONSHIP_*
    11176     */
    11277    public function get_relationship()
  • trunk/src/wp-includes/SimplePie/src/Sanitize.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
    469
     10use DOMDocument;
     11use DOMXPath;
    4712use InvalidArgumentException;
     13use Psr\Http\Client\ClientInterface;
     14use Psr\Http\Message\RequestFactoryInterface;
     15use Psr\Http\Message\UriFactoryInterface;
    4816use SimplePie\Cache\Base;
    4917use SimplePie\Cache\BaseDataCache;
     
    5119use SimplePie\Cache\DataCache;
    5220use SimplePie\Cache\NameFilter;
     21use SimplePie\HTTP\Client;
     22use SimplePie\HTTP\ClientException;
     23use SimplePie\HTTP\FileClient;
     24use SimplePie\HTTP\Psr18Client;
    5325
    5426/**
     
    5830 * This class can be overloaded with {@see \SimplePie\SimplePie::set_sanitize_class()}
    5931 *
    60  * @package SimplePie
    6132 * @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
    6233 */
     
    6435{
    6536    // Private vars
    66     public $base;
     37    /** @var string */
     38    public $base = '';
    6739
    6840    // Options
     41    /** @var bool */
    6942    public $remove_div = true;
     43    /** @var string */
    7044    public $image_handler = '';
     45    /** @var string[] */
    7146    public $strip_htmltags = ['base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'];
     47    /** @var bool */
    7248    public $encode_instead_of_strip = false;
     49    /** @var string[] */
    7350    public $strip_attributes = ['bgsound', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'];
     51    /** @var string[] */
    7452    public $rename_attributes = [];
     53    /** @var array<string, array<string, string>> */
    7554    public $add_attributes = ['audio' => ['preload' => 'none'], 'iframe' => ['sandbox' => 'allow-scripts allow-same-origin'], 'video' => ['preload' => 'none']];
     55    /** @var bool */
    7656    public $strip_comments = false;
     57    /** @var string */
    7758    public $output_encoding = 'UTF-8';
     59    /** @var bool */
    7860    public $enable_cache = true;
     61    /** @var string */
    7962    public $cache_location = './cache';
     63    /** @var string&(callable(string): string) */
    8064    public $cache_name_function = 'md5';
    8165
     
    8468     */
    8569    private $cache_namefilter;
     70    /** @var int */
    8671    public $timeout = 10;
     72    /** @var string */
    8773    public $useragent = '';
     74    /** @var bool */
    8875    public $force_fsockopen = false;
    89     public $replace_url_attributes = null;
     76    /** @var array<string, string|string[]> */
     77    public $replace_url_attributes = [];
     78    /**
     79     * @var array<int, mixed> Custom curl options
     80     * @see SimplePie::set_curl_options()
     81     */
     82    private $curl_options = [];
     83
     84    /** @var Registry */
    9085    public $registry;
    9186
     
    105100     * Array is a tree split at DNS levels. Example:
    106101     * array('biz' => true, 'com' => array('example' => true), 'net' => array('example' => array('www' => true)))
     102     * @var true|array<string, true|array<string, true|array<string, array<string, true|array<string, true|array<string, true>>>>>>
    107103     */
    108104    public $https_domains = [];
     105
     106    /**
     107     * @var Client|null
     108     */
     109    private $http_client = null;
    109110
    110111    public function __construct()
     
    114115    }
    115116
    116     public function remove_div($enable = true)
     117    /**
     118     * @return void
     119     */
     120    public function remove_div(bool $enable = true)
    117121    {
    118122        $this->remove_div = (bool) $enable;
    119123    }
    120124
     125    /**
     126     * @param string|false $page
     127     * @return void
     128     */
    121129    public function set_image_handler($page = false)
    122130    {
     
    124132            $this->image_handler = (string) $page;
    125133        } else {
    126             $this->image_handler = false;
    127         }
    128     }
    129 
    130     public function set_registry(\SimplePie\Registry $registry)/* : void */
     134            $this->image_handler = '';
     135        }
     136    }
     137
     138    /**
     139     * @return void
     140     */
     141    public function set_registry(\SimplePie\Registry $registry)
    131142    {
    132143        $this->registry = $registry;
    133144    }
    134145
    135     public function pass_cache_data($enable_cache = true, $cache_location = './cache', $cache_name_function = 'md5', $cache_class = 'SimplePie\Cache', ?DataCache $cache = null)
    136     {
    137         if (isset($enable_cache)) {
    138             $this->enable_cache = (bool) $enable_cache;
    139         }
     146    /**
     147     * @param (string&(callable(string): string))|NameFilter $cache_name_function
     148     * @param class-string<Cache> $cache_class
     149     * @return void
     150     */
     151    public function pass_cache_data(bool $enable_cache = true, string $cache_location = './cache', $cache_name_function = 'md5', string $cache_class = Cache::class, ?DataCache $cache = null)
     152    {
     153        $this->enable_cache = $enable_cache;
    140154
    141155        if ($cache_location) {
    142             $this->cache_location = (string) $cache_location;
    143         }
    144 
    145         if (!is_string($cache_name_function) && !is_object($cache_name_function) && !$cache_name_function instanceof NameFilter) {
     156            $this->cache_location = $cache_location;
     157        }
     158
     159        // @phpstan-ignore-next-line Enforce PHPDoc type.
     160        if (!is_string($cache_name_function) && !$cache_name_function instanceof NameFilter) {
    146161            throw new InvalidArgumentException(sprintf(
    147162                '%s(): Argument #3 ($cache_name_function) must be of type %s',
     
    154169        if (is_string($cache_name_function)) {
    155170            // trigger_error(sprintf('Providing $cache_name_function as string in "%s()" is deprecated since SimplePie 1.8.0, provide as "%s" instead.', __METHOD__, NameFilter::class), \E_USER_DEPRECATED);
    156             $this->cache_name_function = (string) $cache_name_function;
     171            $this->cache_name_function = $cache_name_function;
    157172
    158173            $cache_name_function = new CallableNameFilter($cache_name_function);
     
    166181    }
    167182
    168     public function pass_file_data($file_class = 'SimplePie\File', $timeout = 10, $useragent = '', $force_fsockopen = false)
    169     {
     183    /**
     184     * Set a PSR-18 client and PSR-17 factories
     185     *
     186     * Allows you to use your own HTTP client implementations.
     187     */
     188    final public function set_http_client(
     189        ClientInterface $http_client,
     190        RequestFactoryInterface $request_factory,
     191        UriFactoryInterface $uri_factory
     192    ): void {
     193        $this->http_client = new Psr18Client($http_client, $request_factory, $uri_factory);
     194    }
     195
     196    /**
     197     * @deprecated since SimplePie 1.9.0, use \SimplePie\Sanitize::set_http_client() instead.
     198     * @param class-string<File> $file_class
     199     * @param array<int, mixed> $curl_options
     200     * @return void
     201     */
     202    public function pass_file_data(string $file_class = File::class, int $timeout = 10, string $useragent = '', bool $force_fsockopen = false, array $curl_options = [])
     203    {
     204        // trigger_error(sprintf('SimplePie\Sanitize::pass_file_data() is deprecated since SimplePie 1.9.0, please use "SimplePie\Sanitize::set_http_client()" instead.'), \E_USER_DEPRECATED);
    170205        if ($timeout) {
    171             $this->timeout = (string) $timeout;
     206            $this->timeout = $timeout;
    172207        }
    173208
    174209        if ($useragent) {
    175             $this->useragent = (string) $useragent;
     210            $this->useragent = $useragent;
    176211        }
    177212
    178213        if ($force_fsockopen) {
    179             $this->force_fsockopen = (string) $force_fsockopen;
    180         }
    181     }
    182 
     214            $this->force_fsockopen = $force_fsockopen;
     215        }
     216
     217        $this->curl_options = $curl_options;
     218        // Invalidate the registered client.
     219        $this->http_client = null;
     220    }
     221
     222    /**
     223     * @param string[]|string|false $tags Set a list of tags to strip, or set empty string to use default tags, or false to strip nothing.
     224     * @return void
     225     */
    183226    public function strip_htmltags($tags = ['base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'])
    184227    {
     
    190233            }
    191234        } else {
    192             $this->strip_htmltags = false;
    193         }
    194     }
    195 
    196     public function encode_instead_of_strip($encode = false)
    197     {
    198         $this->encode_instead_of_strip = (bool) $encode;
    199     }
    200 
     235            $this->strip_htmltags = [];
     236        }
     237    }
     238
     239    /**
     240     * @return void
     241     */
     242    public function encode_instead_of_strip(bool $encode = false)
     243    {
     244        $this->encode_instead_of_strip = $encode;
     245    }
     246
     247    /**
     248     * @param string[]|string $attribs
     249     * @return void
     250     */
    201251    public function rename_attributes($attribs = [])
    202252    {
     
    208258            }
    209259        } else {
    210             $this->rename_attributes = false;
    211         }
    212     }
    213 
     260            $this->rename_attributes = [];
     261        }
     262    }
     263
     264    /**
     265     * @param string[]|string $attribs
     266     * @return void
     267     */
    214268    public function strip_attributes($attribs = ['bgsound', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'])
    215269    {
     
    221275            }
    222276        } else {
    223             $this->strip_attributes = false;
    224         }
    225     }
    226 
    227     public function add_attributes($attribs = ['audio' => ['preload' => 'none'], 'iframe' => ['sandbox' => 'allow-scripts allow-same-origin'], 'video' => ['preload' => 'none']])
    228     {
    229         if ($attribs) {
    230             if (is_array($attribs)) {
    231                 $this->add_attributes = $attribs;
    232             } else {
    233                 $this->add_attributes = explode(',', $attribs);
    234             }
    235         } else {
    236             $this->add_attributes = false;
    237         }
    238     }
    239 
    240     public function strip_comments($strip = false)
    241     {
    242         $this->strip_comments = (bool) $strip;
    243     }
    244 
    245     public function set_output_encoding($encoding = 'UTF-8')
    246     {
    247         $this->output_encoding = (string) $encoding;
     277            $this->strip_attributes = [];
     278        }
     279    }
     280
     281    /**
     282     * @param array<string, array<string, string>> $attribs
     283     * @return void
     284     */
     285    public function add_attributes(array $attribs = ['audio' => ['preload' => 'none'], 'iframe' => ['sandbox' => 'allow-scripts allow-same-origin'], 'video' => ['preload' => 'none']])
     286    {
     287        $this->add_attributes = $attribs;
     288    }
     289
     290    /**
     291     * @return void
     292     */
     293    public function strip_comments(bool $strip = false)
     294    {
     295        $this->strip_comments = $strip;
     296    }
     297
     298    /**
     299     * @return void
     300     */
     301    public function set_output_encoding(string $encoding = 'UTF-8')
     302    {
     303        $this->output_encoding = $encoding;
    248304    }
    249305
     
    257313     *
    258314     * @since 1.0
    259      * @param array|null $element_attribute Element/attribute key/value pairs, null for default
    260      */
    261     public function set_url_replacements($element_attribute = null)
     315     * @param array<string, string|string[]>|null $element_attribute Element/attribute key/value pairs, null for default
     316     * @return void
     317     */
     318    public function set_url_replacements(?array $element_attribute = null)
    262319    {
    263320        if ($element_attribute === null) {
     
    283340            ];
    284341        }
    285         $this->replace_url_attributes = (array) $element_attribute;
     342        $this->replace_url_attributes = $element_attribute;
    286343    }
    287344
     
    290347     * @see \SimplePie\Misc::https_url()
    291348     * Example array('biz', 'example.com', 'example.org', 'www.example.net');
    292      */
    293     public function set_https_domains($domains)
     349     *
     350     * @param string[] $domains list of domain names ['biz', 'example.com', 'example.org', 'www.example.net']
     351     *
     352     * @return void
     353     */
     354    public function set_https_domains(array $domains)
    294355    {
    295356        $this->https_domains = [];
     
    297358            $domain = trim($domain, ". \t\n\r\0\x0B");
    298359            $segments = array_reverse(explode('.', $domain));
     360            /** @var true|array<string, true|array<string, true|array<string, array<string, true|array<string, true|array<string, true>>>>>> */ // Needed for PHPStan.
    299361            $node = &$this->https_domains;
    300362            foreach ($segments as $segment) {//Build a tree
     
    313375    /**
    314376     * Check if the domain is in the list of forced HTTPS.
    315      */
    316     protected function is_https_domain($domain)
     377     *
     378     * @return bool
     379     */
     380    protected function is_https_domain(string $domain)
    317381    {
    318382        $domain = trim($domain, '. ');
     
    331395    /**
    332396     * Force HTTPS for selected Web sites.
    333      */
    334     public function https_url($url)
    335     {
    336         return (strtolower(substr($url, 0, 7)) === 'http://') &&
    337             $this->is_https_domain(parse_url($url, PHP_URL_HOST)) ?
    338             substr_replace($url, 's', 4, 0) : //Add the 's' to HTTPS
    339             $url;
    340     }
    341 
    342     public function sanitize($data, $type, $base = '')
     397     *
     398     * @return string
     399     */
     400    public function https_url(string $url)
     401    {
     402        return (
     403            strtolower(substr($url, 0, 7)) === 'http://'
     404            && ($parsed = parse_url($url, PHP_URL_HOST)) !== false // Malformed URL
     405            && $parsed !== null // Missing host
     406            && $this->is_https_domain($parsed) // Should be forced?
     407        ) ? substr_replace($url, 's', 4, 0) // Add the 's' to HTTPS
     408        : $url;
     409    }
     410
     411    /**
     412     * @param int-mask-of<SimplePie::CONSTRUCT_*> $type
     413     * @param string $base
     414     * @return string Sanitized data; false if output encoding is changed to something other than UTF-8 and conversion fails
     415     */
     416    public function sanitize(string $data, int $type, string $base = '')
    343417    {
    344418        $data = trim($data);
     
    363437                $document->encoding = 'UTF-8';
    364438
     439                // PHPStan seems to have trouble resolving int-mask because bitwise
     440                // operators are used when operators are used when passing this parameter.
     441                // https://github.com/phpstan/phpstan/issues/9384
     442                /** @var int-mask-of<SimplePie::CONSTRUCT_*> $type */
    365443                $data = $this->preprocess($data, $type);
    366444
    367                 set_error_handler(['SimplePie\Misc', 'silence_errors']);
     445                set_error_handler([Misc::class, 'silence_errors']);
    368446                $document->loadHTML($data);
    369447                restore_error_handler();
     
    373451                // Strip comments
    374452                if ($this->strip_comments) {
     453                    /** @var \DOMNodeList<\DOMComment> */
    375454                    $comments = $xpath->query('//comment()');
    376455
    377456                    foreach ($comments as $comment) {
    378                         $comment->parentNode->removeChild($comment);
     457                        $parentNode = $comment->parentNode;
     458                        assert($parentNode !== null, 'For PHPStan, comment must have a parent');
     459                        $parentNode->removeChild($comment);
    379460                    }
    380461                }
     
    382463                // Strip out HTML tags and attributes that might cause various security problems.
    383464                // Based on recommendations by Mark Pilgrim at:
    384                 // http://diveintomark.org/archives/2003/06/12/how_to_consume_rss_safely
     465                // https://web.archive.org/web/20110902041826/http://diveintomark.org:80/archives/2003/06/12/how_to_consume_rss_safely
    385466                if ($this->strip_htmltags) {
    386467                    foreach ($this->strip_htmltags as $tag) {
     
    414495
    415496                // If image handling (caching, etc.) is enabled, cache and rewrite all the image tags.
    416                 if (isset($this->image_handler) && ((string) $this->image_handler) !== '' && $this->enable_cache) {
     497                if ($this->image_handler !== '' && $this->enable_cache) {
    417498                    $images = $document->getElementsByTagName('img');
    418499
     
    425506                                $img->setAttribute('src', $this->image_handler . $image_url);
    426507                            } else {
    427                                 $file = $this->registry->create(File::class, [$img->getAttribute('src'), $this->timeout, 5, ['X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']], $this->useragent, $this->force_fsockopen]);
    428                                 $headers = $file->headers;
    429 
    430                                 if ($file->success && ($file->method & \SimplePie\SimplePie::FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) {
    431                                     if ($cache->set_data($image_url, ['headers' => $file->headers, 'body' => $file->body], $this->cache_duration)) {
     508                                try {
     509                                    $file = $this->get_http_client()->request(
     510                                        Client::METHOD_GET,
     511                                        $img->getAttribute('src'),
     512                                        ['X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']]
     513                                    );
     514                                } catch (ClientException $th) {
     515                                    continue;
     516                                }
     517
     518                                if ((!Misc::is_remote_uri($file->get_final_requested_uri()) || ($file->get_status_code() === 200 || $file->get_status_code() > 206 && $file->get_status_code() < 300))) {
     519                                    if ($cache->set_data($image_url, ['headers' => $file->get_headers(), 'body' => $file->get_body_content()], $this->cache_duration)) {
    432520                                        $img->setAttribute('src', $this->image_handler . $image_url);
    433521                                    } else {
     
    441529
    442530                // Get content node
    443                 $div = $document->getElementsByTagName('body')->item(0)->firstChild;
     531                $div = null;
     532                if (($item = $document->getElementsByTagName('body')->item(0)) !== null) {
     533                    $div = $item->firstChild;
     534                }
    444535                // Finally, convert to a HTML string
    445                 $data = trim($document->saveHTML($div));
     536                $data = trim((string) $document->saveHTML($div));
    446537
    447538                if ($this->remove_div) {
    448539                    $data = preg_replace('/^<div' . \SimplePie\SimplePie::PCRE_XML_ATTRIBUTE . '>/', '', $data);
    449                     $data = preg_replace('/<\/div>$/', '', $data);
     540                    // Cast for PHPStan, it is unable to validate a non-literal regex above.
     541                    $data = preg_replace('/<\/div>$/', '', (string) $data);
    450542                } else {
    451543                    $data = preg_replace('/^<div' . \SimplePie\SimplePie::PCRE_XML_ATTRIBUTE . '>/', '<div>', $data);
    452544                }
    453545
    454                 $data = str_replace('</source>', '', $data);
     546                // Cast for PHPStan, it is unable to validate a non-literal regex above.
     547                $data = str_replace('</source>', '', (string) $data);
    455548            }
    456549
     
    467560
    468561            if ($this->output_encoding !== 'UTF-8') {
     562                // This really returns string|false but changing encoding is uncommon and we are going to deprecate it, so let’s just lie to PHPStan in the interest of cleaner annotations.
     563                /** @var string */
    469564                $data = $this->registry->call(Misc::class, 'change_encoding', [$data, 'UTF-8', $this->output_encoding]);
    470565            }
     
    473568    }
    474569
    475     protected function preprocess($html, $type)
     570    /**
     571     * @param int-mask-of<SimplePie::CONSTRUCT_*> $type
     572     * @return string
     573     */
     574    protected function preprocess(string $html, int $type)
    476575    {
    477576        $ret = '';
     
    494593    }
    495594
    496     public function replace_urls($document, $tag, $attributes)
     595    /**
     596     * @param array<string>|string $attributes
     597     * @return void
     598     */
     599    public function replace_urls(DOMDocument $document, string $tag, $attributes)
    497600    {
    498601        if (!is_array($attributes)) {
     
    516619    }
    517620
    518     public function do_strip_htmltags($match)
     621    /**
     622     * @param array<int, string> $match
     623     * @return string
     624     */
     625    public function do_strip_htmltags(array $match)
    519626    {
    520627        if ($this->encode_instead_of_strip) {
     
    533640    }
    534641
    535     protected function strip_tag($tag, $document, $xpath, $type)
     642    /**
     643     * @param int-mask-of<SimplePie::CONSTRUCT_*> $type
     644     * @return void
     645     */
     646    protected function strip_tag(string $tag, DOMDocument $document, DOMXPath $xpath, int $type)
    536647    {
    537648        $elements = $xpath->query('body//' . $tag);
     649
     650        if ($elements === false) {
     651            throw new \SimplePie\Exception(sprintf(
     652                '%s(): Possibly malformed expression, check argument #1 ($tag)',
     653                __METHOD__
     654            ), 1);
     655        }
     656
    538657        if ($this->encode_instead_of_strip) {
    539658            foreach ($elements as $element) {
     
    543662                if (!in_array($tag, ['script', 'style'])) {
    544663                    $text = '<' . $tag;
    545                     if ($element->hasAttributes()) {
     664                    if ($element->attributes !== null) {
    546665                        $attrs = [];
    547666                        foreach ($element->attributes as $name => $attr) {
     
    569688                $number = $element->childNodes->length;
    570689                for ($i = $number; $i > 0; $i--) {
    571                     $child = $element->childNodes->item(0);
    572                     $fragment->appendChild($child);
     690                    if (($child = $element->childNodes->item(0)) !== null) {
     691                        $fragment->appendChild($child);
     692                    }
    573693                }
    574694
     
    577697                }
    578698
    579                 $element->parentNode->replaceChild($fragment, $element);
     699                if (($parentNode = $element->parentNode) !== null) {
     700                    $parentNode->replaceChild($fragment, $element);
     701                }
    580702            }
    581703
     
    583705        } elseif (in_array($tag, ['script', 'style'])) {
    584706            foreach ($elements as $element) {
    585                 $element->parentNode->removeChild($element);
     707                if (($parentNode = $element->parentNode) !== null) {
     708                    $parentNode->removeChild($element);
     709                }
    586710            }
    587711
     
    592716                $number = $element->childNodes->length;
    593717                for ($i = $number; $i > 0; $i--) {
    594                     $child = $element->childNodes->item(0);
    595                     $fragment->appendChild($child);
    596                 }
    597 
    598                 $element->parentNode->replaceChild($fragment, $element);
    599             }
    600         }
    601     }
    602 
    603     protected function strip_attr($attrib, $xpath)
     718                    if (($child = $element->childNodes->item(0)) !== null) {
     719                        $fragment->appendChild($child);
     720                    }
     721                }
     722
     723                if (($parentNode = $element->parentNode) !== null) {
     724                    $parentNode->replaceChild($fragment, $element);
     725                }
     726            }
     727        }
     728    }
     729
     730    /**
     731     * @return void
     732     */
     733    protected function strip_attr(string $attrib, DOMXPath $xpath)
    604734    {
    605735        $elements = $xpath->query('//*[@' . $attrib . ']');
    606736
     737        if ($elements === false) {
     738            throw new \SimplePie\Exception(sprintf(
     739                '%s(): Possibly malformed expression, check argument #1 ($attrib)',
     740                __METHOD__
     741            ), 1);
     742        }
     743
     744        /** @var \DOMElement $element */
    607745        foreach ($elements as $element) {
    608746            $element->removeAttribute($attrib);
     
    610748    }
    611749
    612     protected function rename_attr($attrib, $xpath)
     750    /**
     751     * @return void
     752     */
     753    protected function rename_attr(string $attrib, DOMXPath $xpath)
    613754    {
    614755        $elements = $xpath->query('//*[@' . $attrib . ']');
    615756
     757        if ($elements === false) {
     758            throw new \SimplePie\Exception(sprintf(
     759                '%s(): Possibly malformed expression, check argument #1 ($attrib)',
     760                __METHOD__
     761            ), 1);
     762        }
     763
     764        /** @var \DOMElement $element */
    616765        foreach ($elements as $element) {
    617766            $element->setAttribute('data-sanitized-' . $attrib, $element->getAttribute($attrib));
     
    620769    }
    621770
    622     protected function add_attr($tag, $valuePairs, $document)
     771    /**
     772     * @param array<string, string> $valuePairs
     773     * @return void
     774     */
     775    protected function add_attr(string $tag, array $valuePairs, DOMDocument $document)
    623776    {
    624777        $elements = $document->getElementsByTagName($tag);
     778        /** @var \DOMElement $element */
    625779        foreach ($elements as $element) {
    626780            foreach ($valuePairs as $attrib => $value) {
     
    637791     * @return DataCache
    638792     */
    639     private function get_cache($image_url = '')
     793    private function get_cache(string $image_url = ''): DataCache
    640794    {
    641795        if ($this->cache === null) {
     
    652806        return $this->cache;
    653807    }
     808
     809    /**
     810     * Get a HTTP client
     811     */
     812    private function get_http_client(): Client
     813    {
     814        if ($this->http_client === null) {
     815            $this->http_client = new FileClient(
     816                $this->registry,
     817                [
     818                    'timeout' => $this->timeout,
     819                    'redirects' => 5,
     820                    'useragent' => $this->useragent,
     821                    'force_fsockopen' => $this->force_fsockopen,
     822                    'curl_options' => $this->curl_options,
     823                ]
     824            );
     825        }
     826
     827        return $this->http_client;
     828    }
    654829}
    655830
  • trunk/src/wp-includes/SimplePie/src/SimplePie.php

    r60490 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
    469
    4710use InvalidArgumentException;
     11use Psr\Http\Client\ClientInterface;
     12use Psr\Http\Message\RequestFactoryInterface;
     13use Psr\Http\Message\UriFactoryInterface;
    4814use Psr\SimpleCache\CacheInterface;
    4915use SimplePie\Cache\Base;
     
    5420use SimplePie\Cache\Psr16;
    5521use SimplePie\Content\Type\Sniffer;
     22use SimplePie\Exception as SimplePieException;
     23use SimplePie\HTTP\Client;
     24use SimplePie\HTTP\ClientException;
     25use SimplePie\HTTP\FileClient;
     26use SimplePie\HTTP\Psr18Client;
     27use SimplePie\HTTP\Response;
    5628
    5729/**
    5830 * SimplePie
    59  *
    60  * @package SimplePie
    61  * @subpackage API
    6231 */
    6332class SimplePie
     
    7140     * SimplePie Version
    7241     */
    73     public const VERSION = '1.8.1';
     42    public const VERSION = '1.9.0';
    7443
    7544    /**
     
    412381
    413382    /**
    414      * @var array Raw data
     383     * @internal Default value of the HTTP Accept header when fetching/locating feeds
     384     */
     385    public const DEFAULT_HTTP_ACCEPT_HEADER = 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1';
     386
     387    /**
     388     * @var array<string, mixed> Raw data
    415389     * @access private
    416390     */
     
    418392
    419393    /**
    420      * @var mixed Error string
     394     * @var string|string[]|null Error string (or array when multiple feeds are initialized)
    421395     * @access private
    422396     */
    423     public $error;
     397    public $error = null;
    424398
    425399    /**
     
    431405
    432406    /**
    433      * @var object Instance of \SimplePie\Sanitize (or other class)
     407     * @var Sanitize instance of Sanitize class
    434408     * @see SimplePie::set_sanitize_class()
    435409     * @access private
     
    452426
    453427    /**
    454      * @var string Original feed URL, or new feed URL iff HTTP 301 Moved Permanently
     428     * @var ?string Original feed URL, or new feed URL iff HTTP 301 Moved Permanently
    455429     * @see SimplePie::subscribe_url()
    456430     * @access private
     
    459433
    460434    /**
    461      * @var object Instance of \SimplePie\File to use as a feed
     435     * @var File Instance of File class to use as a feed
    462436     * @see SimplePie::set_file()
    463      * @access private
    464      */
    465     public $file;
    466 
    467     /**
    468      * @var string Raw feed data
     437     */
     438    private $file;
     439
     440    /**
     441     * @var string|false Raw feed data
    469442     * @see SimplePie::set_raw_data()
    470443     * @access private
     
    480453
    481454    /**
    482      * @var array Custom curl options
     455     * @var array<int, mixed> Custom curl options
    483456     * @see SimplePie::set_curl_options()
    484457     * @access private
     
    551524
    552525    /**
    553      * @var string Function that creates the cache filename
     526     * @var string&(callable(string): string) Function that creates the cache filename
    554527     * @see SimplePie::set_cache_name_function()
    555528     * @access private
     
    573546
    574547    /**
    575      * @var int Feed Autodiscovery Level
     548     * @var self::LOCATOR_* Feed Autodiscovery Level
    576549     * @see SimplePie::set_autodiscovery_level()
    577550     * @access private
     
    582555     * Class registry object
    583556     *
    584      * @var \SimplePie\Registry
     557     * @var Registry
    585558     */
    586559    public $registry;
     
    594567
    595568    /**
    596      * @var array All the feeds found during the autodiscovery process
     569     * @var array<Response>|null All the feeds found during the autodiscovery process
    597570     * @see SimplePie::get_all_discovered_feeds()
    598571     * @access private
     
    608581
    609582    /**
    610      * @var array Stores the URLs when multiple feeds are being initialized.
     583     * @var array<string> Stores the URLs when multiple feeds are being initialized.
    611584     * @see SimplePie::set_feed_url()
    612585     * @access private
     
    615588
    616589    /**
    617      * @var array Stores SimplePie objects when multiple feeds initialized.
     590     * @var array<int, static> Stores SimplePie objects when multiple feeds initialized.
    618591     * @access private
    619592     */
     
    621594
    622595    /**
    623      * @var array Stores the get_object_vars() array for use with multifeeds.
     596     * @var array<mixed> Stores the get_object_vars() array for use with multifeeds.
    624597     * @see SimplePie::set_feed_url()
    625598     * @access private
     
    628601
    629602    /**
    630      * @var integer Stores the number of items to return per-feed with multifeeds.
     603     * @var int Stores the number of items to return per-feed with multifeeds.
    631604     * @see SimplePie::set_item_limit()
    632605     * @access private
     
    641614
    642615    /**
    643      * @var array Stores the default attributes to be stripped by strip_attributes().
     616     * @var array<string> Stores the default attributes to be stripped by strip_attributes().
    644617     * @see SimplePie::strip_attributes()
    645618     * @access private
     
    648621
    649622    /**
    650      * @var array Stores the default attributes to add to different tags by add_attributes().
     623     * @var array<string, array<string, string>> Stores the default attributes to add to different tags by add_attributes().
    651624     * @see SimplePie::add_attributes()
    652625     * @access private
     
    655628
    656629    /**
    657      * @var array Stores the default tags to be stripped by strip_htmltags().
     630     * @var array<string> Stores the default tags to be stripped by strip_htmltags().
    658631     * @see SimplePie::strip_htmltags()
    659632     * @access private
     
    662635
    663636    /**
    664      * @var array Stores the default attributes to be renamed by rename_attributes().
     637     * @var string[]|string Stores the default attributes to be renamed by rename_attributes().
    665638     * @see SimplePie::rename_attributes()
    666639     * @access private
     
    673646     */
    674647    public $enable_exceptions = false;
     648
     649    /**
     650     * @var Client|null
     651     */
     652    private $http_client = null;
     653
     654    /** @var bool Whether HTTP client has been injected */
     655    private $http_client_injected = false;
    675656
    676657    /**
     
    699680
    700681        // Other objects, instances created here so we can set options on them
    701         $this->sanitize = new \SimplePie\Sanitize();
    702         $this->registry = new \SimplePie\Registry();
     682        $this->sanitize = new Sanitize();
     683        $this->registry = new Registry();
    703684
    704685        if (func_num_args() > 0) {
     
    722703    /**
    723704     * Used for converting object to a string
     705     * @return string
    724706     */
    725707    public function __toString()
     
    730712    /**
    731713     * Remove items that link back to this before destroying this object
     714     * @return void
    732715     */
    733716    public function __destruct()
     
    757740     * @since 1.1
    758741     * @param bool $enable Force the given data/URL to be treated as a feed
    759      */
    760     public function force_feed($enable = false)
    761     {
    762         $this->force_feed = (bool) $enable;
     742     * @return void
     743     */
     744    public function force_feed(bool $enable = false)
     745    {
     746        $this->force_feed = $enable;
    763747    }
    764748
     
    770754     * over any set raw data.
    771755     *
    772      * You can set multiple feeds to mash together by passing an array instead
     756     * Deprecated since 1.9.0: You can set multiple feeds to mash together by passing an array instead
    773757     * of a string for the $url. Remember that with each additional feed comes
    774758     * additional processing and resources.
     
    776760     * @since 1.0 Preview Release
    777761     * @see set_raw_data()
    778      * @param string|array $url This is the URL (or array of URLs) that you want to parse.
     762     * @param string|string[] $url This is the URL (or (deprecated) array of URLs) that you want to parse.
     763     * @return void
    779764     */
    780765    public function set_feed_url($url)
     
    782767        $this->multifeed_url = [];
    783768        if (is_array($url)) {
     769            trigger_error('Fetching multiple feeds with single SimplePie instance is deprecated since SimplePie 1.9.0, create one SimplePie instance per feed and use SimplePie::merge_items to get a single list of items.', \E_USER_DEPRECATED);
    784770            foreach ($url as $value) {
    785771                $this->multifeed_url[] = $this->registry->call(Misc::class, 'fix_protocol', [$value, 1]);
     
    792778
    793779    /**
    794      * Set an instance of {@see \SimplePie\File} to use as a feed
    795      *
    796      * @param \SimplePie\File &$file
     780     * Set an instance of {@see File} to use as a feed
     781     *
     782     * @deprecated since SimplePie 1.9.0, use \SimplePie\SimplePie::set_http_client() or \SimplePie\SimplePie::set_raw_data() instead.
     783     *
     784     * @param File &$file
    797785     * @return bool True on success, false on failure
    798786     */
    799     public function set_file(&$file)
    800     {
    801         if ($file instanceof \SimplePie\File) {
    802             $this->feed_url = $file->url;
    803             $this->permanent_url = $this->feed_url;
    804             $this->file = &$file;
    805             return true;
    806         }
    807         return false;
     787    public function set_file(File &$file)
     788    {
     789        // trigger_error(sprintf('SimplePie\SimplePie::set_file() is deprecated since SimplePie 1.9.0, please use "SimplePie\SimplePie::set_http_client()" or "SimplePie\SimplePie::set_raw_data()" instead.'), \E_USER_DEPRECATED);
     790
     791        $this->feed_url = $file->get_final_requested_uri();
     792        $this->permanent_url = $this->feed_url;
     793        $this->file = &$file;
     794
     795        return true;
    808796    }
    809797
     
    820808     * @param string $data RSS or Atom data as a string.
    821809     * @see set_feed_url()
    822      */
    823     public function set_raw_data($data)
     810     * @return void
     811     */
     812    public function set_raw_data(string $data)
    824813    {
    825814        $this->raw_data = $data;
     815    }
     816
     817    /**
     818     * Set a PSR-18 client and PSR-17 factories
     819     *
     820     * Allows you to use your own HTTP client implementations.
     821     * This will become required with SimplePie 2.0.0.
     822     */
     823    final public function set_http_client(
     824        ClientInterface $http_client,
     825        RequestFactoryInterface $request_factory,
     826        UriFactoryInterface $uri_factory
     827    ): void {
     828        $this->http_client = new Psr18Client($http_client, $request_factory, $uri_factory);
    826829    }
    827830
     
    834837     * @since 1.0 Beta 3
    835838     * @param int $timeout The maximum number of seconds to spend waiting to retrieve a feed.
    836      */
    837     public function set_timeout($timeout = 10)
    838     {
     839     * @return void
     840     */
     841    public function set_timeout(int $timeout = 10)
     842    {
     843        if ($this->http_client_injected) {
     844            throw new SimplePieException(sprintf(
     845                'Using "%s()" has no effect, because you already provided a HTTP client with "%s::set_http_client()". Configure timeout in your HTTP client instead.',
     846                __METHOD__,
     847                self::class
     848            ));
     849        }
     850
    839851        $this->timeout = (int) $timeout;
     852
     853        // Reset a possible existing FileClient,
     854        // so a new client with the changed value will be created
     855        if (is_object($this->http_client) && $this->http_client instanceof FileClient) {
     856            $this->http_client = null;
     857        } elseif (is_object($this->http_client)) {
     858            // Trigger notice if a PSR-18 client was set
     859            trigger_error(sprintf(
     860                'Using "%s()" has no effect, because you already provided a HTTP client with "%s::set_http_client()". Configure the timeout in your HTTP client instead.',
     861                __METHOD__,
     862                get_class($this)
     863            ), \E_USER_NOTICE);
     864        }
    840865    }
    841866
     
    846871     *
    847872     * @since 1.0 Beta 3
    848      * @param array $curl_options Curl options to add to default settings
     873     * @param array<int, mixed> $curl_options Curl options to add to default settings
     874     * @return void
    849875     */
    850876    public function set_curl_options(array $curl_options = [])
    851877    {
     878        if ($this->http_client_injected) {
     879            throw new SimplePieException(sprintf(
     880                'Using "%s()" has no effect, because you already provided a HTTP client with "%s::set_http_client()". Configure custom curl options in your HTTP client instead.',
     881                __METHOD__,
     882                self::class
     883            ));
     884        }
     885
    852886        $this->curl_options = $curl_options;
     887
     888        // Reset a possible existing FileClient,
     889        // so a new client with the changed value will be created
     890        if (is_object($this->http_client) && $this->http_client instanceof FileClient) {
     891            $this->http_client = null;
     892        } elseif (is_object($this->http_client)) {
     893            // Trigger notice if a PSR-18 client was set
     894            trigger_error(sprintf(
     895                'Using "%s()" has no effect, because you already provided a HTTP client with "%s::set_http_client()". Configure the curl options in your HTTP client instead.',
     896                __METHOD__,
     897                get_class($this)
     898            ), \E_USER_NOTICE);
     899        }
    853900    }
    854901
     
    858905     * @since 1.0 Beta 3
    859906     * @param bool $enable Force fsockopen() to be used
    860      */
    861     public function force_fsockopen($enable = false)
    862     {
    863         $this->force_fsockopen = (bool) $enable;
     907     * @return void
     908     */
     909    public function force_fsockopen(bool $enable = false)
     910    {
     911        if ($this->http_client_injected) {
     912            throw new SimplePieException(sprintf(
     913                'Using "%s()" has no effect, because you already provided a HTTP client with "%s::set_http_client()". Configure fsockopen in your HTTP client instead.',
     914                __METHOD__,
     915                self::class
     916            ));
     917        }
     918
     919        $this->force_fsockopen = $enable;
     920
     921        // Reset a possible existing FileClient,
     922        // so a new client with the changed value will be created
     923        if (is_object($this->http_client) && $this->http_client instanceof FileClient) {
     924            $this->http_client = null;
     925        } elseif (is_object($this->http_client)) {
     926            // Trigger notice if a PSR-18 client was set
     927            trigger_error(sprintf(
     928                'Using "%s()" has no effect, because you already provided a HTTP client with "%s::set_http_client()". Configure fsockopen in your HTTP client instead.',
     929                __METHOD__,
     930                get_class($this)
     931            ), \E_USER_NOTICE);
     932        }
    864933    }
    865934
     
    872941     * @since 1.0 Preview Release
    873942     * @param bool $enable Enable caching
    874      */
    875     public function enable_cache($enable = true)
    876     {
    877         $this->enable_cache = (bool) $enable;
     943     * @return void
     944     */
     945    public function enable_cache(bool $enable = true)
     946    {
     947        $this->enable_cache = $enable;
    878948    }
    879949
     
    881951     * Set a PSR-16 implementation as cache
    882952     *
    883      * @param CacheInterface $psr16cache The PSR-16 cache implementation
     953     * @param CacheInterface $cache The PSR-16 cache implementation
    884954     *
    885955     * @return void
     
    901971     *
    902972     * @param bool $enable Force use of cache on fail.
    903      */
    904     public function force_cache_fallback($enable = false)
     973     * @return void
     974     */
     975    public function force_cache_fallback(bool $enable = false)
    905976    {
    906977        // @trigger_error(sprintf('SimplePie\SimplePie::force_cache_fallback() is deprecated since SimplePie 1.8.0, expired cache will not be used anymore.'), \E_USER_DEPRECATED);
    907         $this->force_cache_fallback = (bool) $enable;
     978        $this->force_cache_fallback = $enable;
    908979    }
    909980
     
    913984     *
    914985     * @param int $seconds The feed content cache duration
    915      */
    916     public function set_cache_duration($seconds = 3600)
    917     {
    918         $this->cache_duration = (int) $seconds;
     986     * @return void
     987     */
     988    public function set_cache_duration(int $seconds = 3600)
     989    {
     990        $this->cache_duration = $seconds;
    919991    }
    920992
     
    924996     *
    925997     * @param int $seconds The autodiscovered feed URL cache duration.
    926      */
    927     public function set_autodiscovery_cache_duration($seconds = 604800)
    928     {
    929         $this->autodiscovery_cache_duration = (int) $seconds;
     998     * @return void
     999     */
     1000    public function set_autodiscovery_cache_duration(int $seconds = 604800)
     1001    {
     1002        $this->autodiscovery_cache_duration = $seconds;
    9301003    }
    9311004
     
    9331006     * Set the file system location where the cached files should be stored
    9341007     *
    935      * @deprecated since SimplePie 1.8.0, use \SimplePie\SimplePie::set_cache() instead.
     1008     * @deprecated since SimplePie 1.8.0, use SimplePie::set_cache() instead.
    9361009     *
    9371010     * @param string $location The file system location.
    938      */
    939     public function set_cache_location($location = './cache')
     1011     * @return void
     1012     */
     1013    public function set_cache_location(string $location = './cache')
    9401014    {
    9411015        // @trigger_error(sprintf('SimplePie\SimplePie::set_cache_location() is deprecated since SimplePie 1.8.0, please use "SimplePie\SimplePie::set_cache()" instead.'), \E_USER_DEPRECATED);
    942         $this->cache_location = (string) $location;
     1016        $this->cache_location = $location;
    9431017    }
    9441018
     
    9491023     * @return string A filename (i.e. hash, without path and without extension).
    9501024     */
    951     public function get_cache_filename($url)
     1025    public function get_cache_filename(string $url)
    9521026    {
    9531027        // Append custom parameters to the URL to avoid cache pollution in case of multiple calls with different parameters.
     
    9571031            $options[CURLOPT_TIMEOUT] = $this->timeout;
    9581032        }
    959         if ($this->useragent !== \SimplePie\Misc::get_default_useragent()) {
     1033        if ($this->useragent !== Misc::get_default_useragent()) {
    9601034            $options[CURLOPT_USERAGENT] = $this->useragent;
    9611035        }
     
    9771051     *
    9781052     * @param bool $enable Sort as reverse chronological order.
    979      */
    980     public function enable_order_by_date($enable = true)
    981     {
    982         $this->order_by_date = (bool) $enable;
     1053     * @return void
     1054     */
     1055    public function enable_order_by_date(bool $enable = true)
     1056    {
     1057        $this->order_by_date = $enable;
    9831058    }
    9841059
     
    9891064     * back to the normal encoding detection if the override fails
    9901065     *
    991      * @param string $encoding Character encoding
     1066     * @param string|false $encoding Character encoding
     1067     * @return void
    9921068     */
    9931069    public function set_input_encoding($encoding = false)
     
    10031079     * Set how much feed autodiscovery to do
    10041080     *
    1005      * @see \SimplePie\SimplePie::LOCATOR_NONE
    1006      * @see \SimplePie\SimplePie::LOCATOR_AUTODISCOVERY
    1007      * @see \SimplePie\SimplePie::LOCATOR_LOCAL_EXTENSION
    1008      * @see \SimplePie\SimplePie::LOCATOR_LOCAL_BODY
    1009      * @see \SimplePie\SimplePie::LOCATOR_REMOTE_EXTENSION
    1010      * @see \SimplePie\SimplePie::LOCATOR_REMOTE_BODY
    1011      * @see \SimplePie\SimplePie::LOCATOR_ALL
    1012      * @param int $level Feed Autodiscovery Level (level can be a combination of the above constants, see bitwise OR operator)
    1013      */
    1014     public function set_autodiscovery_level($level = self::LOCATOR_ALL)
    1015     {
    1016         $this->autodiscovery = (int) $level;
     1081     * @see self::LOCATOR_NONE
     1082     * @see self::LOCATOR_AUTODISCOVERY
     1083     * @see self::LOCATOR_LOCAL_EXTENSION
     1084     * @see self::LOCATOR_LOCAL_BODY
     1085     * @see self::LOCATOR_REMOTE_EXTENSION
     1086     * @see self::LOCATOR_REMOTE_BODY
     1087     * @see self::LOCATOR_ALL
     1088     * @param self::LOCATOR_* $level Feed Autodiscovery Level (level can be a combination of the above constants, see bitwise OR operator)
     1089     * @return void
     1090     */
     1091    public function set_autodiscovery_level(int $level = self::LOCATOR_ALL)
     1092    {
     1093        $this->autodiscovery = $level;
    10171094    }
    10181095
     
    10211098     *
    10221099     * Use this to override SimplePie's default classes
    1023      * @see \SimplePie\Registry
    10241100     *
    10251101     * @return Registry
     
    10351111     * @deprecated since SimplePie 1.3, use {@see set_cache()} instead
    10361112     *
    1037      * @param string $class Name of custom class
    1038      *
    1039      * @return boolean True on success, false otherwise
    1040      */
    1041     public function set_cache_class($class = Cache::class)
    1042     {
    1043         // trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::set_cache()" instead.', __METHOD__), \E_USER_DEPRECATED);
     1113     * @param class-string<Cache> $class Name of custom class
     1114     *
     1115     * @return bool True on success, false otherwise
     1116     */
     1117    public function set_cache_class(string $class = Cache::class)
     1118    {
     1119        trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::set_cache()" instead.', __METHOD__), \E_USER_DEPRECATED);
    10441120
    10451121        return $this->registry->register(Cache::class, $class, true);
     
    10511127     * @deprecated since SimplePie 1.3, use {@see get_registry()} instead
    10521128     *
    1053      * @param string $class Name of custom class
    1054      *
    1055      * @return boolean True on success, false otherwise
    1056      */
    1057     public function set_locator_class($class = Locator::class)
    1058     {
    1059         // trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
     1129     * @param class-string<Locator> $class Name of custom class
     1130     *
     1131     * @return bool True on success, false otherwise
     1132     */
     1133    public function set_locator_class(string $class = Locator::class)
     1134    {
     1135        trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
    10601136
    10611137        return $this->registry->register(Locator::class, $class, true);
     
    10671143     * @deprecated since SimplePie 1.3, use {@see get_registry()} instead
    10681144     *
    1069      * @param string $class Name of custom class
    1070      *
    1071      * @return boolean True on success, false otherwise
    1072      */
    1073     public function set_parser_class($class = Parser::class)
    1074     {
    1075         // trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
     1145     * @param class-string<Parser> $class Name of custom class
     1146     *
     1147     * @return bool True on success, false otherwise
     1148     */
     1149    public function set_parser_class(string $class = Parser::class)
     1150    {
     1151        trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
    10761152
    10771153        return $this->registry->register(Parser::class, $class, true);
     
    10831159     * @deprecated since SimplePie 1.3, use {@see get_registry()} instead
    10841160     *
    1085      * @param string $class Name of custom class
    1086      *
    1087      * @return boolean True on success, false otherwise
    1088      */
    1089     public function set_file_class($class = File::class)
    1090     {
    1091         // trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
     1161     * @param class-string<File> $class Name of custom class
     1162     *
     1163     * @return bool True on success, false otherwise
     1164     */
     1165    public function set_file_class(string $class = File::class)
     1166    {
     1167        trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
    10921168
    10931169        return $this->registry->register(File::class, $class, true);
     
    10991175     * @deprecated since SimplePie 1.3, use {@see get_registry()} instead
    11001176     *
    1101      * @param string $class Name of custom class
    1102      *
    1103      * @return boolean True on success, false otherwise
    1104      */
    1105     public function set_sanitize_class($class = Sanitize::class)
    1106     {
    1107         // trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
     1177     * @param class-string<Sanitize> $class Name of custom class
     1178     *
     1179     * @return bool True on success, false otherwise
     1180     */
     1181    public function set_sanitize_class(string $class = Sanitize::class)
     1182    {
     1183        trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
    11081184
    11091185        return $this->registry->register(Sanitize::class, $class, true);
     
    11151191     * @deprecated since SimplePie 1.3, use {@see get_registry()} instead
    11161192     *
    1117      * @param string $class Name of custom class
    1118      *
    1119      * @return boolean True on success, false otherwise
    1120      */
    1121     public function set_item_class($class = Item::class)
    1122     {
    1123         // trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
     1193     * @param class-string<Item> $class Name of custom class
     1194     *
     1195     * @return bool True on success, false otherwise
     1196     */
     1197    public function set_item_class(string $class = Item::class)
     1198    {
     1199        trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
    11241200
    11251201        return $this->registry->register(Item::class, $class, true);
     
    11311207     * @deprecated since SimplePie 1.3, use {@see get_registry()} instead
    11321208     *
    1133      * @param string $class Name of custom class
    1134      *
    1135      * @return boolean True on success, false otherwise
    1136      */
    1137     public function set_author_class($class = Author::class)
    1138     {
    1139         // trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
     1209     * @param class-string<Author> $class Name of custom class
     1210     *
     1211     * @return bool True on success, false otherwise
     1212     */
     1213    public function set_author_class(string $class = Author::class)
     1214    {
     1215        trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
    11401216
    11411217        return $this->registry->register(Author::class, $class, true);
     
    11471223     * @deprecated since SimplePie 1.3, use {@see get_registry()} instead
    11481224     *
    1149      * @param string $class Name of custom class
    1150      *
    1151      * @return boolean True on success, false otherwise
    1152      */
    1153     public function set_category_class($class = Category::class)
    1154     {
    1155         // trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
     1225     * @param class-string<Category> $class Name of custom class
     1226     *
     1227     * @return bool True on success, false otherwise
     1228     */
     1229    public function set_category_class(string $class = Category::class)
     1230    {
     1231        trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
    11561232
    11571233        return $this->registry->register(Category::class, $class, true);
     
    11631239     * @deprecated since SimplePie 1.3, use {@see get_registry()} instead
    11641240     *
    1165      * @param string $class Name of custom class
    1166      *
    1167      * @return boolean True on success, false otherwise
    1168      */
    1169     public function set_enclosure_class($class = Enclosure::class)
    1170     {
    1171         // trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
     1241     * @param class-string<Enclosure> $class Name of custom class
     1242     *
     1243     * @return bool True on success, false otherwise
     1244     */
     1245    public function set_enclosure_class(string $class = Enclosure::class)
     1246    {
     1247        trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
    11721248
    11731249        return $this->registry->register(Enclosure::class, $class, true);
     
    11791255     * @deprecated since SimplePie 1.3, use {@see get_registry()} instead
    11801256     *
    1181      * @param string $class Name of custom class
    1182      *
    1183      * @return boolean True on success, false otherwise
    1184      */
    1185     public function set_caption_class($class = Caption::class)
    1186     {
    1187         // trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
     1257     * @param class-string<Caption> $class Name of custom class
     1258     *
     1259     * @return bool True on success, false otherwise
     1260     */
     1261    public function set_caption_class(string $class = Caption::class)
     1262    {
     1263        trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
    11881264
    11891265        return $this->registry->register(Caption::class, $class, true);
     
    11951271     * @deprecated since SimplePie 1.3, use {@see get_registry()} instead
    11961272     *
    1197      * @param string $class Name of custom class
    1198      *
    1199      * @return boolean True on success, false otherwise
    1200      */
    1201     public function set_copyright_class($class = Copyright::class)
    1202     {
    1203         // trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
     1273     * @param class-string<Copyright> $class Name of custom class
     1274     *
     1275     * @return bool True on success, false otherwise
     1276     */
     1277    public function set_copyright_class(string $class = Copyright::class)
     1278    {
     1279        trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
    12041280
    12051281        return $this->registry->register(Copyright::class, $class, true);
     
    12111287     * @deprecated since SimplePie 1.3, use {@see get_registry()} instead
    12121288     *
    1213      * @param string $class Name of custom class
    1214      *
    1215      * @return boolean True on success, false otherwise
    1216      */
    1217     public function set_credit_class($class = Credit::class)
    1218     {
    1219         // trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
     1289     * @param class-string<Credit> $class Name of custom class
     1290     *
     1291     * @return bool True on success, false otherwise
     1292     */
     1293    public function set_credit_class(string $class = Credit::class)
     1294    {
     1295        trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
    12201296
    12211297        return $this->registry->register(Credit::class, $class, true);
     
    12271303     * @deprecated since SimplePie 1.3, use {@see get_registry()} instead
    12281304     *
    1229      * @param string $class Name of custom class
    1230      *
    1231      * @return boolean True on success, false otherwise
    1232      */
    1233     public function set_rating_class($class = Rating::class)
    1234     {
    1235         // trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
     1305     * @param class-string<Rating> $class Name of custom class
     1306     *
     1307     * @return bool True on success, false otherwise
     1308     */
     1309    public function set_rating_class(string $class = Rating::class)
     1310    {
     1311        trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
    12361312
    12371313        return $this->registry->register(Rating::class, $class, true);
     
    12431319     * @deprecated since SimplePie 1.3, use {@see get_registry()} instead
    12441320     *
    1245      * @param string $class Name of custom class
    1246      *
    1247      * @return boolean True on success, false otherwise
    1248      */
    1249     public function set_restriction_class($class = Restriction::class)
    1250     {
    1251         // trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
     1321     * @param class-string<Restriction> $class Name of custom class
     1322     *
     1323     * @return bool True on success, false otherwise
     1324     */
     1325    public function set_restriction_class(string $class = Restriction::class)
     1326    {
     1327        trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
    12521328
    12531329        return $this->registry->register(Restriction::class, $class, true);
     
    12591335     * @deprecated since SimplePie 1.3, use {@see get_registry()} instead
    12601336     *
    1261      * @param string $class Name of custom class
    1262      *
    1263      * @return boolean True on success, false otherwise
    1264      */
    1265     public function set_content_type_sniffer_class($class = Sniffer::class)
    1266     {
    1267         // trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
     1337     * @param class-string<Sniffer> $class Name of custom class
     1338     *
     1339     * @return bool True on success, false otherwise
     1340     */
     1341    public function set_content_type_sniffer_class(string $class = Sniffer::class)
     1342    {
     1343        trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
    12681344
    12691345        return $this->registry->register(Sniffer::class, $class, true);
     
    12751351     * @deprecated since SimplePie 1.3, use {@see get_registry()} instead
    12761352     *
    1277      * @param string $class Name of custom class
    1278      *
    1279      * @return boolean True on success, false otherwise
    1280      */
    1281     public function set_source_class($class = Source::class)
    1282     {
    1283         // trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
     1353     * @param class-string<Source> $class Name of custom class
     1354     *
     1355     * @return bool True on success, false otherwise
     1356     */
     1357    public function set_source_class(string $class = Source::class)
     1358    {
     1359        trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
    12841360
    12851361        return $this->registry->register(Source::class, $class, true);
     
    12901366     *
    12911367     * @param string $ua New user agent string.
    1292      */
    1293     public function set_useragent($ua = null)
    1294     {
     1368     * @return void
     1369     */
     1370    public function set_useragent(?string $ua = null)
     1371    {
     1372        if ($this->http_client_injected) {
     1373            throw new SimplePieException(sprintf(
     1374                'Using "%s()" has no effect, because you already provided a HTTP client with "%s::set_http_client()". Configure user agent string in your HTTP client instead.',
     1375                __METHOD__,
     1376                self::class
     1377            ));
     1378        }
     1379
    12951380        if ($ua === null) {
    1296             $ua = \SimplePie\Misc::get_default_useragent();
     1381            $ua = Misc::get_default_useragent();
    12971382        }
    12981383
    12991384        $this->useragent = (string) $ua;
     1385
     1386        // Reset a possible existing FileClient,
     1387        // so a new client with the changed value will be created
     1388        if (is_object($this->http_client) && $this->http_client instanceof FileClient) {
     1389            $this->http_client = null;
     1390        } elseif (is_object($this->http_client)) {
     1391            // Trigger notice if a PSR-18 client was set
     1392            trigger_error(sprintf(
     1393                'Using "%s()" has no effect, because you already provided a HTTP client with "%s::set_http_client()". Configure the useragent in your HTTP client instead.',
     1394                __METHOD__,
     1395                get_class($this)
     1396            ), \E_USER_NOTICE);
     1397        }
    13001398    }
    13011399
     
    13171415     * @deprecated since SimplePie 1.8.0, use {@see set_cache_namefilter()} instead
    13181416     *
    1319      * @param mixed $function Callback function
    1320      */
    1321     public function set_cache_name_function($function = 'md5')
     1417     * @param (string&(callable(string): string))|null $function Callback function
     1418     * @return void
     1419     */
     1420    public function set_cache_name_function(?string $function = null)
    13221421    {
    13231422        // trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.8.0, please use "SimplePie\SimplePie::set_cache_namefilter()" instead.', __METHOD__), \E_USER_DEPRECATED);
    13241423
    1325         if (is_callable($function)) {
    1326             $this->cache_name_function = $function;
    1327 
    1328             $this->set_cache_namefilter(new CallableNameFilter($this->cache_name_function));
    1329         }
     1424        if ($function === null) {
     1425            $function = 'md5';
     1426        }
     1427
     1428        $this->cache_name_function = $function;
     1429
     1430        $this->set_cache_namefilter(new CallableNameFilter($this->cache_name_function));
    13301431    }
    13311432
     
    13371438     *
    13381439     * @param bool $set Whether to set them or not
    1339      */
    1340     public function set_stupidly_fast($set = false)
     1440     * @return void
     1441     */
     1442    public function set_stupidly_fast(bool $set = false)
    13411443    {
    13421444        if ($set) {
     
    13441446            $this->remove_div(false);
    13451447            $this->strip_comments(false);
    1346             $this->strip_htmltags(false);
    1347             $this->strip_attributes(false);
    1348             $this->add_attributes(false);
     1448            $this->strip_htmltags([]);
     1449            $this->strip_attributes([]);
     1450            $this->add_attributes([]);
    13491451            $this->set_image_handler(false);
    13501452            $this->set_https_domains([]);
     
    13561458     *
    13571459     * @param int $max Maximum number of feeds to check
    1358      */
    1359     public function set_max_checked_feeds($max = 10)
    1360     {
    1361         $this->max_checked_feeds = (int) $max;
    1362     }
    1363 
    1364     public function remove_div($enable = true)
     1460     * @return void
     1461     */
     1462    public function set_max_checked_feeds(int $max = 10)
     1463    {
     1464        $this->max_checked_feeds = $max;
     1465    }
     1466
     1467    /**
     1468     * @return void
     1469     */
     1470    public function remove_div(bool $enable = true)
    13651471    {
    13661472        $this->sanitize->remove_div($enable);
    13671473    }
    13681474
    1369     public function strip_htmltags($tags = '', $encode = null)
     1475    /**
     1476     * @param string[]|string|false $tags Set a list of tags to strip, or set empty string to use default tags, or false to strip nothing.
     1477     * @return void
     1478     */
     1479    public function strip_htmltags($tags = '', ?bool $encode = null)
    13701480    {
    13711481        if ($tags === '') {
     
    13781488    }
    13791489
    1380     public function encode_instead_of_strip($enable = true)
     1490    /**
     1491     * @return void
     1492     */
     1493    public function encode_instead_of_strip(bool $enable = true)
    13811494    {
    13821495        $this->sanitize->encode_instead_of_strip($enable);
    13831496    }
    13841497
     1498    /**
     1499     * @param string[]|string $attribs
     1500     * @return void
     1501     */
    13851502    public function rename_attributes($attribs = '')
    13861503    {
     
    13911508    }
    13921509
     1510    /**
     1511     * @param string[]|string $attribs
     1512     * @return void
     1513     */
    13931514    public function strip_attributes($attribs = '')
    13941515    {
     
    13991520    }
    14001521
     1522    /**
     1523     * @param array<string, array<string, string>>|'' $attribs
     1524     * @return void
     1525     */
    14011526    public function add_attributes($attribs = '')
    14021527    {
     
    14281553     *
    14291554     * @param string $encoding
    1430      */
    1431     public function set_output_encoding($encoding = 'UTF-8')
     1555     * @return void
     1556     */
     1557    public function set_output_encoding(string $encoding = 'UTF-8')
    14321558    {
    14331559        $this->sanitize->set_output_encoding($encoding);
    14341560    }
    14351561
    1436     public function strip_comments($strip = false)
     1562    /**
     1563     * @return void
     1564     */
     1565    public function strip_comments(bool $strip = false)
    14371566    {
    14381567        $this->sanitize->strip_comments($strip);
     
    14481577     *
    14491578     * @since 1.0
    1450      * @param array|null $element_attribute Element/attribute key/value pairs, null for default
    1451      */
    1452     public function set_url_replacements($element_attribute = null)
     1579     * @param array<string, string|string[]>|null $element_attribute Element/attribute key/value pairs, null for default
     1580     * @return void
     1581     */
     1582    public function set_url_replacements(?array $element_attribute = null)
    14531583    {
    14541584        $this->sanitize->set_url_replacements($element_attribute);
     
    14571587    /**
    14581588     * Set the list of domains for which to force HTTPS.
    1459      * @see \SimplePie\Sanitize::set_https_domains()
    1460      * @param array List of HTTPS domains. Example array('biz', 'example.com', 'example.org', 'www.example.net').
    1461      */
    1462     public function set_https_domains($domains = [])
    1463     {
    1464         if (is_array($domains)) {
    1465             $this->sanitize->set_https_domains($domains);
    1466         }
     1589     * @see Sanitize::set_https_domains()
     1590     * @param array<string> $domains List of HTTPS domains. Example array('biz', 'example.com', 'example.org', 'www.example.net').
     1591     * @return void
     1592     */
     1593    public function set_https_domains(array $domains = [])
     1594    {
     1595        $this->sanitize->set_https_domains($domains);
    14671596    }
    14681597
     
    14701599     * Set the handler to enable the display of cached images.
    14711600     *
    1472      * @param string $page Web-accessible path to the handler_image.php file.
     1601     * @param string|false $page Web-accessible path to the handler_image.php file.
    14731602     * @param string $qs The query string that the value should be passed to.
    1474      */
    1475     public function set_image_handler($page = false, $qs = 'i')
     1603     * @return void
     1604     */
     1605    public function set_image_handler($page = false, string $qs = 'i')
    14761606    {
    14771607        if ($page !== false) {
     
    14851615     * Set the limit for items returned per-feed with multifeeds
    14861616     *
    1487      * @param integer $limit The maximum number of items to return.
    1488      */
    1489     public function set_item_limit($limit = 0)
    1490     {
    1491         $this->item_limit = (int) $limit;
     1617     * @param int $limit The maximum number of items to return.
     1618     * @return void
     1619     */
     1620    public function set_item_limit(int $limit = 0)
     1621    {
     1622        $this->item_limit = $limit;
    14921623    }
    14931624
     
    14951626     * Enable throwing exceptions
    14961627     *
    1497      * @param boolean $enable Should we throw exceptions, or use the old-style error property?
    1498      */
    1499     public function enable_exceptions($enable = true)
     1628     * @param bool $enable Should we throw exceptions, or use the old-style error property?
     1629     * @return void
     1630     */
     1631    public function enable_exceptions(bool $enable = true)
    15001632    {
    15011633        $this->enable_exceptions = $enable;
     
    15091641     * parsed, and all of that other good stuff.
    15101642     *
    1511      * @return boolean True if successful, false otherwise
     1643     * @return bool True if successful, false otherwise
    15121644     */
    15131645    public function init()
     
    15241656                $parser_check = xml_parser_create();
    15251657                xml_parse_into_struct($parser_check, '<foo>&amp;</foo>', $values);
    1526                 xml_parser_free($parser_check);
     1658                if (\PHP_VERSION_ID < 80000) {
     1659                    xml_parser_free($parser_check);
     1660                }
    15271661                $xml_is_sane = isset($values[0]['value']);
    15281662            }
     
    15341668        // The default sanitize class gets set in the constructor, check if it has
    15351669        // changed.
    1536         if ($this->registry->get_class(Sanitize::class) !== 'SimplePie\Sanitize') {
     1670        if ($this->registry->get_class(Sanitize::class) !== Sanitize::class) {
    15371671            $this->sanitize = $this->registry->create(Sanitize::class);
    15381672        }
     
    15431677        // Pass whatever was set with config options over to the sanitizer.
    15441678        // Pass the classes in for legacy support; new classes should use the registry instead
     1679        $cache = $this->registry->get_class(Cache::class);
     1680        \assert($cache !== null, 'Cache must be defined');
    15451681        $this->sanitize->pass_cache_data(
    15461682            $this->enable_cache,
    15471683            $this->cache_location,
    15481684            $this->cache_namefilter,
    1549             $this->registry->get_class(Cache::class),
     1685            $cache,
    15501686            $this->cache
    15511687        );
    1552         $this->sanitize->pass_file_data($this->registry->get_class(File::class), $this->timeout, $this->useragent, $this->force_fsockopen, $this->curl_options);
     1688
     1689        $http_client = $this->get_http_client();
     1690
     1691        if ($http_client instanceof Psr18Client) {
     1692            $this->sanitize->set_http_client(
     1693                $http_client->getHttpClient(),
     1694                $http_client->getRequestFactory(),
     1695                $http_client->getUriFactory()
     1696            );
     1697        }
    15531698
    15541699        if (!empty($this->multifeed_url)) {
     
    15861731            }
    15871732
    1588             // Fetch the data via \SimplePie\File into $this->raw_data
     1733            // Fetch the data into $this->raw_data
    15891734            if (($fetched = $this->fetch_data($cache)) === true) {
    15901735                return true;
     
    16501795
    16511796                // If it's parsed fine
    1652                 if ($parser->parse($utf8_data, 'UTF-8', $this->permanent_url)) {
     1797                if ($parser->parse($utf8_data, 'UTF-8', $this->permanent_url ?? '')) {
    16531798                    $this->data = $parser->get_data();
    16541799                    if (!($this->get_type() & ~self::TYPE_NONE)) {
     
    16611806                        $this->data['headers'] = $headers;
    16621807                    }
    1663                     $this->data['build'] = \SimplePie\Misc::get_build();
     1808                    $this->data['build'] = Misc::get_build();
    16641809
    16651810                    // Cache the file if caching is enabled
    16661811                    $this->data['cache_expiration_time'] = $this->cache_duration + time();
     1812
    16671813                    if ($cache && !$cache->set_data($this->get_cache_filename($this->feed_url), $this->data, $this->cache_duration)) {
    16681814                        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);
     
    16741820
    16751821        if (isset($parser)) {
    1676             // We have an error, just set \SimplePie\Misc::error to it and quit
     1822            // We have an error, just set Misc::error to it and quit
    16771823            $this->error = $this->feed_url;
    16781824            $this->error .= sprintf(' is invalid XML, likely due to invalid characters. XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
     
    17021848
    17031849    /**
    1704      * Fetch the data via \SimplePie\File
     1850     * Fetch the data
    17051851     *
    17061852     * If the data is already cached, attempt to fetch it from there instead
     1853     *
    17071854     * @param Base|DataCache|false $cache Cache handler, or false to not load from the cache
    1708      * @return array|true Returns true if the data was loaded from the cache, or an array of HTTP headers and sniffed type
     1855     * @return array{array<string, string>, string}|bool Returns true if the data was loaded from the cache, or an array of HTTP headers and sniffed type
    17091856     */
    17101857    protected function fetch_data(&$cache)
    17111858    {
    1712         if (is_object($cache) && $cache instanceof Base) {
     1859        if ($cache instanceof Base) {
    17131860            // @trigger_error(sprintf('Providing $cache as "\SimplePie\Cache\Base" in %s() is deprecated since SimplePie 1.8.0, please provide "\SimplePie\Cache\DataCache" implementation instead.', __METHOD__), \E_USER_DEPRECATED);
    17141861            $cache = new BaseDataCache($cache);
    17151862        }
    17161863
     1864        // @phpstan-ignore-next-line Enforce PHPDoc type.
    17171865        if ($cache !== false && !$cache instanceof DataCache) {
    17181866            throw new InvalidArgumentException(sprintf(
     
    17321880            if (!empty($this->data)) {
    17331881                // If the cache is for an outdated build of SimplePie
    1734                 if (!isset($this->data['build']) || $this->data['build'] !== \SimplePie\Misc::get_build()) {
     1882                if (!isset($this->data['build']) || $this->data['build'] !== Misc::get_build()) {
    17351883                    $cache->delete_data($cacheKey);
    17361884                    $this->data = [];
     
    17641912                    if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag'])) {
    17651913                        $headers = [
    1766                             'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
     1914                            'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER,
    17671915                        ];
    17681916                        if (isset($this->data['headers']['last-modified'])) {
     
    17731921                        }
    17741922
    1775                         $file = $this->registry->create(File::class, [$this->feed_url, $this->timeout / 10, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options]);
    1776                         $this->status_code = $file->status_code;
    1777 
    1778                         if ($file->success) {
    1779                             if ($file->status_code === 304) {
    1780                                 // Set raw_data to false here too, to signify that the cache
    1781                                 // is still valid.
    1782                                 $this->raw_data = false;
     1923                        try {
     1924                            $file = $this->get_http_client()->request(Client::METHOD_GET, $this->feed_url, $headers);
     1925                            $this->status_code = $file->get_status_code();
     1926                        } catch (ClientException $th) {
     1927                            $this->check_modified = false;
     1928                            $this->status_code = 0;
     1929
     1930                            if ($this->force_cache_fallback) {
     1931                                $this->data['cache_expiration_time'] = $this->cache_duration + time();
    17831932                                $cache->set_data($cacheKey, $this->data, $this->cache_duration);
     1933
    17841934                                return true;
    17851935                            }
    1786                         } else {
    1787                             $this->check_modified = false;
    1788                             if ($this->force_cache_fallback) {
    1789                                 $cache->set_data($cacheKey, $this->data, $this->cache_duration);
    1790                                 return true;
    1791                             }
    1792 
    1793                             unset($file);
     1936
     1937                            $failedFileReason = $th->getMessage();
     1938                        }
     1939
     1940                        if ($this->status_code === 304) {
     1941                            // Set raw_data to false here too, to signify that the cache
     1942                            // is still valid.
     1943                            $this->raw_data = false;
     1944                            $this->data['cache_expiration_time'] = $this->cache_duration + time();
     1945                            $cache->set_data($cacheKey, $this->data, $this->cache_duration);
     1946
     1947                            return true;
    17941948                        }
    17951949                    }
     
    18091963        // If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it.
    18101964        if (!isset($file)) {
    1811             if ($this->file instanceof \SimplePie\File && $this->file->url === $this->feed_url) {
     1965            if ($this->file instanceof File && $this->file->get_final_requested_uri() === $this->feed_url) {
    18121966                $file = &$this->file;
     1967            } elseif (isset($failedFileReason)) {
     1968                // Do not try to fetch again if we already failed once.
     1969                // If the file connection had an error, set SimplePie::error to that and quit
     1970                $this->error = $failedFileReason;
     1971
     1972                return !empty($this->data);
    18131973            } else {
    18141974                $headers = [
    1815                     'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
     1975                    'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER,
    18161976                ];
    1817                 $file = $this->registry->create(File::class, [$this->feed_url, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options]);
    1818             }
    1819         }
    1820         $this->status_code = $file->status_code;
     1977                try {
     1978                    $file = $this->get_http_client()->request(Client::METHOD_GET, $this->feed_url, $headers);
     1979                } catch (ClientException $th) {
     1980                    // If the file connection has an error, set SimplePie::error to that and quit
     1981                    $this->error = $th->getMessage();
     1982
     1983                    return !empty($this->data);
     1984                }
     1985            }
     1986        }
     1987        $this->status_code = $file->get_status_code();
    18211988
    18221989        // If the file connection has an error, set SimplePie::error to that and quit
    1823         if (!$file->success && !($file->method & self::FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) {
    1824             $this->error = $file->error;
     1990        if (!(!Misc::is_remote_uri($file->get_final_requested_uri()) || ($file->get_status_code() === 200 || $file->get_status_code() > 206 && $file->get_status_code() < 300))) {
     1991            $this->error = 'Retrieved unsupported status code "' . $this->status_code . '"';
    18251992            return !empty($this->data);
    18261993        }
     
    18281995        if (!$this->force_feed) {
    18291996            // Check if the supplied URL is a feed, if it isn't, look for it.
    1830             $locate = $this->registry->create(Locator::class, [&$file, $this->timeout, $this->useragent, $this->max_checked_feeds, $this->force_fsockopen, $this->curl_options]);
     1997            $locate = $this->registry->create(Locator::class, [
     1998                (!$file instanceof File) ? File::fromResponse($file) : $file,
     1999                $this->timeout,
     2000                $this->useragent,
     2001                $this->max_checked_feeds,
     2002                $this->force_fsockopen,
     2003                $this->curl_options
     2004            ]);
     2005
     2006            $http_client = $this->get_http_client();
     2007
     2008            if ($http_client instanceof Psr18Client) {
     2009                $locate->set_http_client(
     2010                    $http_client->getHttpClient(),
     2011                    $http_client->getRequestFactory(),
     2012                    $http_client->getUriFactory()
     2013                );
     2014            }
    18312015
    18322016            if (!$locate->is_feed($file)) {
    1833                 $copyStatusCode = $file->status_code;
    1834                 $copyContentType = $file->headers['content-type'] ?? '';
     2017                $copyStatusCode = $file->get_status_code();
     2018                $copyContentType = $file->get_header_line('content-type');
    18352019                try {
    18362020                    $microformats = false;
    18372021                    if (class_exists('DOMXpath') && function_exists('Mf2\parse')) {
    18382022                        $doc = new \DOMDocument();
    1839                         @$doc->loadHTML($file->body);
     2023                        @$doc->loadHTML($file->get_body_content());
    18402024                        $xpath = new \DOMXpath($doc);
    18412025                        // Check for both h-feed and h-entry, as both a feed with no entries
     
    18432027                        $query = '//*[contains(concat(" ", @class, " "), " h-feed ") or '.
    18442028                            'contains(concat(" ", @class, " "), " h-entry ")]';
     2029
     2030                        /** @var \DOMNodeList<\DOMElement> $result */
    18452031                        $result = $xpath->query($query);
    18462032                        $microformats = $result->length !== 0;
     
    18532039                    );
    18542040                    if ($microformats) {
    1855                         if ($hub = $locate->get_rel_link('hub')) {
    1856                             $self = $locate->get_rel_link('self');
    1857                             $this->store_links($file, $hub, $self);
     2041                        $hub = $locate->get_rel_link('hub');
     2042                        $self = $locate->get_rel_link('self');
     2043                        if ($hub || $self) {
     2044                            $file = $this->store_links($file, $hub, $self);
    18582045                        }
    18592046                        // Push the current file onto all_discovered feeds so the user can
    18602047                        // be shown this as one of the options.
    1861                         if (isset($this->all_discovered_feeds)) {
     2048                        if ($this->all_discovered_feeds !== null) {
    18622049                            $this->all_discovered_feeds[] = $file;
    18632050                        }
     
    18742061                        }
    18752062                    }
    1876                 } catch (\SimplePie\Exception $e) {
     2063                } catch (SimplePieException $e) {
    18772064                    // We need to unset this so that if SimplePie::set_file() has been called that object is untouched
    18782065                    unset($file);
     
    18862073                    $this->data = [
    18872074                        'url' => $this->feed_url,
    1888                         'feed_url' => $file->url,
    1889                         'build' => \SimplePie\Misc::get_build(),
     2075                        'feed_url' => $file->get_final_requested_uri(),
     2076                        'build' => Misc::get_build(),
    18902077                        'cache_expiration_time' => $this->cache_duration + time(),
    18912078                    ];
     
    18962083                }
    18972084            }
    1898             $this->feed_url = $file->url;
     2085            $this->feed_url = $file->get_final_requested_uri();
    18992086            $locate = null;
    19002087        }
    19012088
    1902         $this->raw_data = $file->body;
    1903         $this->permanent_url = $file->permanent_url;
    1904         $headers = $file->headers;
     2089        $this->raw_data = $file->get_body_content();
     2090        $this->permanent_url = $file->get_permanent_uri();
     2091
     2092        $headers = [];
     2093        foreach ($file->get_headers() as $key => $values) {
     2094            $headers[$key] = implode(', ', $values);
     2095        }
     2096
    19052097        $sniffer = $this->registry->create(Sniffer::class, [&$file]);
    19062098        $sniffed = $sniffer->get_type();
     
    19122104     * Get the error message for the occurred error
    19132105     *
    1914      * @return string|array Error message, or array of messages for multifeeds
     2106     * @return string|string[]|null Error message, or array of messages for multifeeds
    19152107     */
    19162108    public function error()
     
    19352127     * the data instead of printing it.
    19362128     *
    1937      * @return string|boolean Raw XML data, false if the cache is used
     2129     * @return string|false Raw XML data, false if the cache is used
    19382130     */
    19392131    public function get_raw_data()
     
    19712163     *
    19722164     * @param string $mime MIME type to serve the page as
    1973      */
    1974     public function handle_content_type($mime = 'text/html')
     2165     * @return void
     2166     */
     2167    public function handle_content_type(string $mime = 'text/html')
    19752168    {
    19762169        if (!headers_sent()) {
     
    19882181     * Get the type of the feed
    19892182     *
    1990      * This returns a \SimplePie\SimplePie::TYPE_* constant, which can be tested against
     2183     * This returns a self::TYPE_* constant, which can be tested against
    19912184     * using {@link http://php.net/language.operators.bitwise bitwise operators}
    19922185     *
    19932186     * @since 0.8 (usage changed to using constants in 1.0)
    1994      * @see \SimplePie\SimplePie::TYPE_NONE Unknown.
    1995      * @see \SimplePie\SimplePie::TYPE_RSS_090 RSS 0.90.
    1996      * @see \SimplePie\SimplePie::TYPE_RSS_091_NETSCAPE RSS 0.91 (Netscape).
    1997      * @see \SimplePie\SimplePie::TYPE_RSS_091_USERLAND RSS 0.91 (Userland).
    1998      * @see \SimplePie\SimplePie::TYPE_RSS_091 RSS 0.91.
    1999      * @see \SimplePie\SimplePie::TYPE_RSS_092 RSS 0.92.
    2000      * @see \SimplePie\SimplePie::TYPE_RSS_093 RSS 0.93.
    2001      * @see \SimplePie\SimplePie::TYPE_RSS_094 RSS 0.94.
    2002      * @see \SimplePie\SimplePie::TYPE_RSS_10 RSS 1.0.
    2003      * @see \SimplePie\SimplePie::TYPE_RSS_20 RSS 2.0.x.
    2004      * @see \SimplePie\SimplePie::TYPE_RSS_RDF RDF-based RSS.
    2005      * @see \SimplePie\SimplePie::TYPE_RSS_SYNDICATION Non-RDF-based RSS (truly intended as syndication format).
    2006      * @see \SimplePie\SimplePie::TYPE_RSS_ALL Any version of RSS.
    2007      * @see \SimplePie\SimplePie::TYPE_ATOM_03 Atom 0.3.
    2008      * @see \SimplePie\SimplePie::TYPE_ATOM_10 Atom 1.0.
    2009      * @see \SimplePie\SimplePie::TYPE_ATOM_ALL Any version of Atom.
    2010      * @see \SimplePie\SimplePie::TYPE_ALL Any known/supported feed type.
    2011      * @return int \SimplePie\SimplePie::TYPE_* constant
     2187     * @see self::TYPE_NONE Unknown.
     2188     * @see self::TYPE_RSS_090 RSS 0.90.
     2189     * @see self::TYPE_RSS_091_NETSCAPE RSS 0.91 (Netscape).
     2190     * @see self::TYPE_RSS_091_USERLAND RSS 0.91 (Userland).
     2191     * @see self::TYPE_RSS_091 RSS 0.91.
     2192     * @see self::TYPE_RSS_092 RSS 0.92.
     2193     * @see self::TYPE_RSS_093 RSS 0.93.
     2194     * @see self::TYPE_RSS_094 RSS 0.94.
     2195     * @see self::TYPE_RSS_10 RSS 1.0.
     2196     * @see self::TYPE_RSS_20 RSS 2.0.x.
     2197     * @see self::TYPE_RSS_RDF RDF-based RSS.
     2198     * @see self::TYPE_RSS_SYNDICATION Non-RDF-based RSS (truly intended as syndication format).
     2199     * @see self::TYPE_RSS_ALL Any version of RSS.
     2200     * @see self::TYPE_ATOM_03 Atom 0.3.
     2201     * @see self::TYPE_ATOM_10 Atom 1.0.
     2202     * @see self::TYPE_ATOM_ALL Any version of Atom.
     2203     * @see self::TYPE_ALL Any known/supported feed type.
     2204     * @return int-mask-of<self::TYPE_*> constant
    20122205     */
    20132206    public function get_type()
     
    20942287     * @return string|null
    20952288     */
    2096     public function subscribe_url($permanent = false)
     2289    public function subscribe_url(bool $permanent = false)
    20972290    {
    20982291        if ($permanent) {
     
    21522345     * @param string $namespace The URL of the XML namespace of the elements you're trying to access
    21532346     * @param string $tag Tag name
    2154      * @return array
    2155      */
    2156     public function get_feed_tags($namespace, $tag)
     2347     * @return array<array<string, mixed>>|null
     2348     */
     2349    public function get_feed_tags(string $namespace, string $tag)
    21572350    {
    21582351        $type = $this->get_type();
     
    21922385     * @param string $namespace The URL of the XML namespace of the elements you're trying to access
    21932386     * @param string $tag Tag name
    2194      * @return array
    2195      */
    2196     public function get_channel_tags($namespace, $tag)
     2387     * @return array<array<string, mixed>>|null
     2388     */
     2389    public function get_channel_tags(string $namespace, string $tag)
    21972390    {
    21982391        $type = $this->get_type();
     
    22382431     * @param string $namespace The URL of the XML namespace of the elements you're trying to access
    22392432     * @param string $tag Tag name
    2240      * @return array
    2241      */
    2242     public function get_image_tags($namespace, $tag)
     2433     * @return array<array<string, mixed>>|null
     2434     */
     2435    public function get_image_tags(string $namespace, string $tag)
    22432436    {
    22442437        $type = $this->get_type();
     
    22702463     * Get the base URL value from the feed
    22712464     *
    2272      * Uses `<xml:base>` if available, otherwise uses the first link in the
    2273      * feed, or failing that, the URL of the feed itself.
     2465     * Uses `<xml:base>` if available,
     2466     * otherwise uses the first 'self' link or the first 'alternate' link of the feed,
     2467     * or failing that, the URL of the feed itself.
    22742468     *
    22752469     * @see get_link
    22762470     * @see subscribe_url
    22772471     *
    2278      * @param array $element
     2472     * @param array<string, mixed> $element
    22792473     * @return string
    22802474     */
    2281     public function get_base($element = [])
     2475    public function get_base(array $element = [])
    22822476    {
    22832477        if (!empty($element['xml_base_explicit']) && isset($element['xml_base'])) {
    22842478            return $element['xml_base'];
    2285         } elseif ($this->get_link() !== null) {
    2286             return $this->get_link();
    2287         }
    2288 
    2289         return $this->subscribe_url();
     2479        }
     2480        if (($link = $this->get_link(0, 'alternate')) !== null) {
     2481            return $link;
     2482        }
     2483        if (($link = $this->get_link(0, 'self')) !== null) {
     2484            return $link;
     2485        }
     2486
     2487        return $this->subscribe_url() ?? '';
    22902488    }
    22912489
     
    22942492     *
    22952493     * @access private
    2296      * @see \SimplePie\Sanitize::sanitize()
     2494     * @see Sanitize::sanitize()
    22972495     * @param string $data Data to sanitize
    2298      * @param int $type One of the \SimplePie\SimplePie::CONSTRUCT_* constants
     2496     * @param int-mask-of<SimplePie::CONSTRUCT_*> $type
    22992497     * @param string $base Base URL to resolve URLs against
    23002498     * @return string Sanitized data
    23012499     */
    2302     public function sanitize($data, $type, $base = '')
     2500    public function sanitize(string $data, int $type, string $base = '')
    23032501    {
    23042502        try {
     2503            // This really returns string|false but changing encoding is uncommon and we are going to deprecate it, so let’s just lie to PHPStan in the interest of cleaner annotations.
    23052504            return $this->sanitize->sanitize($data, $type, $base);
    2306         } catch (\SimplePie\Exception $e) {
     2505        } catch (SimplePieException $e) {
    23072506            if (!$this->enable_exceptions) {
    23082507                $this->error = $e->getMessage();
     
    23492548     * @since Unknown
    23502549     * @param int $key The category that you want to return. Remember that arrays begin with 0, not 1
    2351      * @return \SimplePie\Category|null
    2352      */
    2353     public function get_category($key = 0)
     2550     * @return Category|null
     2551     */
     2552    public function get_category(int $key = 0)
    23542553    {
    23552554        $categories = $this->get_categories();
     
    23672566     *
    23682567     * @since Unknown
    2369      * @return array|null List of {@see \SimplePie\Category} objects
     2568     * @return array<Category>|null List of {@see Category} objects
    23702569     */
    23712570    public function get_categories()
     
    24182617     * @since 1.1
    24192618     * @param int $key The author that you want to return. Remember that arrays begin with 0, not 1
    2420      * @return \SimplePie\Author|null
    2421      */
    2422     public function get_author($key = 0)
     2619     * @return Author|null
     2620     */
     2621    public function get_author(int $key = 0)
    24232622    {
    24242623        $authors = $this->get_authors();
     
    24362635     *
    24372636     * @since 1.1
    2438      * @return array|null List of {@see \SimplePie\Author} objects
     2637     * @return array<Author>|null List of {@see Author} objects
    24392638     */
    24402639    public function get_authors()
     
    24492648            }
    24502649            if (isset($author['child'][self::NAMESPACE_ATOM_10]['uri'][0]['data'])) {
    2451                 $uri = $this->sanitize($author['child'][self::NAMESPACE_ATOM_10]['uri'][0]['data'], self::CONSTRUCT_IRI, $this->get_base($author['child'][self::NAMESPACE_ATOM_10]['uri'][0]));
     2650                $uri = $author['child'][self::NAMESPACE_ATOM_10]['uri'][0];
     2651                $uri = $this->sanitize($uri['data'], self::CONSTRUCT_IRI, $this->get_base($uri));
    24522652            }
    24532653            if (isset($author['child'][self::NAMESPACE_ATOM_10]['email'][0]['data'])) {
     
    24662666            }
    24672667            if (isset($author[0]['child'][self::NAMESPACE_ATOM_03]['url'][0]['data'])) {
    2468                 $url = $this->sanitize($author[0]['child'][self::NAMESPACE_ATOM_03]['url'][0]['data'], self::CONSTRUCT_IRI, $this->get_base($author[0]['child'][self::NAMESPACE_ATOM_03]['url'][0]));
     2668                $url = $author[0]['child'][self::NAMESPACE_ATOM_03]['url'][0];
     2669                $url = $this->sanitize($url['data'], self::CONSTRUCT_IRI, $this->get_base($url));
    24692670            }
    24702671            if (isset($author[0]['child'][self::NAMESPACE_ATOM_03]['email'][0]['data'])) {
     
    24972698     * @since 1.1
    24982699     * @param int $key The contrbutor that you want to return. Remember that arrays begin with 0, not 1
    2499      * @return \SimplePie\Author|null
    2500      */
    2501     public function get_contributor($key = 0)
     2700     * @return Author|null
     2701     */
     2702    public function get_contributor(int $key = 0)
    25022703    {
    25032704        $contributors = $this->get_contributors();
     
    25152716     *
    25162717     * @since 1.1
    2517      * @return array|null List of {@see \SimplePie\Author} objects
     2718     * @return array<Author>|null List of {@see Author} objects
    25182719     */
    25192720    public function get_contributors()
     
    25282729            }
    25292730            if (isset($contributor['child'][self::NAMESPACE_ATOM_10]['uri'][0]['data'])) {
    2530                 $uri = $this->sanitize($contributor['child'][self::NAMESPACE_ATOM_10]['uri'][0]['data'], self::CONSTRUCT_IRI, $this->get_base($contributor['child'][self::NAMESPACE_ATOM_10]['uri'][0]));
     2731                $uri = $contributor['child'][self::NAMESPACE_ATOM_10]['uri'][0];
     2732                $uri = $this->sanitize($uri['data'], self::CONSTRUCT_IRI, $this->get_base($uri));
    25312733            }
    25322734            if (isset($contributor['child'][self::NAMESPACE_ATOM_10]['email'][0]['data'])) {
     
    25452747            }
    25462748            if (isset($contributor['child'][self::NAMESPACE_ATOM_03]['url'][0]['data'])) {
    2547                 $url = $this->sanitize($contributor['child'][self::NAMESPACE_ATOM_03]['url'][0]['data'], self::CONSTRUCT_IRI, $this->get_base($contributor['child'][self::NAMESPACE_ATOM_03]['url'][0]));
     2749                $url = $contributor['child'][self::NAMESPACE_ATOM_03]['url'][0];
     2750                $url = $this->sanitize($url['data'], self::CONSTRUCT_IRI, $this->get_base($url));
    25482751            }
    25492752            if (isset($contributor['child'][self::NAMESPACE_ATOM_03]['email'][0]['data'])) {
     
    25702773     * @return string|null Link URL
    25712774     */
    2572     public function get_link($key = 0, $rel = 'alternate')
     2775    public function get_link(int $key = 0, string $rel = 'alternate')
    25732776    {
    25742777        $links = $this->get_links($rel);
     
    26032806     * @since Beta 2
    26042807     * @param string $rel The relationship of links to return
    2605      * @return array|null Links found for the feed (strings)
    2606      */
    2607     public function get_links($rel = 'alternate')
     2808     * @return array<string>|null Links found for the feed (strings)
     2809     */
     2810    public function get_links(string $rel = 'alternate')
    26082811    {
    26092812        if (!isset($this->data['links'])) {
     
    26702873    }
    26712874
     2875    /**
     2876     * @return ?array<Response>
     2877     */
    26722878    public function get_all_discovered_feeds()
    26732879    {
     
    27732979     * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo
    27742980     * @link http://www.georss.org/ GeoRSS
    2775      * @return string|null
     2981     * @return float|null
    27762982     */
    27772983    public function get_latitude()
     
    27963002     * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo
    27973003     * @link http://www.georss.org/ GeoRSS
    2798      * @return string|null
     3004     * @return float|null
    27993005     */
    28003006    public function get_longitude()
     
    29433149     * @return int Number of items in the feed
    29443150     */
    2945     public function get_item_quantity($max = 0)
    2946     {
    2947         $max = (int) $max;
     3151    public function get_item_quantity(int $max = 0)
     3152    {
    29483153        $qty = count($this->get_items());
    29493154        if ($max === 0) {
     
    29513156        }
    29523157
    2953         return ($qty > $max) ? $max : $qty;
     3158        return min($qty, $max);
    29543159    }
    29553160
     
    29643169     * @since Beta 2
    29653170     * @param int $key The item that you want to return. Remember that arrays begin with 0, not 1
    2966      * @return \SimplePie\Item|null
    2967      */
    2968     public function get_item($key = 0)
     3171     * @return Item|null
     3172     */
     3173    public function get_item(int $key = 0)
    29693174    {
    29703175        $items = $this->get_items();
     
    29873192     * @param int $start Index to start at
    29883193     * @param int $end Number of items to return. 0 for all items after `$start`
    2989      * @return \SimplePie\Item[]|null List of {@see \SimplePie\Item} objects
    2990      */
    2991     public function get_items($start = 0, $end = 0)
     3194     * @return Item[] List of {@see Item} objects
     3195     */
     3196    public function get_items(int $start = 0, int $end = 0)
    29923197    {
    29933198        if (!isset($this->data['items'])) {
     
    30033208                $keys = array_keys($items);
    30043209                foreach ($keys as $key) {
    3005                     $this->data['items'][] = $this->registry->create(Item::class, [$this, $items[$key]]);
     3210                    $this->data['items'][] = $this->make_item($items[$key]);
    30063211                }
    30073212            }
     
    30093214                $keys = array_keys($items);
    30103215                foreach ($keys as $key) {
    3011                     $this->data['items'][] = $this->registry->create(Item::class, [$this, $items[$key]]);
     3216                    $this->data['items'][] = $this->make_item($items[$key]);
    30123217                }
    30133218            }
     
    30153220                $keys = array_keys($items);
    30163221                foreach ($keys as $key) {
    3017                     $this->data['items'][] = $this->registry->create(Item::class, [$this, $items[$key]]);
     3222                    $this->data['items'][] = $this->make_item($items[$key]);
    30183223                }
    30193224            }
     
    30213226                $keys = array_keys($items);
    30223227                foreach ($keys as $key) {
    3023                     $this->data['items'][] = $this->registry->create(Item::class, [$this, $items[$key]]);
     3228                    $this->data['items'][] = $this->make_item($items[$key]);
    30243229                }
    30253230            }
     
    30273232                $keys = array_keys($items);
    30283233                foreach ($keys as $key) {
    3029                     $this->data['items'][] = $this->registry->create(Item::class, [$this, $items[$key]]);
     3234                    $this->data['items'][] = $this->make_item($items[$key]);
    30303235                }
    30313236            }
     
    30573262     *
    30583263     * @deprecated Use your own favicon handling instead
    3059      */
    3060     public function set_favicon_handler($page = false, $qs = 'i')
    3061     {
    3062         trigger_error('Favicon handling has been removed, please use your own handling', \E_USER_DEPRECATED);
     3264     * @param string|false $page
     3265     * @return bool
     3266     */
     3267    public function set_favicon_handler($page = false, string $qs = 'i')
     3268    {
     3269        trigger_error('Favicon handling has been removed since SimplePie 1.3, please use your own handling', \E_USER_DEPRECATED);
    30633270        return false;
    30643271    }
     
    30683275     *
    30693276     * @deprecated Use your own favicon handling instead
     3277     * @return string|bool
    30703278     */
    30713279    public function get_favicon()
    30723280    {
    3073         trigger_error('Favicon handling has been removed, please use your own handling', \E_USER_DEPRECATED);
     3281        trigger_error('Favicon handling has been removed since SimplePie 1.3, please use your own handling', \E_USER_DEPRECATED);
    30743282
    30753283        if (($url = $this->get_link()) !== null) {
     
    30843292     *
    30853293     * @param string $method Method name
    3086      * @param array $args Arguments to the method
     3294     * @param array<mixed> $args Arguments to the method
    30873295     * @return mixed
    30883296     */
    3089     public function __call($method, $args)
     3297    public function __call(string $method, array $args)
    30903298    {
    30913299        if (strpos($method, 'subscribe_') === 0) {
    3092             trigger_error('subscribe_*() has been deprecated, implement the callback yourself', \E_USER_DEPRECATED);
     3300            trigger_error('subscribe_*() has been deprecated since SimplePie 1.3, implement the callback yourself', \E_USER_DEPRECATED);
    30933301            return '';
    30943302        }
    30953303        if ($method === 'enable_xml_dump') {
    3096             trigger_error('enable_xml_dump() has been deprecated, use get_raw_data() instead', \E_USER_DEPRECATED);
     3304            trigger_error('enable_xml_dump() has been deprecated since SimplePie 1.3, use get_raw_data() instead', \E_USER_DEPRECATED);
    30973305            return false;
    30983306        }
     
    31003308        $class = get_class($this);
    31013309        $trace = debug_backtrace(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
    3102         $file = $trace[0]['file'];
    3103         $line = $trace[0]['line'];
     3310        $file = $trace[0]['file'] ?? '';
     3311        $line = $trace[0]['line'] ?? '';
    31043312        throw new SimplePieException("Call to undefined method $class::$method() in $file on line $line");
    31053313    }
    31063314
    31073315    /**
     3316     * Item factory
     3317     *
     3318     * @param array<string, mixed> $data
     3319     */
     3320    private function make_item(array $data): Item
     3321    {
     3322        $item = $this->registry->create(Item::class, [$this, $data]);
     3323        $item->set_sanitize($this->sanitize);
     3324
     3325        return $item;
     3326    }
     3327
     3328    /**
    31083329     * Sorting callback for items
    31093330     *
    31103331     * @access private
    3111      * @param SimplePie $a
    3112      * @param SimplePie $b
    3113      * @return boolean
    3114      */
    3115     public static function sort_items($a, $b)
     3332     * @param Item $a
     3333     * @param Item $b
     3334     * @return -1|0|1
     3335     */
     3336    public static function sort_items(Item $a, Item $b)
    31163337    {
    31173338        $a_date = $a->get_date('U');
     
    31373358     *
    31383359     * @link http://simplepie.org/wiki/tutorial/sort_multiple_feeds_by_time_and_date#if_feeds_require_separate_per-feed_settings
    3139      * @param array $urls List of SimplePie feed objects to merge
     3360     * @param array<SimplePie> $urls List of SimplePie feed objects to merge
    31403361     * @param int $start Starting item
    31413362     * @param int $end Number of items to return
    31423363     * @param int $limit Maximum number of items per feed
    3143      * @return array
    3144      */
    3145     public static function merge_items($urls, $start = 0, $end = 0, $limit = 0)
    3146     {
    3147         if (is_array($urls) && sizeof($urls) > 0) {
     3364     * @return array<Item>
     3365     */
     3366    public static function merge_items(array $urls, int $start = 0, int $end = 0, int $limit = 0)
     3367    {
     3368        if (count($urls) > 0) {
    31483369            $items = [];
    31493370            foreach ($urls as $arg) {
    31503371                if ($arg instanceof SimplePie) {
    31513372                    $items = array_merge($items, $arg->get_items(0, $limit));
     3373
     3374                    // @phpstan-ignore-next-line Enforce PHPDoc type.
    31523375                } else {
    31533376                    trigger_error('Arguments must be SimplePie objects', E_USER_WARNING);
     
    31733396     * There is no way to find PuSH links in the body of a microformats feed,
    31743397     * so they are added to the headers when found, to be used later by get_links.
    3175      * @param \SimplePie\File $file
    3176      * @param string $hub
    3177      * @param string $self
    3178      */
    3179     private function store_links(&$file, $hub, $self)
    3180     {
    3181         if (isset($file->headers['link']['hub']) ||
    3182               (isset($file->headers['link']) &&
    3183                preg_match('/rel=hub/', $file->headers['link']))) {
    3184             return;
    3185         }
    3186 
    3187         if ($hub) {
    3188             if (isset($file->headers['link'])) {
    3189                 if ($file->headers['link'] !== '') {
    3190                     $file->headers['link'] = ', ';
    3191                 }
    3192             } else {
    3193                 $file->headers['link'] = '';
    3194             }
    3195             $file->headers['link'] .= '<'.$hub.'>; rel=hub';
    3196             if ($self) {
    3197                 $file->headers['link'] .= ', <'.$self.'>; rel=self';
    3198             }
    3199         }
     3398     */
     3399    private function store_links(Response $file, ?string $hub, ?string $self): Response
     3400    {
     3401        $linkHeaderLine = $file->get_header_line('link');
     3402        $linkHeader = $file->get_header('link');
     3403
     3404        if ($hub && !preg_match('/rel=hub/', $linkHeaderLine)) {
     3405            $linkHeader[] = '<'.$hub.'>; rel=hub';
     3406        }
     3407
     3408        if ($self && !preg_match('/rel=self/', $linkHeaderLine)) {
     3409            $linkHeader[] = '<'.$self.'>; rel=self';
     3410        }
     3411
     3412        if (count($linkHeader) > 0) {
     3413            $file = $file->with_header('link', $linkHeader);
     3414        }
     3415
     3416        return $file;
    32003417    }
    32013418
     
    32073424     * @return DataCache
    32083425     */
    3209     private function get_cache($feed_url = '')
     3426    private function get_cache(string $feed_url = ''): DataCache
    32103427    {
    32113428        if ($this->cache === null) {
     
    32223439        return $this->cache;
    32233440    }
     3441
     3442    /**
     3443     * Get a HTTP client
     3444     */
     3445    private function get_http_client(): Client
     3446    {
     3447        if ($this->http_client === null) {
     3448            $this->http_client = new FileClient(
     3449                $this->get_registry(),
     3450                [
     3451                    'timeout' => $this->timeout,
     3452                    'redirects' => 5,
     3453                    'useragent' => $this->useragent,
     3454                    'force_fsockopen' => $this->force_fsockopen,
     3455                    'curl_options' => $this->curl_options,
     3456                ]
     3457            );
     3458            $this->http_client_injected = true;
     3459        }
     3460
     3461        return $this->http_client;
     3462    }
    32243463}
    32253464
  • trunk/src/wp-includes/SimplePie/src/Source.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
     
    5114 *
    5215 * This class can be overloaded with {@see \SimplePie::set_source_class()}
    53  *
    54  * @package SimplePie
    55  * @subpackage API
    5616 */
    5717class Source implements RegistryAware
    5818{
     19    /** @var Item */
    5920    public $item;
     21    /** @var array<string, mixed> */
    6022    public $data = [];
     23    /** @var Registry */
    6124    protected $registry;
    6225
    63     public function __construct($item, $data)
     26    /**
     27     * @param array<string, mixed> $data
     28     */
     29    public function __construct(Item $item, array $data)
    6430    {
    6531        $this->item = $item;
     
    6733    }
    6834
    69     public function set_registry(\SimplePie\Registry $registry)/* : void */
     35    /**
     36     * @return void
     37     */
     38    public function set_registry(\SimplePie\Registry $registry)
    7039    {
    7140        $this->registry = $registry;
    7241    }
    7342
     43    /**
     44     * @return string
     45     */
    7446    public function __toString()
    7547    {
     
    7749    }
    7850
    79     public function get_source_tags($namespace, $tag)
     51    /**
     52     * @param string $namespace
     53     * @param string $tag
     54     * @return array<array<string, mixed>>|null
     55     */
     56    public function get_source_tags(string $namespace, string $tag)
    8057    {
    8158        if (isset($this->data['child'][$namespace][$tag])) {
     
    8663    }
    8764
    88     public function get_base($element = [])
     65    /**
     66     * @param array<string, mixed> $element
     67     * @return string
     68     */
     69    public function get_base(array $element = [])
    8970    {
    9071        return $this->item->get_base($element);
    9172    }
    9273
    93     public function sanitize($data, $type, $base = '')
     74    /**
     75     * @param string $data
     76     * @param int-mask-of<SimplePie::CONSTRUCT_*> $type
     77     * @param string $base
     78     * @return string
     79     */
     80    public function sanitize(string $data, $type, string $base = '')
    9481    {
    9582        return $this->item->sanitize($data, $type, $base);
    9683    }
    9784
     85    /**
     86     * @return Item
     87     */
    9888    public function get_item()
    9989    {
     
    10191    }
    10292
     93    /**
     94     * @return string|null
     95     */
    10396    public function get_title()
    10497    {
     
    122115    }
    123116
    124     public function get_category($key = 0)
     117    /**
     118     * @param int $key
     119     * @return Category|null
     120     */
     121    public function get_category(int $key = 0)
    125122    {
    126123        $categories = $this->get_categories();
     
    132129    }
    133130
     131    /**
     132     * @return array<Category>|null
     133     */
    134134    public function get_categories()
    135135    {
     
    176176    }
    177177
    178     public function get_author($key = 0)
     178    /**
     179     * @param int $key
     180     * @return Author|null
     181     */
     182    public function get_author(int $key = 0)
    179183    {
    180184        $authors = $this->get_authors();
     
    186190    }
    187191
     192    /**
     193     * @return array<Author>|null
     194     */
    188195    public function get_authors()
    189196    {
     
    197204            }
    198205            if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'])) {
    199                 $uri = $this->sanitize($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]));
     206                $uri = $author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0];
     207                $uri = $this->sanitize($uri['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($uri));
    200208            }
    201209            if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'])) {
     
    214222            }
    215223            if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'])) {
    216                 $url = $this->sanitize($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]));
     224                $url = $author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0];
     225                $url = $this->sanitize($url['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($url));
    217226            }
    218227            if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'])) {
     
    240249    }
    241250
    242     public function get_contributor($key = 0)
     251    /**
     252     * @param int $key
     253     * @return Author|null
     254     */
     255    public function get_contributor(int $key = 0)
    243256    {
    244257        $contributors = $this->get_contributors();
     
    250263    }
    251264
     265    /**
     266     * @return array<Author>|null
     267     */
    252268    public function get_contributors()
    253269    {
     
    261277            }
    262278            if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'])) {
    263                 $uri = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]));
     279                $uri = $contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0];
     280                $uri = $this->sanitize($uri['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($uri));
    264281            }
    265282            if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'])) {
     
    278295            }
    279296            if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'])) {
    280                 $url = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]));
     297                $url = $contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0];
     298                $url = $this->sanitize($url['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($url));
    281299            }
    282300            if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'])) {
     
    295313    }
    296314
    297     public function get_link($key = 0, $rel = 'alternate')
     315    /**
     316     * @param int $key
     317     * @param string $rel
     318     * @return string|null
     319     */
     320    public function get_link(int $key = 0, string $rel = 'alternate')
    298321    {
    299322        $links = $this->get_links($rel);
     
    307330    /**
    308331     * Added for parity between the parent-level and the item/entry-level.
     332     *
     333     * @return string|null
    309334     */
    310335    public function get_permalink()
     
    313338    }
    314339
    315     public function get_links($rel = 'alternate')
     340    /**
     341     * @param string $rel
     342     * @return array<string>|null
     343     */
     344    public function get_links(string $rel = 'alternate')
    316345    {
    317346        if (!isset($this->data['links'])) {
     
    345374            $keys = array_keys($this->data['links']);
    346375            foreach ($keys as $key) {
     376                $key = (string) $key;
     377
    347378                if ($this->registry->call(Misc::class, 'is_isegment_nz_nc', [$key])) {
    348379                    if (isset($this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key])) {
     
    366397    }
    367398
     399    /**
     400     * @return string|null
     401     */
    368402    public function get_description()
    369403    {
     
    391425    }
    392426
     427    /**
     428     * @return string|null
     429     */
    393430    public function get_copyright()
    394431    {
     
    408445    }
    409446
     447    /**
     448     * @return string|null
     449     */
    410450    public function get_language()
    411451    {
     
    423463    }
    424464
     465    /**
     466     * @return float|null
     467     */
    425468    public function get_latitude()
    426469    {
     
    434477    }
    435478
     479    /**
     480     * @return float|null
     481     */
    436482    public function get_longitude()
    437483    {
     
    447493    }
    448494
     495    /**
     496     * @return string|null
     497     */
    449498    public function get_image_url()
    450499    {
  • trunk/src/wp-includes/SimplePie/src/XML/Declaration/Parser.php

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie\XML\Declaration;
     
    4710/**
    4811 * Parses the XML Declaration
    49  *
    50  * @package SimplePie
    51  * @subpackage Parsing
    5212 */
    5313class Parser
     
    13999     * @param string $data Input data
    140100     */
    141     public function __construct($data)
     101    public function __construct(string $data)
    142102    {
    143103        $this->data = $data;
     
    151111     * @return bool true on success, false on failure
    152112     */
    153     public function parse()
     113    public function parse(): bool
    154114    {
    155115        while ($this->state && $this->state !== self::STATE_EMIT && $this->has_data()) {
     
    162122        }
    163123
    164         $this->version = '';
    165         $this->encoding = '';
    166         $this->standalone = '';
     124        // Reset the parser state.
     125        $this->version = '1.0';
     126        $this->encoding = 'UTF-8';
     127        $this->standalone = false;
    167128        return false;
    168129    }
     
    174135     * @return bool true if there is further data, false if not
    175136     */
    176     public function has_data()
     137    public function has_data(): bool
    177138    {
    178139        return (bool) ($this->position < $this->data_length);
     
    193154    /**
    194155     * Read value
     156     *
     157     * @return string|false
    195158     */
    196159    public function get_value()
     
    209172    }
    210173
    211     public function before_version_name()
     174    public function before_version_name(): void
    212175    {
    213176        if ($this->skip_whitespace()) {
     
    218181    }
    219182
    220     public function version_name()
     183    public function version_name(): void
    221184    {
    222185        if (substr($this->data, $this->position, 7) === 'version') {
     
    229192    }
    230193
    231     public function version_equals()
     194    public function version_equals(): void
    232195    {
    233196        if (substr($this->data, $this->position, 1) === '=') {
     
    240203    }
    241204
    242     public function version_value()
    243     {
    244         if ($this->version = $this->get_value()) {
     205    public function version_value(): void
     206    {
     207        if ($version = $this->get_value()) {
     208            $this->version = $version;
    245209            $this->skip_whitespace();
    246210            if ($this->has_data()) {
     
    254218    }
    255219
    256     public function encoding_name()
     220    public function encoding_name(): void
    257221    {
    258222        if (substr($this->data, $this->position, 8) === 'encoding') {
     
    265229    }
    266230
    267     public function encoding_equals()
     231    public function encoding_equals(): void
    268232    {
    269233        if (substr($this->data, $this->position, 1) === '=') {
     
    276240    }
    277241
    278     public function encoding_value()
    279     {
    280         if ($this->encoding = $this->get_value()) {
     242    public function encoding_value(): void
     243    {
     244        if ($encoding = $this->get_value()) {
     245            $this->encoding = $encoding;
    281246            $this->skip_whitespace();
    282247            if ($this->has_data()) {
     
    290255    }
    291256
    292     public function standalone_name()
     257    public function standalone_name(): void
    293258    {
    294259        if (substr($this->data, $this->position, 10) === 'standalone') {
     
    301266    }
    302267
    303     public function standalone_equals()
     268    public function standalone_equals(): void
    304269    {
    305270        if (substr($this->data, $this->position, 1) === '=') {
     
    312277    }
    313278
    314     public function standalone_value()
     279    public function standalone_value(): void
    315280    {
    316281        if ($standalone = $this->get_value()) {
  • trunk/src/wp-includes/class-wp-simplepie-file.php

    r59141 r60771  
    7676                $this->headers = wp_remote_retrieve_headers( $res );
    7777
     78                if ( $this->headers instanceof \WpOrg\Requests\Utility\CaseInsensitiveDictionary ) {
     79                    $this->headers = $this->headers->getAll();
     80                }
     81
    7882                /*
    7983                 * SimplePie expects multiple headers to be stored as a comma-separated string,
  • trunk/src/wp-includes/feed.php

    r60703 r60771  
    813813    $feed = new SimplePie\SimplePie();
    814814
    815     $feed->set_sanitize_class( 'WP_SimplePie_Sanitize_KSES' );
     815    $feed->get_registry()->register( SimplePie\Sanitize::class, 'WP_SimplePie_Sanitize_KSES', true );
     816
    816817    /*
    817818     * We must manually overwrite $feed->sanitize because SimplePie's constructor
     
    830831    }
    831832
    832     $feed->set_file_class( 'WP_SimplePie_File' );
     833    $feed->get_registry()->register( SimplePie\File::class, 'WP_SimplePie_File', true );
    833834
    834835    $feed->set_feed_url( $url );
Note: See TracChangeset for help on using the changeset viewer.