Skip to content

Commit

Permalink
Merge pull request #853 from jtojnar/fix-ci
Browse files Browse the repository at this point in the history
ci: Fix coding style
  • Loading branch information
mblaney committed Dec 19, 2023
2 parents 290e930 + 44cd22f commit 1ec20d6
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 51 deletions.
8 changes: 4 additions & 4 deletions build/compile.php
Expand Up @@ -6,17 +6,17 @@
define('SP_PATH', dirname(__FILE__, 2)); define('SP_PATH', dirname(__FILE__, 2));
define('COMPILED', SP_PATH . DIRECTORY_SEPARATOR . 'SimplePie.compiled.php'); define('COMPILED', SP_PATH . DIRECTORY_SEPARATOR . 'SimplePie.compiled.php');


if (! function_exists('str_starts_with')) { if (!function_exists('str_starts_with')) {
function str_starts_with(string $haystack, string $needle): bool function str_starts_with(string $haystack, string $needle): bool
{ {
return strncmp($haystack, $needle, strlen($needle)) === 0; return strncmp($haystack, $needle, strlen($needle)) === 0;
} }
} }


if (! function_exists('str_ends_with')) { if (!function_exists('str_ends_with')) {
function str_ends_with(string $haystack, string $needle): bool function str_ends_with(string $haystack, string $needle): bool
{ {
return $needle === '' || $needle === substr($haystack, - strlen($needle)); return $needle === '' || $needle === substr($haystack, -strlen($needle));
} }
} }


