Skip to content

Commit

Permalink
Merge branch 'master' into cache-hash
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkarex committed Jul 23, 2024
2 parents ee843b3 + 4899a66 commit 4cd51b5
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 29 deletions.
1 change: 0 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
'@PHP71Migration:risky' => true,
'no_alias_functions' => true,
'void_return' => false,
'phpdoc_to_param_type' => true,
'@PHPUnit84Migration:risky' => true,
])
->setRiskyAllowed(true)
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Provide access to HTTP status code by @Alkarex in [#674](https://github.com/simplepie/simplepie/pull/674)
* Fix wrong type hint by @Alkarex in [#678](https://github.com/simplepie/simplepie/pull/678)
* Force HTTPS for selected domains by @Alkarex in [#676](https://github.com/simplepie/simplepie/pull/676)
* Prevent cache polution by @Alkarex in [#675](https://github.com/simplepie/simplepie/pull/675)
* Prevent cache pollution by @Alkarex in [#675](https://github.com/simplepie/simplepie/pull/675)
* Fix typo in comment by @Alkarex in [#680](https://github.com/simplepie/simplepie/pull/680)
* Remove HTTP credentials in HTTP Referer by @Alkarex in [#681](https://github.com/simplepie/simplepie/pull/681)
* CI: switch to GH Actions by @jrfnl in [#688](https://github.com/simplepie/simplepie/pull/688)
Expand Down Expand Up @@ -301,7 +301,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Fixed a PHP notice that occurs when a date starts with `(`. [#348](https://github.com/simplepie/simplepie/pull/348)
* Fixed uninitialized string offeset PHP notices. [#353](https://github.com/simplepie/simplepie/pull/353)
* Fixed call to non-existent property in Memcache. [#311](https://github.com/simplepie/simplepie/pull/311)
* Fixed a bug where MySQL statements were not being passed thorugh `prepare()`. [#348](https://github.com/simplepie/simplepie/pull/348)
* Fixed a bug where MySQL statements were not being passed through `prepare()`. [#348](https://github.com/simplepie/simplepie/pull/348)
* Fixed an instance where an error message in `SimplePie` was not being triggered correctly. [#348](https://github.com/simplepie/simplepie/pull/348)
* Fixed a bug with Russian feeds. [#348](https://github.com/simplepie/simplepie/pull/348)
* Fixed an issue with memory leaks. [#287](https://github.com/simplepie/simplepie/pull/287)
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ parameters:
- '(Constructor of class SimplePie\\Enclosure has an unused parameter \$javascript\.)'

# Testing legacy dynamic property usage.
- '(Access to an undefined property SimplePie.IRI::\$nonexistant_prop\.)'
- '(Access to an undefined property SimplePie.IRI::\$nonexistent_prop\.)'

-
message: '(^Strict comparison using === between string and false will always evaluate to false\.$)'
Expand Down
2 changes: 1 addition & 1 deletion src/Cache/CallableNameFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(callable $callable)
* and encodings or longer lengths, but MUST support at least that
* minimum.
*
* @param string $name The name for the cache will be most likly an url with query string
* @param string $name The name for the cache will be most likely an url with query string
*
* @return string the new cache name
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Cache/NameFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface NameFilter
* and encodings or longer lengths, but MUST support at least that
* minimum.
*
* @param string $name The name for the cache will be most likly an url with query string
* @param string $name The name for the cache will be most likely an url with query string
*
* @return string the new cache name
*/
Expand Down
4 changes: 2 additions & 2 deletions src/HTTP/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ class Parser
protected $position = 0;

/**
* Name of the hedaer currently being parsed
* Name of the header currently being parsed
*
* @var string
*/
protected $name = '';

/**
* Value of the hedaer currently being parsed
* Value of the header currently being parsed
*
* @var string
*/
Expand Down
8 changes: 4 additions & 4 deletions src/Misc.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,13 @@ public static function change_encoding(string $data, string $input, string $outp

// We fail to fail on non US-ASCII bytes
if ($input === 'US-ASCII') {
static $non_ascii_octects = '';
if (!$non_ascii_octects) {
static $non_ascii_octets = '';
if (!$non_ascii_octets) {
for ($i = 0x80; $i <= 0xFF; $i++) {
$non_ascii_octects .= chr($i);
$non_ascii_octets .= chr($i);
}
}
$data = substr($data, 0, strcspn($data, $non_ascii_octects));
$data = substr($data, 0, strcspn($data, $non_ascii_octets));
}

// This is first, as behaviour of this is completely predictable
Expand Down
2 changes: 2 additions & 0 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ public function parse(string &$data, string $encoding, string $url = '')
//Parse by chunks not to use too much memory
do {
$stream_data = fread($stream, 1048576);
// NB: At some point between PHP 7.3 and 7.4, the signature for `fread()` has changed
// from returning `string` to returning `string|false`, hence the falsy check:
if (!xml_parse($xml, $stream_data == false ? '' : $stream_data, feof($stream))) {
$this->error_code = xml_get_error_code($xml);
$this->error_string = xml_error_string($this->error_code);
Expand Down
4 changes: 2 additions & 2 deletions src/SimplePie.php
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,7 @@ public function remove_div(bool $enable = true)
}

/**
* @param string[]|string|false $tags Set a list of tags to strip, or set emtpy string to use default tags or false, to strip nothing.
* @param string[]|string|false $tags Set a list of tags to strip, or set empty string to use default tags or false, to strip nothing.
* @return void
*/
public function strip_htmltags($tags = '', ?bool $encode = null)
Expand Down Expand Up @@ -3416,7 +3416,7 @@ public static function merge_items(array $urls, int $start = 0, int $end = 0, in
if ($arg instanceof SimplePie) {
$items = array_merge($items, $arg->get_items(0, $limit));

// @phpstan-ignore-next-line Enforce PHPDoc type.
// @phpstan-ignore-next-line Enforce PHPDoc type.
} else {
trigger_error('Arguments must be SimplePie objects', E_USER_WARNING);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/EncodingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function test_convert_UTF16(string $input, string $expected, string $enco
$this->assertSameBin2Hex($expected, SimplePie_Misc::change_encoding($input, $encoding, 'UTF-16'));
}

public function test_nonexistant(): void
public function test_nonexistent(): void
{
$this->assertFalse(SimplePie_Misc::change_encoding('', 'TESTENC', 'UTF-8'));
}
Expand Down
8 changes: 4 additions & 4 deletions tests/IRITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,16 +446,16 @@ public function testWriteAliased(): void
$this->assertSame('test', $iri->fragment);
}

public function testNonexistantProperty(): void
public function testNonexistentProperty(): void
{
$iri = new SimplePie_IRI();
$this->assertFalse(isset($iri->nonexistant_prop));
$this->assertFalse(isset($iri->nonexistent_prop));

// PHPUnit 10 compatible way to test trigger_error().
set_error_handler(
function ($errno, $errstr): bool {
$this->assertSame(
'Undefined property: SimplePie\IRI::nonexistant_prop',
'Undefined property: SimplePie\IRI::nonexistent_prop',
$errstr
);

Expand All @@ -465,7 +465,7 @@ function ($errno, $errstr): bool {
E_USER_NOTICE
);

$should_fail = $iri->nonexistant_prop;
$should_fail = $iri->nonexistent_prop;
}

public function testBlankHost(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/CachingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function testInitWithDifferentCacheStateCallsCacheCorrectly(

$writtenData = $data;

// Ignore internally setted '__cache_expiration_time'
// Ignore internally set '__cache_expiration_time'
if (array_key_exists('__cache_expiration_time', $writtenData)) {
unset($writtenData['__cache_expiration_time']);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/CategoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function testClassExists(): void
/**
* @return array<array{string, string}>
*/
public static function getFeedCategoryLableDataProvider(): array
public static function getFeedCategoryLabelDataProvider(): array
{
return [
'Test Atom 0.3 DC 1.0 Subject' => [
Expand Down Expand Up @@ -377,7 +377,7 @@ public static function getFeedCategoryLableDataProvider(): array
}

/**
* @dataProvider getFeedCategoryLableDataProvider
* @dataProvider getFeedCategoryLabelDataProvider
*/
public function test_get_label_from_feed_category(string $data, string $expected): void
{
Expand All @@ -395,7 +395,7 @@ public function test_get_label_from_feed_category(string $data, string $expected
/**
* @return array<array{string, string}>
*/
public static function getItemCategoryLableDataProvider(): array
public static function getItemCategoryLabelDataProvider(): array
{
return [
'Test Atom 0.3 DC 1.0 Subject' => [
Expand Down Expand Up @@ -805,7 +805,7 @@ public static function getItemCategoryLableDataProvider(): array
}

/**
* @dataProvider getItemCategoryLableDataProvider
* @dataProvider getItemCategoryLabelDataProvider
*/
public function test_get_label_from_item_category(string $data, string $expected): void
{
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/IRITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,16 +456,16 @@ public function testWriteAliased(): void
$this->assertSame('test', $iri->fragment);
}

public function testNonexistantProperty(): void
public function testNonexistentProperty(): void
{
$iri = new IRI();
$this->assertFalse(isset($iri->nonexistant_prop));
$this->assertFalse(isset($iri->nonexistent_prop));

// PHPUnit 10 compatible way to test trigger_error().
set_error_handler(
function ($errno, $errstr): bool {
$this->assertSame(
'Undefined property: SimplePie\IRI::nonexistant_prop',
'Undefined property: SimplePie\IRI::nonexistent_prop',
$errstr
);

Expand All @@ -475,7 +475,7 @@ function ($errno, $errstr): bool {
E_USER_NOTICE
);

$should_fail = $iri->nonexistant_prop;
$should_fail = $iri->nonexistent_prop;
}

public function testBlankHost(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/MiscTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function test_convert_UTF16(string $input, string $expected, string $enco
$this->assertSameBin2Hex($expected, Misc::change_encoding($input, $encoding, 'UTF-16'));
}

public function test_nonexistant(): void
public function test_nonexistent(): void
{
$this->assertFalse(Misc::change_encoding('', 'TESTENC', 'UTF-8'));
}
Expand Down

0 comments on commit 4cd51b5

Please sign in to comment.