Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/DeepClone/DeepClone.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ final class DeepClone
'XMLReader' => true,
'SNMP' => true,
'tidy' => true,
'tidyNode' => true,
];

private static array $reflectors = [];
Expand Down
3 changes: 2 additions & 1 deletion src/Intl/Normalizer/Normalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ public static function normalize(string $s, int $form = self::FORM_C)
return false;
}

throw new \ValueError('normalizer_normalize(): Argument #2 ($form) must be a a valid normalization form');
// the doubled article was fixed in PHP 8.6
throw new \ValueError('normalizer_normalize(): Argument #2 ($form) must be a '.(80600 > \PHP_VERSION_ID ? 'a ' : '').'valid normalization form');
}

if ('' === $s) {
Expand Down
25 changes: 19 additions & 6 deletions tests/DeepClone/DeepCloneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1193,18 +1193,31 @@ public function testMongoDbBsonRoundTrip()
/**
* @requires extension tidy
*/
public function testTidyNodeRoundTrip()
public function testTidyNodeIsNotInstantiable()
{
$tidy = new \tidy();
$tidy->parseString('<p><b>hello</b></p>', [], 'utf8');
$b = $tidy->body()->child[0]->child[0]; // <b> node

$clone = deepclone_from_array(deepclone_to_array($b));
if (\PHP_VERSION_ID < 80600 && \extension_loaded('deepclone') && !TestListenerTrait::$enabledPolyfills) {
// tidyNode is final and bare-instantiable there, so the extension
// still restores it property by property.
$clone = deepclone_from_array(deepclone_to_array($b));

$this->assertInstanceOf(\tidyNode::class, $clone);
$this->assertNotSame($b, $clone);
$this->assertSame($b->name, $clone->name);
$this->assertSame($b->value, $clone->value);
$this->assertInstanceOf(\tidyNode::class, $clone);
$this->assertNotSame($b, $clone);
$this->assertSame($b->name, $clone->name);
$this->assertSame($b->value, $clone->value);

return;
}

// tidyNode wraps a libTidy handle that cannot survive serialization; PHP 8.6
// marks it NOT_SERIALIZABLE, and the polyfill mirrors that on every version.
$this->expectException(\DeepClone\NotInstantiableException::class);
$this->expectExceptionMessage('Type "tidyNode" is not instantiable.');

deepclone_to_array($b);
}

public function testHydrateScopedInstantiate()
Expand Down
2 changes: 1 addition & 1 deletion tests/Intl/Normalizer/NormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function testNormalizeWithInvalidForm()
{
if (80000 <= \PHP_VERSION_ID) {
$this->expectException(\ValueError::class);
$this->expectExceptionMessage('normalizer_normalize(): Argument #2 ($form) must be a a valid normalization form');
$this->expectExceptionMessage('normalizer_normalize(): Argument #2 ($form) must be a '.(80600 > \PHP_VERSION_ID ? 'a ' : '').'valid normalization form');
}

$this->assertFalse(normalizer_normalize('foo', -1));
Expand Down
7 changes: 5 additions & 2 deletions tests/Php73/Php73Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,11 @@ public function testHardwareTimeAsArrayNanos()
usleep(1000);
$hrtime2 = hrtime();

$this->assertSame(0, $hrtime2[0] - $hrtime[0]);
$this->assertGreaterThanOrEqual(1000000, $hrtime2[1] - $hrtime[1]);
// don't compare the components separately: the pair can straddle a whole second
$elapsed = 1000000000 * ($hrtime2[0] - $hrtime[0]) + $hrtime2[1] - $hrtime[1];

$this->assertGreaterThanOrEqual(1000000, $elapsed);
$this->assertLessThan(1000000000, $hrtime2[1]);
}

public function testHardwareTimeAsArraySeconds()
Expand Down