Expand Down Expand Up @@ -58,7 +58,7 @@ function remove_header($contents)
} }
break; break;
case T_DECLARE: case T_DECLARE:
if (! $stripped_declare && ! $in_declare_strip) { if (!$stripped_declare && !$in_declare_strip) {
$in_declare_strip = true; $in_declare_strip = true;
// SPDX comments precede the declare statement. // SPDX comments precede the declare statement.
$stripped_spdx = true; $stripped_spdx = true;
Expand Down
4 changes: 2 additions & 2 deletions src/Cache/BaseDataCache.php
Expand Up @@ -46,12 +46,12 @@ public function get_data(string $key, $default = null)
{ {
$data = $this->cache->load(); $data = $this->cache->load();


if (! is_array($data)) { if (!is_array($data)) {
return $default; return $default;
} }


// ignore data if internal cache expiration time is not set // ignore data if internal cache expiration time is not set
if (! array_key_exists('__cache_expiration_time', $data)) { if (!array_key_exists('__cache_expiration_time', $data)) {
return $default; return $default;
} }


Expand Down
8 changes: 4 additions & 4 deletions src/Cache/DB.php
Expand Up @@ -42,13 +42,13 @@ protected static function prepare_simplepie_object_for_cache(\SimplePie\SimplePi
} }


if (isset($data->data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['feed'][0])) { if (isset($data->data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['feed'][0])) {
$channel = & $data->data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['feed'][0]; $channel = &$data->data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['feed'][0];
} elseif (isset($data->data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['feed'][0])) { } elseif (isset($data->data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['feed'][0])) {
$channel = & $data->data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['feed'][0]; $channel = &$data->data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['feed'][0];
} elseif (isset($data->data['child'][\SimplePie\SimplePie::NAMESPACE_RDF]['RDF'][0])) { } elseif (isset($data->data['child'][\SimplePie\SimplePie::NAMESPACE_RDF]['RDF'][0])) {
$channel = & $data->data['child'][\SimplePie\SimplePie::NAMESPACE_RDF]['RDF'][0]; $channel = &$data->data['child'][\SimplePie\SimplePie::NAMESPACE_RDF]['RDF'][0];
} elseif (isset($data->data['child'][\SimplePie\SimplePie::NAMESPACE_RSS_20]['rss'][0]['child'][\SimplePie\SimplePie::NAMESPACE_RSS_20]['channel'][0])) { } elseif (isset($data->data['child'][\SimplePie\SimplePie::NAMESPACE_RSS_20]['rss'][0]['child'][\SimplePie\SimplePie::NAMESPACE_RSS_20]['channel'][0])) {
$channel = & $data->data['child'][\SimplePie\SimplePie::NAMESPACE_RSS_20]['rss'][0]['child'][\SimplePie\SimplePie::NAMESPACE_RSS_20]['channel'][0]; $channel = &$data->data['child'][\SimplePie\SimplePie::NAMESPACE_RSS_20]['rss'][0]['child'][\SimplePie\SimplePie::NAMESPACE_RSS_20]['channel'][0];
} else { } else {
$channel = null; $channel = null;
} }
Expand Down
8 changes: 4 additions & 4 deletions src/Cache/MySQL.php
Expand Up @@ -250,13 +250,13 @@ public function load()


if ($items !== 0) { if ($items !== 0) {
if (isset($data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['feed'][0])) { if (isset($data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['feed'][0])) {
$feed = & $data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['feed'][0]; $feed = &$data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['feed'][0];
} elseif (isset($data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['feed'][0])) { } elseif (isset($data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['feed'][0])) {
$feed = & $data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['feed'][0]; $feed = &$data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['feed'][0];
} elseif (isset($data['child'][\SimplePie\SimplePie::NAMESPACE_RDF]['RDF'][0])) { } elseif (isset($data['child'][\SimplePie\SimplePie::NAMESPACE_RDF]['RDF'][0])) {
$feed = & $data['child'][\SimplePie\SimplePie::NAMESPACE_RDF]['RDF'][0]; $feed = &$data['child'][\SimplePie\SimplePie::NAMESPACE_RDF]['RDF'][0];
} elseif (isset($data['child'][\SimplePie\SimplePie::NAMESPACE_RSS_20]['rss'][0])) { } elseif (isset($data['child'][\SimplePie\SimplePie::NAMESPACE_RSS_20]['rss'][0])) {
$feed = & $data['child'][\SimplePie\SimplePie::NAMESPACE_RSS_20]['rss'][0]; $feed = &$data['child'][\SimplePie\SimplePie::NAMESPACE_RSS_20]['rss'][0];
} else { } else {
$feed = null; $feed = null;
} }
Expand Down
2 changes: 1 addition & 1 deletion src/Cache/Psr16.php
Expand Up @@ -55,7 +55,7 @@ public function get_data(string $key, $default = null)
{ {
$data = $this->cache->get($key, $default); $data = $this->cache->get($key, $default);


if (! is_array($data) || $data === $default) { if (!is_array($data) || $data === $default) {
return $default; return $default;
} }


Expand Down
2 changes: 1 addition & 1 deletion src/Content/Type/Sniffer.php
Expand Up @@ -38,7 +38,7 @@ class Sniffer
*/ */
public function __construct(/* File */ $file) public function __construct(/* File */ $file)
{ {
if (! is_object($file) || ! $file instanceof Response) { if (!is_object($file) || !$file instanceof Response) {
// For BC we're asking for `File`, but internally we accept every `Response` implementation // For BC we're asking for `File`, but internally we accept every `Response` implementation
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(sprintf(
'%s(): Argument #1 ($file) must be of type %s', '%s(): Argument #1 ($file) must be of type %s',
Expand Down
2 changes: 1 addition & 1 deletion src/File.php
Expand Up @@ -265,7 +265,7 @@ public function __construct(string $url, int $timeout = 10, int $redirects = 5,
} }
} else { } else {
$this->method = \SimplePie\SimplePie::FILE_SOURCE_LOCAL | \SimplePie\SimplePie::FILE_SOURCE_FILE_GET_CONTENTS; $this->method = \SimplePie\SimplePie::FILE_SOURCE_LOCAL | \SimplePie\SimplePie::FILE_SOURCE_FILE_GET_CONTENTS;
if (empty($url) || ! is_readable($url) || false === $filebody = file_get_contents($url)) { if (empty($url) || !is_readable($url) || false === $filebody = file_get_contents($url)) {
$this->body = ''; $this->body = '';
$this->error = sprintf('file "%s" is not readable', $url); $this->error = sprintf('file "%s" is not readable', $url);
$this->success = false; $this->success = false;
Expand Down
2 changes: 1 addition & 1 deletion src/HTTP/Psr18Client.php
Expand Up @@ -144,7 +144,7 @@ private function requestUrl(string $method, string $url, array $headers): Respon


private function requestLocalFile(string $path): Response private function requestLocalFile(string $path): Response
{ {
if (! is_readable($path)) { if (!is_readable($path)) {
throw new HttpException(sprintf('file "%s" is not readable', $path)); throw new HttpException(sprintf('file "%s" is not readable', $path));
} }


Expand Down
6 changes: 3 additions & 3 deletions src/Item.php
Expand Up @@ -841,12 +841,12 @@ public function get_links(string $rel = 'alternate')
if ($this->registry->call(Misc::class, 'is_isegment_nz_nc', [$key])) { if ($this->registry->call(Misc::class, 'is_isegment_nz_nc', [$key])) {
if (isset($this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key])) { if (isset($this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key])) {
$this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key]); $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key]);
$this->data['links'][$key] = & $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key]; $this->data['links'][$key] = &$this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key];
} else { } else {
$this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] = & $this->data['links'][$key]; $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] = &$this->data['links'][$key];
} }
} elseif (substr($key, 0, 41) === \SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY) { } elseif (substr($key, 0, 41) === \SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY) {
$this->data['links'][substr($key, 41)] = & $this->data['links'][$key]; $this->data['links'][substr($key, 41)] = &$this->data['links'][$key];
} }
$this->data['links'][$key] = array_unique($this->data['links'][$key]); $this->data['links'][$key] = array_unique($this->data['links'][$key]);
} }
Expand Down
6 changes: 3 additions & 3 deletions src/Parser.php
Expand Up @@ -307,8 +307,8 @@ public function tag_open($parser, string $tag, array $attributes)
$this->data['data'] .= '>'; $this->data['data'] .= '>';
} }
} else { } else {
$this->datas[] = & $this->data; $this->datas[] = &$this->data;
$this->data = & $this->data['child'][end($this->namespace)][end($this->element)][]; $this->data = &$this->data['child'][end($this->namespace)][end($this->element)][];
$this->data = ['data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang)]; $this->data = ['data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang)];
if ((end($this->namespace) === \SimplePie\SimplePie::NAMESPACE_ATOM_03 && in_array(end($this->element), ['title', 'tagline', 'copyright', 'info', 'summary', 'content']) && isset($attribs['']['mode']) && $attribs['']['mode'] === 'xml') if ((end($this->namespace) === \SimplePie\SimplePie::NAMESPACE_ATOM_03 && in_array(end($this->element), ['title', 'tagline', 'copyright', 'info', 'summary', 'content']) && isset($attribs['']['mode']) && $attribs['']['mode'] === 'xml')
|| (end($this->namespace) === \SimplePie\SimplePie::NAMESPACE_ATOM_10 && in_array(end($this->element), ['rights', 'subtitle', 'summary', 'info', 'title', 'content']) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml') || (end($this->namespace) === \SimplePie\SimplePie::NAMESPACE_ATOM_10 && in_array(end($this->element), ['rights', 'subtitle', 'summary', 'info', 'title', 'content']) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml')
Expand Down Expand Up @@ -346,7 +346,7 @@ public function tag_close($parser, string $tag)
} }
} }
if ($this->current_xhtml_construct === -1) { if ($this->current_xhtml_construct === -1) {
$this->data = & $this->datas[count($this->datas) - 1]; $this->data = &$this->datas[count($this->datas) - 1];
array_pop($this->datas); array_pop($this->datas);
} }


