Skip to content

Commit b2575ca

Browse files
committed
Warn when a class synopsis page doesn't exist
1 parent e733ebf commit b2575ca

13 files changed

+51
-14
lines changed

Zend/zend_builtin_functions.stub.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
/** @generate-class-entries */
44

5+
/** @undocumentable */
56
#[\AllowDynamicProperties]
67
class stdClass
78
{

Zend/zend_builtin_functions_arginfo.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/gen_stub.php

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2453,6 +2453,8 @@ class ClassInfo {
24532453
public $cond;
24542454
/** @var int|null */
24552455
public $phpVersionIdMinimumCompatibility;
2456+
/** @var bool */
2457+
public $isUndocumentable;
24562458

24572459
/**
24582460
* @param AttributeInfo[] $attributes
@@ -2480,7 +2482,8 @@ public function __construct(
24802482
array $funcInfos,
24812483
array $enumCaseInfos,
24822484
?string $cond,
2483-
?int $minimumPhpVersionIdCompatibility
2485+
?int $minimumPhpVersionIdCompatibility,
2486+
bool $isUndocumentable
24842487
) {
24852488
$this->name = $name;
24862489
$this->flags = $flags;
@@ -2499,6 +2502,7 @@ public function __construct(
24992502
$this->enumCaseInfos = $enumCaseInfos;
25002503
$this->cond = $cond;
25012504
$this->phpVersionIdMinimumCompatibility = $minimumPhpVersionIdCompatibility;
2505+
$this->isUndocumentable = $isUndocumentable;
25022506
}
25032507

25042508
/**
@@ -3088,6 +3092,8 @@ class FileInfo {
30883092
public $generateLegacyArginfoForPhpVersionId;
30893093
/** @var bool */
30903094
public $generateClassEntries = false;
3095+
/** @var bool */
3096+
public $isUndocumentable = false;
30913097

30923098
/**
30933099
* @return iterable<FuncInfo>
@@ -3499,7 +3505,8 @@ function parseClass(
34993505
array $methods,
35003506
array $enumCases,
35013507
?string $cond,
3502-
?int $minimumPhpVersionIdCompatibility
3508+
?int $minimumPhpVersionIdCompatibility,
3509+
bool $isUndocumentable
35033510
): ClassInfo {
35043511
$flags = $class instanceof Class_ ? $class->flags : 0;
35053512
$comment = $class->getDocComment();
@@ -3521,6 +3528,8 @@ function parseClass(
35213528
$isStrictProperties = true;
35223529
} else if ($tag->name === 'not-serializable') {
35233530
$isNotSerializable = true;
3531+
} else if ($tag->name === 'undocumentable') {
3532+
$isUndocumentable = true;
35243533
}
35253534
}
35263535
}
@@ -3579,7 +3588,8 @@ function parseClass(
35793588
$methods,
35803589
$enumCases,
35813590
$cond,
3582-
$minimumPhpVersionIdCompatibility
3591+
$minimumPhpVersionIdCompatibility,
3592+
$isUndocumentable
35833593
);
35843594
}
35853595

@@ -3732,7 +3742,7 @@ function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstrac
37323742
}
37333743

37343744
$fileInfo->classInfos[] = parseClass(
3735-
$className, $stmt, $constInfos, $propertyInfos, $methodInfos, $enumCaseInfos, $cond, $fileInfo->generateLegacyArginfoForPhpVersionId
3745+
$className, $stmt, $constInfos, $propertyInfos, $methodInfos, $enumCaseInfos, $cond, $fileInfo->generateLegacyArginfoForPhpVersionId, $fileInfo->isUndocumentable
37363746
);
37373747
continue;
37383748
}
@@ -3783,6 +3793,8 @@ protected function pName_FullyQualified(Name\FullyQualified $node) {
37833793
} else if ($tag->name === 'generate-class-entries') {
37843794
$fileInfo->generateClassEntries = true;
37853795
$fileInfo->declarationPrefix = $tag->value ? $tag->value . " " : "";
3796+
} else if ($tag->name === 'undocumentable') {
3797+
$fileInfo->isUndocumentable = true;
37863798
}
37873799
}
37883800
}
@@ -4219,12 +4231,14 @@ function generateClassSynopses(array $classMap, iterable $allConstInfos): array
42194231
}
42204232

42214233
/**
4222-
* @param ClassInfo[] $classMap
4234+
* @param array<string, ClassInfo> $classMap
42234235
* $param iterable<ConstInfo> $allConstInfos
42244236
* @return array<string, string>
42254237
*/
42264238
function replaceClassSynopses(string $targetDirectory, array $classMap, iterable $allConstInfos): array
42274239
{
4240+
$existingClassSynopses = [];
4241+
42284242
$classSynopses = [];
42294243

42304244
$it = new RecursiveIteratorIterator(
@@ -4281,6 +4295,9 @@ function replaceClassSynopses(string $targetDirectory, array $classMap, iterable
42814295
if (!isset($classMap[$className])) {
42824296
continue;
42834297
}
4298+
4299+
$existingClassSynopses[$className] = $className;
4300+
42844301
$classInfo = $classMap[$className];
42854302

42864303
$newClassSynopsis = $classInfo->getClassSynopsisElement($doc, $classMap, $allConstInfos);
@@ -4320,6 +4337,14 @@ function replaceClassSynopses(string $targetDirectory, array $classMap, iterable
43204337
}
43214338
}
43224339

4340+
$missingClassSynopses = array_diff_key($classMap, $existingClassSynopses);
4341+
foreach ($missingClassSynopses as $className => $info) {
4342+
/** @var ClassInfo $info */
4343+
if (!$info->isUndocumentable) {
4344+
echo "Warning: Missing class synopsis page for $className\n";
4345+
}
4346+
}
4347+
43234348
return $classSynopses;
43244349
}
43254350

ext/pdo_pgsql/pgsql_driver.stub.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
/** @generate-function-entries */
44

5-
// These are extension methods for PDO. This is not a real class.
5+
/**
6+
* These are extension methods for PDO. This is not a real class.
7+
* @undocumentable
8+
*/
69
class PDO_PGSql_Ext {
710
/** @tentative-return-type */
811
public function pgsqlCopyFromArray(string $tableName, array $rows, string $separator = "\t", string $nullAs = "\\\\N", ?string $fields = null): bool {}

ext/pdo_pgsql/pgsql_driver_arginfo.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/pdo_sqlite/sqlite_driver.stub.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
/** @generate-function-entries */
44

5-
// These are extension methods for PDO. This is not a real class.
5+
/**
6+
* These are extension methods for PDO. This is not a real class.
7+
* @undocumentable
8+
*/
69
class PDO_SQLite_Ext {
710
/** @tentative-return-type */
811
public function sqliteCreateFunction(string $name, callable $callback, int $numArgs = -1, int $flags = 0): bool {}

ext/pdo_sqlite/sqlite_driver_arginfo.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/standard/basic_functions.stub.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,7 @@
740740
const LOG_PERROR = UNKNOWN;
741741
#endif
742742

743+
/** @undocumentable */
743744
#[AllowDynamicProperties]
744745
final class __PHP_Incomplete_Class
745746
{

ext/standard/basic_functions_arginfo.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/zend_test/fiber.stub.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?php
22

3-
/** @generate-class-entries static */
3+
/**
4+
* @generate-class-entries static
5+
* @undocumentable
6+
*/
47

58
final class _ZendTestFiber
69
{

ext/zend_test/fiber_arginfo.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/zend_test/test.stub.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/**
44
* @generate-class-entries static
55
* @generate-legacy-arginfo 80000
6+
* @undocumentable
67
*/
78
namespace {
89
/**

ext/zend_test/test_arginfo.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)