Skip to content

PHP 8.4: Document StreamBucket #4297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 20, 2024
Merged

PHP 8.4: Document StreamBucket #4297

merged 5 commits into from
Dec 20, 2024

Conversation

kocsismate
Copy link
Member

Adding docs for the StreamBucket class.

Comment on lines 56 to 66
<varlistentry>
<term>
<property>dataLength</property>
(<type>int</type>)
</term>
<listitem>
<para>
<parameter>dataLength</parameter> <literal>bucket</literal> The length of the string in the bucket.
</para>
</listitem>
</varlistentry>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just remove the property description now? I would rather have something along the lines of:

Prior to PHP 8.4.0, an stdClass containing the same properties as StreamBucket was returned.

Then duplicating documentation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scream-shot from the current docs:

bucket

What is the meaning of data(len) bucket there? This looks like pure noise.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good point! I wasn't sure if we want to keep these docs or not, so I left it there. But I agree, these are just noise after adding the StreamBucket page.

Comment on lines 89 to 96
<para>
<simplelist>
<member><function>stream_bucket_new</function></member>
<member><function>stream_bucket_append</function></member>
<member><function>stream_bucket_prepend</function></member>
<member><function>stream_bucket_make_writeable</function></member>
</simplelist>
</para>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No useless wrapping para tags

Suggested change
<para>
<simplelist>
<member><function>stream_bucket_new</function></member>
<member><function>stream_bucket_append</function></member>
<member><function>stream_bucket_prepend</function></member>
<member><function>stream_bucket_make_writeable</function></member>
</simplelist>
</para>
<simplelist>
<member><function>stream_bucket_new</function></member>
<member><function>stream_bucket_append</function></member>
<member><function>stream_bucket_prepend</function></member>
<member><function>stream_bucket_make_writeable</function></member>
</simplelist>

Comment on lines 87 to 88
<section role="seealso">
&reftitle.seealso;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent is off

<varlistentry xml:id="streambucket.props.bucket">
<term>resource <varname>bucket</varname></term>
<listitem>
<para>A <literal>userfilter.bucket</literal> resource.</para>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use simpara now, and use new lines for the descriptions. Apply for the other properties.

Suggested change
<para>A <literal>userfilter.bucket</literal> resource.</para>
<simpara>
A <literal>userfilter.bucket</literal> resource.
</simpara>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between the two?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Roughly, simpara is like a HTML p while para is more like a div.

Comment on lines 12 to 14
<para>
A stream bucket is a chunk of stream which can be extracted from bucket brigades.
</para>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<para>
A stream bucket is a chunk of stream which can be extracted from bucket brigades.
</para>
<simpara>
A stream bucket is a chunk of stream which can be extracted from bucket brigades.
</simpara>

Comment on lines 83 to 104
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.4.0</entry>
<entry>
This function returns a <classname>StreamBucket</classname> instance now;
previously, an <classname>stdClass</classname> was returned.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like the changelogs could just XInclude the one from stream_bucket_append() to prevent duplication.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I'm not sure it's worth the effort for only two places to include. 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Xincluding is not really more difficult than copy pasting.

@Girgias Girgias changed the title Synchronize manual with stubs for PHP 8.4 - part 10 PHP 8.4: Document StreamBucket Dec 12, 2024
@Girgias Girgias added this to the PHP 8.4 milestone Dec 12, 2024
Comment on lines 56 to 66
<varlistentry>
<term>
<property>dataLength</property>
(<type>int</type>)
</term>
<listitem>
<para>
<parameter>dataLength</parameter> <literal>bucket</literal> The length of the string in the bucket.
</para>
</listitem>
</varlistentry>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scream-shot from the current docs:

bucket

What is the meaning of data(len) bucket there? This looks like pure noise.

kocsismate and others added 3 commits December 12, 2024 22:34
</listitem>
</varlistentry>
</variablelist>
Returns a bucket object or &null;.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does it return null actually?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I managed to understand https://github.com/php/php-src/blob/d6d78545ea405e89a44445a9a32d77a75fd8bb6b/ext/standard/user_filters.c#L356, it returns null if the brigade is empty (?). The 2nd part of the condition seems to be always non-null (bucket variable).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, at least under ZendMM, php_stream_bucket_make_writeable() cannot return NULL; that code is from 2003; maybe we should move the php_stream_bucket_make_writeable() inside the if-branch.

Anyhow, reading the manual helps understanding the implementation. E.g. the info on https://www.php.net/manual/en/function.stream-bucket-append.php explains everything; and https://www.php.net/manual/en/function.stream-bucket-make-writeable.php (emphasis mine):

This function is called whenever there is the need to access and operate on the content contains in a brigade.

is also quite entertaining. ;)

Might not make sense to try to figure out this particular return value meaning for now.

@kocsismate
Copy link
Member Author

@Girgias Is there anything else I should fix in order to merge this?

@Girgias Girgias merged commit 32caa89 into php:master Dec 20, 2024
2 checks passed
@kocsismate kocsismate deleted the php84-sync-10 branch December 20, 2024 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants