@@ -138,15 +138,6 @@ using the ``@prefer-ref`` PHPDoc tag:
138
138
*/
139
139
function foo(& $param1, string $param2): string {}
140
140
141
- This is going to yield the following arginfo structure:
142
-
143
- .. code :: c
144
-
145
- ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_foo, 0, 2, IS_STRING, 0)
146
- ZEND_ARG_INFO(1, param1)
147
- ZEND_ARG_TYPE_INFO(ZEND_SEND_PREFER_REF, param2, IS_STRING, 0)
148
- ZEND_END_ARG_INFO()
149
-
150
141
*****************************
151
142
Generating function entries
152
143
*****************************
@@ -260,17 +251,7 @@ The following arginfo file is generated:
260
251
{
261
252
zend_class_entry *class_entry = zend_register_internal_enum("Number", IS_STRING, class_Number_methods);
262
253
263
- zval const_ONE_value;
264
- zend_string *const_ONE_value_str = zend_string_init("one", strlen("one"), 1);
265
- ZVAL_STR(&const_ONE_value, const_ONE_value_str);
266
- zend_string *const_ONE_name = zend_string_init_interned("ONE", sizeof("ONE") - 1, 1);
267
- zend_declare_class_constant_ex(class_entry, const_ONE_name, &const_ONE_value, ZEND_ACC_PUBLIC, NULL);
268
- zend_string_release(const_ONE_name);
269
-
270
- zval enum_case_One_value;
271
- zend_string *enum_case_One_value_str = zend_string_init("one", strlen("one"), 1);
272
- ZVAL_STR(&enum_case_One_value, enum_case_One_value_str);
273
- zend_enum_add_case_cstr(class_entry, "One", &enum_case_One_value);
254
+ /* ... */
274
255
275
256
return class_entry;
276
257
}
@@ -279,20 +260,7 @@ The following arginfo file is generated:
279
260
{
280
261
zend_class_entry ce, *class_entry;
281
262
282
- INIT_CLASS_ENTRY(ce, "Foo", class_Foo_methods);
283
- class_entry = zend_register_internal_class_ex(&ce, NULL);
284
-
285
- zval const_PI_value;
286
- ZVAL_DOUBLE(&const_PI_value, M_PI);
287
- zend_string *const_PI_name = zend_string_init_interned("PI", sizeof("PI") - 1, 1);
288
- zend_declare_typed_class_constant(class_entry, const_PI_name, &const_PI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_DOUBLE));
289
- zend_string_release(const_PI_name);
290
-
291
- zval property_prop_default_value;
292
- ZVAL_UNDEF(&property_prop_default_value);
293
- zend_string *property_prop_name = zend_string_init("prop", sizeof("prop") - 1, 1);
294
- zend_declare_typed_property(class_entry, property_prop_name, &property_prop_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING));
295
- zend_string_release(property_prop_name);
263
+ /* ... */
296
264
297
265
return class_entry;
298
266
}
@@ -357,10 +325,7 @@ attribute:
357
325
358
326
static void register_example_symbols(int module_number)
359
327
{
360
- REGISTER_STRING_CONSTANT("FOO", "foo", CONST_PERSISTENT);
361
- REGISTER_DOUBLE_CONSTANT("BAR", M_PI, CONST_PERSISTENT);
362
-
363
- zend_add_parameter_attribute(zend_hash_str_find_ptr(CG(function_table), "foo", sizeof("foo") - 1), 0, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0);
328
+ /* ... */
364
329
}
365
330
366
331
Similarly to class registration functions, ``register_example_symbols() `` also has to be called
@@ -444,23 +409,12 @@ Then notice the ``#if (PHP_VERSION_ID >= ...)`` conditions in the generated argi
444
409
445
410
.. code :: c
446
411
447
- static const zend_function_entry class_Number_methods[] = {
448
- ZEND_FE_END
449
- };
450
-
451
- static const zend_function_entry class_Foo_methods[] = {
452
- ZEND_ME(Foo, foo, arginfo_class_Foo_foo, ZEND_ACC_PUBLIC)
453
- ZEND_FE_END
454
- };
412
+ /* ... */
455
413
456
414
#if (PHP_VERSION_ID >= 80100)
457
415
static zend_class_entry *register_class_Number(void)
458
416
{
459
- zend_class_entry *class_entry = zend_register_internal_enum("Number", IS_UNDEF, class_Number_methods);
460
-
461
- zend_enum_add_case_cstr(class_entry, "One", NULL);
462
-
463
- return class_entry;
417
+ /* ... */
464
418
}
465
419
#endif
466
420
@@ -484,7 +438,7 @@ Then notice the ``#if (PHP_VERSION_ID >= ...)`` conditions in the generated argi
484
438
return class_entry;
485
439
}
486
440
487
- The prepocessor conditions are necessary because ``enum``s and ``readonly `` properties are PHP 8.1
441
+ The preprocessor conditions are necessary because ``enum``s and ``readonly `` properties are PHP 8.1
488
442
features and consequently, they don't exist in PHP 8.0. Therefore, the registration of ``Number `` is
489
443
completely omitted, while the ``readonly `` flag is not added for ``Foo::$prop `` below PHP 8.1
490
444
versions.
@@ -496,8 +450,8 @@ versions.
496
450
A list of functions is maintained for the optimizer in ``Zend/Optimizer/zend_func_infos.h ``
497
451
containing extra information about the return type and the cardinality of the return value. These
498
452
pieces of information can enable more accurate optimizations (i.e. better type inference).
499
- Previously, the file was maintained manually, however since PHP 8.1, ``gen_stub.php `` takes care of
500
- this task by passing the ``--generate-optimizer-info `` option.
453
+ Previously, the file was maintained manually, however since PHP 8.1, ``gen_stub.php `` can take care
454
+ of this task when the ``--generate-optimizer-info `` option is passed to it .
501
455
502
456
A function is added to ``zend_func_infos.h `` if either the ``@return `` or the ``@refcount `` PHPDoc
503
457
tag supplies more information than what is available based on the return type declaration. By
@@ -514,12 +468,6 @@ An example from the built-in functions:
514
468
*/
515
469
function get_declared_classes(): array {}
516
470
517
- Based on which the following func info entry is provided for the optimizer:
518
-
519
- .. code :: c
520
-
521
- F1("get_declared_classes", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
522
-
523
471
Please note that the feature is only available for built-in stubs inside php-src, since currently
524
472
there is no way to provide the function list for the optimizer other than overwriting
525
473
``zend_func_infos.h `` directly.
@@ -596,27 +544,28 @@ the 3-parameter signatures:
596
544
597
545
Theoretically, the manual should reflect the exact same signatures which are represented by the
598
546
stubs. This is not exactly the case yet for built-in symbols, but ``gen_stub.php `` have multiple
599
- features to automate the process of syncronization .
547
+ features to automate the process of synchronization .
600
548
601
549
First of all, newly added functions or methods can be documented by providing the
602
550
``--generate-methodsynopses `` option. E.g. running ``./build/gen_stub.php --generate-methodsynopses
603
551
./ext/mbstring ../doc-en/reference/mbstring `` will create a dedicated page for each ``ext/mbstring ``
604
552
function which is not yet documented, saving them into the
605
- ``../doc-en/reference/mbstring/functions `` directory. Since the generated pages are stubs, the
606
- relevant descriptions have to be added, while the irrelevant ones have to be removed.
553
+ ``../doc-en/reference/mbstring/functions `` directory. Since these are stub pages, many of the
554
+ sections are empty by default, so the relevant descriptions have to be added, while the irrelevant
555
+ ones have to be removed.
607
556
608
557
For functions or methods which are already available in the manual, the documented signatures can be
609
558
updated by providing the ``--replace-methodsynopses `` option. E.g. running ``./build/gen_stub.php
610
559
--replace-methodsynopses ./ ../doc-en/ `` will update all the function or method signatures in the
611
560
English documentation whose stub counterpart is found.
612
561
613
- Class signatures can be updated by providing the ``--replace-classsynopses `` option. E.g. running
614
- ``./build/gen_stub.php --replace-classsynopses ./ ../doc-en/ `` will update all the class signatures
615
- in the English documentation whose stub counterpart is found.
562
+ Class signatures can be updated in the manual by providing the ``--replace-classsynopses `` option.
563
+ E.g. running ``./build/gen_stub.php --replace-classsynopses ./ ../doc-en/ `` will update all the
564
+ class signatures in the English documentation whose stub counterpart is found.
616
565
617
566
If a symbol is not intended to be documented, the ``@undocumentable `` PHPDoc tag should be added to
618
567
it. Doing so will prevent any documentation to be created for the given symbol. In order not to add
619
- a whole stub file not to the manual, the PHPDoc tag should be applied to the file itself. These
568
+ a whole stub file to the manual, the PHPDoc tag should be applied to the file itself. These
620
569
possibilities are useful for symbols which exist only for testing purposes (e.g. the ones declared
621
570
for ``ext/zend_test ``), or by some other reason documentation is not possible.
622
571
0 commit comments