1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Remove the polyfill we no longer need

This commit is contained in:
Bruce Weirdan 2022-01-04 11:29:00 +02:00
parent fa33632958
commit 20567ff720
No known key found for this signature in database
GPG Key ID: CFC3AAB181751B0D
3 changed files with 1 additions and 59 deletions

View File

@ -80,10 +80,7 @@
"autoload": {
"psr-4": {
"Psalm\\": "src/Psalm/"
},
"files": [
"src/spl_object_id.php"
]
}
},
"autoload-dev": {
"psr-4": {

View File

@ -34,7 +34,6 @@
<file name="src/Psalm/Internal/PhpTraverser/CustomTraverser.php"/>
<file name="tests/ErrorBaselineTest.php"/>
<file name="vendor/symfony/console/Command/Command.php"/>
<file name="src/spl_object_id.php"/>
<directory name="tests/fixtures"/>
<file name="vendor/felixfbecker/advanced-json-rpc/lib/Dispatcher.php" />
<directory name="vendor/netresearch/jsonmapper" />

View File

@ -1,54 +0,0 @@
<?php
declare(strict_types=1);
/**
* PHP Polyfill for spl_object_id() for PHP <= 7.1
* This file will be included even in releases which will analyze PHP 7.2,
* there aren't any major compatibilities preventing analysis of PHP 7.2 from running in PHP 7.1.
*/
if (!function_exists('spl_object_id')) {
if (function_exists('runkit_object_id') &&
!(new ReflectionFunction('runkit_object_id'))->isUserDefined()) {
/**
* See https://github.com/runkit7/runkit_object_id for a faster native version for php <= 7.1
*
* @param object $object
* @return int The object id
*/
function spl_object_id($object): int
{
return runkit_object_id($object);
}
} elseif (PHP_INT_SIZE === 8) {
/**
* See https://github.com/runkit7/runkit_object_id for a faster native version for php <= 7.1
*
* @param object $object
* @return int (The object id, XORed with a random number)
*/
function spl_object_id($object): int
{
$hash = spl_object_hash($object);
// Fit this into a php long (32-bit or 64-bit signed int).
// The first 16 hex digits (64 bytes) vary, the last 16 don't.
// Values are usually padded with 0s at the front.
return intval(substr($hash, 1, 15), 16);
}
} else {
/**
* See https://github.com/runkit7/runkit_object_id for a faster native version for php <= 7.1
*
* @param object $object
* @return int (The object id, XORed with a random number)
*/
function spl_object_id($object): int
{
$hash = spl_object_hash($object);
// Fit this into a php long (32-bit or 64-bit signed int).
// The first 16 hex digits (64 bytes) vary, the last 16 don't.
// Values are usually padded with 0s at the front.
return intval(substr($hash, 9, 7), 16);
}
}
}