- Timestamp:
- 09/16/2025 10:45:37 PM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/SimplePie/src/XML/Declaration/Parser.php
r59141 r60771 1 1 <?php 2 2 3 /** 4 * SimplePie 5 * 6 * A PHP-Based RSS and Atom Feed Framework. 7 * Takes the hard work out of managing a complete RSS/Atom solution. 8 * 9 * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 10 * All rights reserved. 11 * 12 * Redistribution and use in source and binary forms, with or without modification, are 13 * permitted provided that the following conditions are met: 14 * 15 * * Redistributions of source code must retain the above copyright notice, this list of 16 * conditions and the following disclaimer. 17 * 18 * * Redistributions in binary form must reproduce the above copyright notice, this list 19 * of conditions and the following disclaimer in the documentation and/or other materials 20 * provided with the distribution. 21 * 22 * * Neither the name of the SimplePie Team nor the names of its contributors may be used 23 * to endorse or promote products derived from this software without specific prior 24 * written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS 27 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 28 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS 29 * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 33 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 * POSSIBILITY OF SUCH DAMAGE. 35 * 36 * @package SimplePie 37 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 * @author Ryan Parman 39 * @author Sam Sneddon 40 * @author Ryan McCue 41 * @link http://simplepie.org/ SimplePie 42 * @license http://www.opensource.org/licenses/bsd-license.php BSD License 43 */ 3 // SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue 4 // SPDX-License-Identifier: BSD-3-Clause 5 6 declare(strict_types=1); 44 7 45 8 namespace SimplePie\XML\Declaration; … … 47 10 /** 48 11 * Parses the XML Declaration 49 *50 * @package SimplePie51 * @subpackage Parsing52 12 */ 53 13 class Parser … … 139 99 * @param string $data Input data 140 100 */ 141 public function __construct( $data)101 public function __construct(string $data) 142 102 { 143 103 $this->data = $data; … … 151 111 * @return bool true on success, false on failure 152 112 */ 153 public function parse() 113 public function parse(): bool 154 114 { 155 115 while ($this->state && $this->state !== self::STATE_EMIT && $this->has_data()) { … … 162 122 } 163 123 164 $this->version = ''; 165 $this->encoding = ''; 166 $this->standalone = ''; 124 // Reset the parser state. 125 $this->version = '1.0'; 126 $this->encoding = 'UTF-8'; 127 $this->standalone = false; 167 128 return false; 168 129 } … … 174 135 * @return bool true if there is further data, false if not 175 136 */ 176 public function has_data() 137 public function has_data(): bool 177 138 { 178 139 return (bool) ($this->position < $this->data_length); … … 193 154 /** 194 155 * Read value 156 * 157 * @return string|false 195 158 */ 196 159 public function get_value() … … 209 172 } 210 173 211 public function before_version_name() 174 public function before_version_name(): void 212 175 { 213 176 if ($this->skip_whitespace()) { … … 218 181 } 219 182 220 public function version_name() 183 public function version_name(): void 221 184 { 222 185 if (substr($this->data, $this->position, 7) === 'version') { … … 229 192 } 230 193 231 public function version_equals() 194 public function version_equals(): void 232 195 { 233 196 if (substr($this->data, $this->position, 1) === '=') { … … 240 203 } 241 204 242 public function version_value() 243 { 244 if ($this->version = $this->get_value()) { 205 public function version_value(): void 206 { 207 if ($version = $this->get_value()) { 208 $this->version = $version; 245 209 $this->skip_whitespace(); 246 210 if ($this->has_data()) { … … 254 218 } 255 219 256 public function encoding_name() 220 public function encoding_name(): void 257 221 { 258 222 if (substr($this->data, $this->position, 8) === 'encoding') { … … 265 229 } 266 230 267 public function encoding_equals() 231 public function encoding_equals(): void 268 232 { 269 233 if (substr($this->data, $this->position, 1) === '=') { … … 276 240 } 277 241 278 public function encoding_value() 279 { 280 if ($this->encoding = $this->get_value()) { 242 public function encoding_value(): void 243 { 244 if ($encoding = $this->get_value()) { 245 $this->encoding = $encoding; 281 246 $this->skip_whitespace(); 282 247 if ($this->has_data()) { … … 290 255 } 291 256 292 public function standalone_name() 257 public function standalone_name(): void 293 258 { 294 259 if (substr($this->data, $this->position, 10) === 'standalone') { … … 301 266 } 302 267 303 public function standalone_equals() 268 public function standalone_equals(): void 304 269 { 305 270 if (substr($this->data, $this->position, 1) === '=') { … … 312 277 } 313 278 314 public function standalone_value() 279 public function standalone_value(): void 315 280 { 316 281 if ($standalone = $this->get_value()) {
Note: See TracChangeset
for help on using the changeset viewer.