Expand Down
4 changes: 2 additions & 2 deletions src/Registry.php
Expand Up @@ -116,7 +116,7 @@ public function register(string $type, $class, bool $legacy = false)
$type = $this->legacyTypes[$type]; $type = $this->legacyTypes[$type];
} }


if (! array_key_exists($type, $this->default)) { if (!array_key_exists($type, $this->default)) {
return false; return false;
} }


Expand Down Expand Up @@ -157,7 +157,7 @@ public function get_class($type)
$type = $this->legacyTypes[$type]; $type = $this->legacyTypes[$type];
} }


if (! array_key_exists($type, $this->default)) { if (!array_key_exists($type, $this->default)) {
return null; return null;
} }


Expand Down
10 changes: 5 additions & 5 deletions src/Sanitize.php
Expand Up @@ -157,7 +157,7 @@ public function pass_cache_data(bool $enable_cache = true, string $cache_locatio
} }


// @phpstan-ignore-next-line Enforce PHPDoc type. // @phpstan-ignore-next-line Enforce PHPDoc type.
if (! is_string($cache_name_function) && ! $cache_name_function instanceof NameFilter) { if (!is_string($cache_name_function) && !$cache_name_function instanceof NameFilter) {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(sprintf(
'%s(): Argument #3 ($cache_name_function) must be of type %s', '%s(): Argument #3 ($cache_name_function) must be of type %s',
__METHOD__, __METHOD__,
Expand Down Expand Up @@ -358,15 +358,15 @@ public function set_https_domains(array $domains)
$domain = trim($domain, ". \t\n\r\0\x0B"); $domain = trim($domain, ". \t\n\r\0\x0B");
$segments = array_reverse(explode('.', $domain)); $segments = array_reverse(explode('.', $domain));
/** @var true|array<string, true|array<string, true|array<string, array<string, true|array<string, true|array<string, true>>>>>> */ // Needed for PHPStan. /** @var true|array<string, true|array<string, true|array<string, array<string, true|array<string, true|array<string, true>>>>>> */ // Needed for PHPStan.
$node = & $this->https_domains; $node = &$this->https_domains;
foreach ($segments as $segment) {//Build a tree foreach ($segments as $segment) {//Build a tree
if ($node === true) { if ($node === true) {
break; break;
} }
if (!isset($node[$segment])) { if (!isset($node[$segment])) {
$node[$segment] = []; $node[$segment] = [];
} }
$node = & $node[$segment]; $node = &$node[$segment];
} }
$node = true; $node = true;
} }
Expand All @@ -381,10 +381,10 @@ protected function is_https_domain(string $domain)
{ {
$domain = trim($domain, '. '); $domain = trim($domain, '. ');
$segments = array_reverse(explode('.', $domain)); $segments = array_reverse(explode('.', $domain));
$node = & $this->https_domains; $node = &$this->https_domains;
foreach ($segments as $segment) {//Explore the tree foreach ($segments as $segment) {//Explore the tree
if (isset($node[$segment])) { if (isset($node[$segment])) {
$node = & $node[$segment]; $node = &$node[$segment];
} else { } else {
break; break;
} }
Expand Down
18 changes: 9 additions & 9 deletions src/SimplePie.php
Expand Up @@ -791,7 +791,7 @@ public function set_file(File &$file)


$this->feed_url = $file->get_final_requested_uri(); $this->feed_url = $file->get_final_requested_uri();
$this->permanent_url = $this->feed_url; $this->permanent_url = $this->feed_url;
$this->file = & $file; $this->file = &$file;


return true; return true;
} }
Expand Down Expand Up @@ -1807,7 +1807,7 @@ public function init()
// Cache the file if caching is enabled // Cache the file if caching is enabled
$this->data['cache_expiration_time'] = $this->cache_duration + time(); $this->data['cache_expiration_time'] = $this->cache_duration + time();


if ($cache && ! $cache->set_data($this->get_cache_filename($this->feed_url), $this->data, $this->cache_duration)) { if ($cache && !$cache->set_data($this->get_cache_filename($this->feed_url), $this->data, $this->cache_duration)) {
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); 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);
} }
return true; return true;
Expand Down Expand Up @@ -1859,7 +1859,7 @@ protected function fetch_data(&$cache)
} }


