Skip to content

Commit fd8b9d7

Browse files
committed
Refactoring
1 parent 96025aa commit fd8b9d7

File tree

1 file changed

+91
-21
lines changed

1 file changed

+91
-21
lines changed

tests/Internal/NativeAdapter/ClassFixtures.php

Lines changed: 91 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,94 @@
66

77
final class ClassFixtures
88
{
9+
private const EXTENSIONS = [
10+
'bcmath' => true,
11+
'bz2' => true,
12+
'calendar' => true,
13+
'Core' => true,
14+
'ctype' => true,
15+
'curl' => true,
16+
'date' => true,
17+
'dba' => true,
18+
'dom' => true,
19+
'exif' => true,
20+
'FFI' => true,
21+
'fileinfo' => true,
22+
'filter' => true,
23+
'ftp' => true,
24+
'gd' => true,
25+
'gettext' => true,
26+
'gmp' => true,
27+
'hash' => true,
28+
'iconv' => true,
29+
'intl' => true,
30+
'json' => true,
31+
'ldap' => true,
32+
'libxml' => true,
33+
'mbstring' => true,
34+
'mysqli' => true,
35+
'mysqlnd' => true,
36+
'odbc' => true,
37+
'openssl' => true,
38+
'pcntl' => true,
39+
'pcov' => true,
40+
'pcre' => true,
41+
'PDO' => true,
42+
'pdo_dblib' => true,
43+
'pdo_mysql' => true,
44+
'PDO_ODBC' => true,
45+
'pdo_pgsql' => true,
46+
'pdo_sqlite' => true,
47+
'pgsql' => true,
48+
'Phar' => true,
49+
'posix' => true,
50+
'pspell' => true,
51+
'random' => true,
52+
'readline' => true,
53+
'Reflection' => true,
54+
'session' => true,
55+
'shmop' => true,
56+
'SimpleXML' => true,
57+
'soap' => true,
58+
'sockets' => true,
59+
'sodium' => true,
60+
'SPL' => true,
61+
'sqlite3' => true,
62+
'standard' => true,
63+
'sysvmsg' => true,
64+
'sysvsem' => true,
65+
'sysvshm' => true,
66+
'tidy' => true,
67+
'tokenizer' => true,
68+
'xml' => true,
69+
'xmlreader' => true,
70+
'xmlwriter' => true,
71+
'xsl' => true,
72+
'Zend OPcache' => true,
73+
'zip' => true,
74+
'zlib' => true,
75+
];
76+
private const INTERNAL_CLASSES_TO_SKIP = [
77+
// has a private constructor that is available only via ReflectionClass::getConstructor()
78+
'IntlCodePointBreakIterator' => true,
79+
// ReflectionClass::getModifiers() returns 0 instead of 32 (enums have IS_FINAL)
80+
'Random\IntervalBoundary' => true,
81+
// is iterable, but does not implement Traversable
82+
'FFI\CData' => true,
83+
// has a lot of problems with __invoke()
84+
'Closure' => true,
85+
// getMethod(ispersistent).getNumberOfRequiredParameters(): failed asserting that 0 is identical to 2
86+
'ZMQContext' => true,
87+
// getMethod(remove).getNumberOfRequiredParameters(): failed asserting that 1 is identical to 2
88+
'ZMQPoll' => true,
89+
// Fatal error: OAuthProvider::__construct(): For the CLI sapi parameters must be set first via OAuthProvider::__construct(array("oauth_param" => "value", ...))
90+
'OAuthProvider' => true,
91+
// problems with readonly properties
92+
'AMQPTimestamp' => true,
93+
// problems with readonly properties
94+
'AMQPDecimal' => true,
95+
];
96+
997
private function __construct() {}
1098

1199
/**
@@ -41,35 +129,17 @@ public static function get(): array
41129

42130
return self::$classes;
43131
}
44-
private const INTERNAL_CLASSES_TO_SKIP = [
45-
// has a private constructor that is available only via ReflectionClass::getConstructor()
46-
'IntlCodePointBreakIterator' => true,
47-
// ReflectionClass::getModifiers() returns 0 instead of 32 (enums have IS_FINAL)
48-
'Random\IntervalBoundary' => true,
49-
// is iterable, but does not implement Traversable
50-
'FFI\CData' => true,
51-
// has a lot of problems with __invoke()
52-
'Closure' => true,
53-
// getMethod(ispersistent).getNumberOfRequiredParameters(): failed asserting that 0 is identical to 2
54-
'ZMQContext' => true,
55-
// getMethod(remove).getNumberOfRequiredParameters(): failed asserting that 1 is identical to 2
56-
'ZMQPoll' => true,
57-
// Fatal error: OAuthProvider::__construct(): For the CLI sapi parameters must be set first via OAuthProvider::__construct(array("oauth_param" => "value", ...))
58-
'OAuthProvider' => true,
59-
// problems with readonly properties
60-
'AMQPTimestamp' => true,
61-
// problems with readonly properties
62-
'AMQPDecimal' => true,
63-
];
64132

65133
/**
66134
* @return \Generator<class-string, array{class-string}>
67135
*/
68136
public static function internal(): \Generator
69137
{
70138
foreach (self::allDeclaredClasses() as $class) {
139+
$extension = (new \ReflectionClass($class))->getExtensionName();
140+
71141
/** @psalm-suppress InvalidArrayOffset */
72-
if (!isset(self::INTERNAL_CLASSES_TO_SKIP[$class]) && (new \ReflectionClass($class))->isInternal()) {
142+
if ($extension !== false && !isset(self::INTERNAL_CLASSES_TO_SKIP[$class]) && isset(self::EXTENSIONS[$extension])) {
73143
yield $class => [$class];
74144
}
75145
}

0 commit comments

Comments
 (0)