Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
vudaltsov committed Nov 21, 2024
1 parent 96025aa commit fd8b9d7
Showing 1 changed file with 91 additions and 21 deletions.
112 changes: 91 additions & 21 deletions tests/Internal/NativeAdapter/ClassFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,94 @@

final class ClassFixtures
{
private const EXTENSIONS = [
'bcmath' => true,
'bz2' => true,
'calendar' => true,
'Core' => true,
'ctype' => true,
'curl' => true,
'date' => true,
'dba' => true,
'dom' => true,
'exif' => true,
'FFI' => true,
'fileinfo' => true,
'filter' => true,
'ftp' => true,
'gd' => true,
'gettext' => true,
'gmp' => true,
'hash' => true,
'iconv' => true,
'intl' => true,
'json' => true,
'ldap' => true,
'libxml' => true,
'mbstring' => true,
'mysqli' => true,
'mysqlnd' => true,
'odbc' => true,
'openssl' => true,
'pcntl' => true,
'pcov' => true,
'pcre' => true,
'PDO' => true,
'pdo_dblib' => true,
'pdo_mysql' => true,
'PDO_ODBC' => true,
'pdo_pgsql' => true,
'pdo_sqlite' => true,
'pgsql' => true,
'Phar' => true,
'posix' => true,
'pspell' => true,
'random' => true,
'readline' => true,
'Reflection' => true,
'session' => true,
'shmop' => true,
'SimpleXML' => true,
'soap' => true,
'sockets' => true,
'sodium' => true,
'SPL' => true,
'sqlite3' => true,
'standard' => true,
'sysvmsg' => true,
'sysvsem' => true,
'sysvshm' => true,
'tidy' => true,
'tokenizer' => true,
'xml' => true,
'xmlreader' => true,
'xmlwriter' => true,
'xsl' => true,
'Zend OPcache' => true,
'zip' => true,
'zlib' => true,
];
private const INTERNAL_CLASSES_TO_SKIP = [
// has a private constructor that is available only via ReflectionClass::getConstructor()
'IntlCodePointBreakIterator' => true,
// ReflectionClass::getModifiers() returns 0 instead of 32 (enums have IS_FINAL)
'Random\IntervalBoundary' => true,
// is iterable, but does not implement Traversable
'FFI\CData' => true,
// has a lot of problems with __invoke()
'Closure' => true,
// getMethod(ispersistent).getNumberOfRequiredParameters(): failed asserting that 0 is identical to 2
'ZMQContext' => true,
// getMethod(remove).getNumberOfRequiredParameters(): failed asserting that 1 is identical to 2
'ZMQPoll' => true,
// Fatal error: OAuthProvider::__construct(): For the CLI sapi parameters must be set first via OAuthProvider::__construct(array("oauth_param" => "value", ...))
'OAuthProvider' => true,
// problems with readonly properties
'AMQPTimestamp' => true,
// problems with readonly properties
'AMQPDecimal' => true,
];

private function __construct() {}

/**
Expand Down Expand Up @@ -41,35 +129,17 @@ public static function get(): array

return self::$classes;
}
private const INTERNAL_CLASSES_TO_SKIP = [
// has a private constructor that is available only via ReflectionClass::getConstructor()
'IntlCodePointBreakIterator' => true,
// ReflectionClass::getModifiers() returns 0 instead of 32 (enums have IS_FINAL)
'Random\IntervalBoundary' => true,
// is iterable, but does not implement Traversable
'FFI\CData' => true,
// has a lot of problems with __invoke()
'Closure' => true,
// getMethod(ispersistent).getNumberOfRequiredParameters(): failed asserting that 0 is identical to 2
'ZMQContext' => true,
// getMethod(remove).getNumberOfRequiredParameters(): failed asserting that 1 is identical to 2
'ZMQPoll' => true,
// Fatal error: OAuthProvider::__construct(): For the CLI sapi parameters must be set first via OAuthProvider::__construct(array("oauth_param" => "value", ...))
'OAuthProvider' => true,
// problems with readonly properties
'AMQPTimestamp' => true,
// problems with readonly properties
'AMQPDecimal' => true,
];

/**
* @return \Generator<class-string, array{class-string}>
*/
public static function internal(): \Generator
{
foreach (self::allDeclaredClasses() as $class) {
$extension = (new \ReflectionClass($class))->getExtensionName();

/** @psalm-suppress InvalidArrayOffset */
if (!isset(self::INTERNAL_CLASSES_TO_SKIP[$class]) && (new \ReflectionClass($class))->isInternal()) {
if ($extension !== false && !isset(self::INTERNAL_CLASSES_TO_SKIP[$class]) && isset(self::EXTENSIONS[$extension])) {
yield $class => [$class];
}
}
Expand Down

0 comments on commit fd8b9d7

Please sign in to comment.