// @phpstan-ignore-next-line Enforce PHPDoc type. // @phpstan-ignore-next-line Enforce PHPDoc type.
if ($cache !== false && ! $cache instanceof DataCache) { if ($cache !== false && !$cache instanceof DataCache) {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(sprintf(
'%s(): Argument #1 ($cache) must be of type %s|false', '%s(): Argument #1 ($cache) must be of type %s|false',
__METHOD__, __METHOD__,
Expand Down Expand Up @@ -1958,7 +1958,7 @@ protected function fetch_data(&$cache)
// 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. // 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.
if (!isset($file)) { if (!isset($file)) {
if ($this->file instanceof File && $this->file->get_final_requested_uri() === $this->feed_url) { if ($this->file instanceof File && $this->file->get_final_requested_uri() === $this->feed_url) {
$file = & $this->file; $file = &$this->file;
} elseif (isset($failedFileReason)) { } elseif (isset($failedFileReason)) {
// Do not try to fetch again if we already failed once. // Do not try to fetch again if we already failed once.
// If the file connection had an error, set SimplePie::error to that and quit // If the file connection had an error, set SimplePie::error to that and quit
Expand Down Expand Up @@ -1990,7 +1990,7 @@ protected function fetch_data(&$cache)
if (!$this->force_feed) { if (!$this->force_feed) {
// Check if the supplied URL is a feed, if it isn't, look for it. // Check if the supplied URL is a feed, if it isn't, look for it.
$locate = $this->registry->create(Locator::class, [ $locate = $this->registry->create(Locator::class, [
(! $file instanceof File) ? File::fromResponse($file) : $file, (!$file instanceof File) ? File::fromResponse($file) : $file,
$this->timeout, $this->timeout,
$this->useragent, $this->useragent,
$this->max_checked_feeds, $this->max_checked_feeds,
Expand Down Expand Up @@ -2826,12 +2826,12 @@ public function get_links(string $rel = 'alternate')
if ($this->registry->call(Misc::class, 'is_isegment_nz_nc', [$key])) { if ($this->registry->call(Misc::class, 'is_isegment_nz_nc', [$key])) {
if (isset($this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key])) { if (isset($this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key])) {
$this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key]); $this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key]);
$this->data['links'][$key] = & $this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key]; $this->data['links'][$key] = &$this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key];
} else { } else {
$this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key] = & $this->data['links'][$key]; $this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key] = &$this->data['links'][$key];
} }
} elseif (substr($key, 0, 41) === self::IANA_LINK_RELATIONS_REGISTRY) { } elseif (substr($key, 0, 41) === self::IANA_LINK_RELATIONS_REGISTRY) {
$this->data['links'][substr($key, 41)] = & $this->data['links'][$key]; $this->data['links'][substr($key, 41)] = &$this->data['links'][$key];
} }
$this->data['links'][$key] = array_unique($this->data['links'][$key]); $this->data['links'][$key] = array_unique($this->data['links'][$key]);
} }
Expand Down Expand Up @@ -3355,7 +3355,7 @@ public static function merge_items(array $urls, int $start = 0, int $end = 0, in
if ($arg instanceof SimplePie) { if ($arg instanceof SimplePie) {
$items = array_merge($items, $arg->get_items(0, $limit)); $items = array_merge($items, $arg->get_items(0, $limit));


// @phpstan-ignore-next-line Enforce PHPDoc type. // @phpstan-ignore-next-line Enforce PHPDoc type.
} else { } else {
trigger_error('Arguments must be SimplePie objects', E_USER_WARNING); trigger_error('Arguments must be SimplePie objects', E_USER_WARNING);
} }
Expand Down
6 changes: 3 additions & 3 deletions src/Source.php
Expand Up @@ -372,12 +372,12 @@ public function get_links(string $rel = 'alternate')
if ($this->registry->call(Misc::class, 'is_isegment_nz_nc', [$key])) { if ($this->registry->call(Misc::class, 'is_isegment_nz_nc', [$key])) {
if (isset($this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key])) { if (isset($this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key])) {
$this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key]); $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key]);
$this->data['links'][$key] = & $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key]; $this->data['links'][$key] = &$this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key];
} else { } else {
$this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] = & $this->data['links'][$key]; $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] = &$this->data['links'][$key];
} }
} elseif (substr($key, 0, 41) === \SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY) { } elseif (substr($key, 0, 41) === \SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY) {
$this->data['links'][substr($key, 41)] = & $this->data['links'][$key]; $this->data['links'][substr($key, 41)] = &$this->data['links'][$key];
} }
$this->data['links'][$key] = array_unique($this->data['links'][$key]); $this->data['links'][$key] = array_unique($this->data['links'][$key]);
} }
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/CachingTest.php
Expand Up @@ -43,7 +43,7 @@ public function testInitWithDifferentCacheStateCallsCacheCorrectly(
// Set current cached data and mtime // Set current cached data and mtime
$psr16->method('get')->willReturnCallback(function ($key, $default) use ($currentDataCached, $currentMtime) { $psr16->method('get')->willReturnCallback(function ($key, $default) use ($currentDataCached, $currentMtime) {
// Set current mtime // Set current mtime
if (substr($key, - strlen('_mtime')) === '_mtime') { if (substr($key, -strlen('_mtime')) === '_mtime') {
return $currentMtime; return $currentMtime;
} }


Expand All @@ -54,7 +54,7 @@ public function testInitWithDifferentCacheStateCallsCacheCorrectly(
// Test data written // Test data written
$psr16->method('set')->willReturnCallback(function ($key, $value, $ttl) use (&$writtenData): bool { $psr16->method('set')->willReturnCallback(function ($key, $value, $ttl) use (&$writtenData): bool {
// Ignore setting of the _mtime value // Ignore setting of the _mtime value
if (substr($key, - strlen('_mtime')) !== '_mtime') { if (substr($key, -strlen('_mtime')) !== '_mtime') {
$writtenData = $value; $writtenData = $value;
} }


Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Cache/Psr16Test.php
Expand Up @@ -54,7 +54,7 @@ public function testSetDataWithInvalidKeyThrowsInvalidArgumentException(): void
$e = $this->createMock(InvalidArgumentException::class); $e = $this->createMock(InvalidArgumentException::class);


// BC for PHP <8.0 and psr/simple-cache <2.0.0: $e must implement \Throwable // BC for PHP <8.0 and psr/simple-cache <2.0.0: $e must implement \Throwable
if (! $e instanceof Throwable) { if (!$e instanceof Throwable) {
$e = new class () extends Exception implements InvalidArgumentException {}; $e = new class () extends Exception implements InvalidArgumentException {};
} }


Expand Down Expand Up @@ -114,7 +114,7 @@ public function testGetDataWithInvalidKeyThrowsInvalidArgumentException(): void
$e = $this->createMock(InvalidArgumentException::class); $e = $this->createMock(InvalidArgumentException::class);


// BC for PHP <8.0 and psr/simple-cache <2.0.0: $e must implement \Throwable // BC for PHP <8.0 and psr/simple-cache <2.0.0: $e must implement \Throwable
if (! $e instanceof Throwable) { if (!$e instanceof Throwable) {
$e = new class () extends Exception implements InvalidArgumentException {}; $e = new class () extends Exception implements InvalidArgumentException {};
} }


Expand Down Expand Up @@ -159,7 +159,7 @@ public function testDeleteDataWithInvalidKeyThrowsInvalidArgumentException(): vo
$e = $this->createMock(InvalidArgumentException::class); $e = $this->createMock(InvalidArgumentException::class);


// BC for PHP <8.0 and psr/simple-cache <2.0.0: $e must implement \Throwable // BC for PHP <8.0 and psr/simple-cache <2.0.0: $e must implement \Throwable
if (! $e instanceof Throwable) { if (!$e instanceof Throwable) {
$e = new class () extends Exception implements InvalidArgumentException {}; $e = new class () extends Exception implements InvalidArgumentException {};
} }


Expand Down

0 comments on commit 1ec20d6

Please sign in to comment.