Skip to content

Use &true; &false; &null; semantically where appropriate - #862

Closed
fulldecent wants to merge 1 commit into
php:masterfrom
fulldecent:semantic-true-false
Closed

Use &true; &false; &null; semantically where appropriate#862
fulldecent wants to merge 1 commit into
php:masterfrom
fulldecent:semantic-true-false

Conversation

@fulldecent

@fulldecent fulldecent commented Aug 18, 2021

Copy link
Copy Markdown
Contributor

This PR is not a result of some automatic find and replace. I have manually reviewed hundreds of files to make these changes.

Format true and false

/ TRUE | FALSE | NULL /i

and ignore any results inside a <![CDATA[ section or where "true"/"false" have meanings other than the boolean types inside PHP.

  • If a true value, use &true;
  • If a false value, use &false;
  • If a null value, use &null;

Why

Improve readability. Make long-term maintenance of translations easier.

Effect on translations

The true, false and null values are semantic and this should help with the long-term maintenance of translations.

Translators will not need to think much about whether true means "真正的布尔值" or "真不变量" when seeing:

  • true color image
  • return value of &true;
  • this invariant is true if X and Y
  • null byte
  • null-terminated

because I have already separated the cases of true and &true;.

Scope creep

  • This PR also fixes two typos of true is to become true if immediately on the lines a was editing.

@fulldecent fulldecent changed the title Use &true; and &false; semantically where appropriate Use &true; &false; &null; semantically where appropriate Aug 18, 2021

@kamil-tekiela kamil-tekiela left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am not against the idea of changing the values. I see the value in it, but I still believe this PR is too big. This is 288 files to carefully be reviewed.
While I understand that you only want to change this single thing, but your PR touches pages that haven't been maintained in a long time. There are very few volunteers who maintain PHP manual in their free time. While doing this change, I feel that we should try to address as many issues as we see on the lines that are being edited. This means that there will be related PRs that will try to fix issues we find (I just submitted one PR). This will make reviewing this PR take a lot longer. Some issues, which are out of the scope of this PR, might even be added to this PR, bloating it even more.

I don't know what other more experienced contributors think, but if you could split this PR into even smaller chunks then it would help with the workload. If not, then please expect this PR to take a while before it is reviewed properly.

<link linkend="object.construct">__construct()</link> and
<link linkend="object.destruct">__destruct()</link> methods of interfaces.
Previously, this would only be true for methods of classes and traits.
Previously, this would only be &true; for methods of classes and traits.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think that was mean to be the word "true", not the constant TRUE.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Disagree. Here is the same text without confusing markup:

... now also return &true; for __construct() and __destruct() methods of interfaces. Previously, this would only be &true; for methods of classes and traits.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe "Previously, this would only be the case for methods of classes and traits." would be better.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have a "more notes" file where I am tracking this specific suggestion.

I hope that the merging of the improvements in these 300 changes I am proposing can continue without requiring the further incremental changes proposed here and below.

We agree that your note is good. We agreed it should be done. I'm noting it. I'll do it. But I don't see anything here which says that that this PR should be considered broken or blocked.

&reftitle.returnvalues;
<para>
Shall return true if this Definition is registered
Shall return &true; if this Definition is registered

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is "shall" the right word here? What is "Definition"? Shouldn't this be the reference to the class name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have a "more notes" file where I am tracking this specific suggestion.

I hope that the merging of the improvements in these 300 changes I am proposing can continue without requiring the further incremental changes proposed here and below.

We agree that your note is good. We agreed it should be done. I'm noting it. I'll do it. But I don't see anything here which says that that this PR should be considered broken or blocked.

Comment thread reference/cubrid/cubridmysql/cubrid-errno.xml Outdated
Comment thread reference/cubrid/cubridmysql/cubrid-error.xml Outdated
@cmb69

cmb69 commented Aug 18, 2021

Copy link
Copy Markdown
Member

I think the decision whether it is good to make this change without any unrelated changes should be made by the translators. @saundefined, @Girgias, @mumumu, what do you think?

@fulldecent

fulldecent commented Aug 18, 2021

Copy link
Copy Markdown
Contributor Author

Thank you for the feedback so far.


I have ambitions to make a lot of changes here. And there is a lot of stuff here that needs changes and other work to do.

My experience is from other large, volunteer-run projects with not enough resources, such as the KDE project of decades ago. I am hoping to make changes and get forward progress here. The best way is if I can prove that I'm not breaking anything and that if something is broken then it is really rare and not hurting anybody, but lost in a sea of other improvements.

Ideally I want to borrow authority to make these changes. If all my changes need to be reviewed by every code owner (living or dead), or if everything I am touching will need to meet more metrics of correctness than are in scope of this a given PR then my efforts will fail.

There are ~300 lines of code changed here. And the best way to review these is using git diff, likely only with one coffee. I really think this specific PR can be approved by one person using common sense without relying on other people to confirm the formatting requirements for the true/false/null values.


My plan is to make this merge and then immediately release the next bite-sized PR from #858. This will overwrite some of the changes made in this PR, but the benefit is that it should be very easy to review and merge and that separate change can be judged on its own merits.

@saundefined

Copy link
Copy Markdown
Member

There are ~300 lines of code changed here. And the best way to review these is using git diff, likely only with one coffee. I really think this specific PR can be approved by one person using common sense without relying on other people to confirm the formatting requirements for the true/false/null values.

Thanks for your hard work!

Many translations now lagging behind the English version (fr 258 files, de — 375),
and I'm afraid that these minor changes will set translations back even further.

You can see the comment for similar minor changes.

I agree that sometime this needs to be done, but I'm not sure if now.

@fulldecent

fulldecent commented Aug 18, 2021

Copy link
Copy Markdown
Contributor Author

Long-term, this change helps make translations easier to manage.

And furthermore, the next change coming after this PR makes translations much easier. It significantly reduces the number of things that need to be translated, for all languages.

Because the translations are already not up-to-date (i.e. short-term), and because this and my next PR will make translations easier to maintain (i.e. long-term), I hope that translations impact are not a blocker for merging this PR.

@fulldecent

Copy link
Copy Markdown
Contributor Author

Previously, this commit was at risk of spamming all the translators with changes on the revcheck dashboard that were useless, because this is a cosmetic change for the English docs that does not require any action from translators.

We have updated and deployed a change to revcheck called [skip-revcheck] (the square brackets ARE significant). Any commit starting with that text will be excluded from the revcheck tool.

This PR uses that feature. In addition I have rebased and squashed.

End result: this is one commit in one PR that changes one thing (formatting of true/false/null) on the English docs and should not have any impact whatsoever on translators.

@salathe salathe added the mahoosive-change Grab a cup of coffee and dive in. label Sep 10, 2021
The <function>cubrid_errno</function> function is used to get the
error code of the error that occurred during the API execution. Usually,
it gets the error code when API returns false as its return value.
it gets the error code when API returns &false;.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit (consistency): as its return value is removed here, but not from the several other places where the same occurs. Your preference is to not include this kind of change in this PR, so I suggest reverting the removal of "as its return value" here.

<listitem>
<simpara>
Use NULL instead of FALSE on failure.
Use NULL instead of &false; on failure.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Use NULL instead of &false; on failure.
Use &null; instead of &false; on failure.

from the server. The callback is passed the Memcached object, the requested
key, and the by-reference value variable. The callback is responsible for
setting the value and returning true or false. If the callback returns true,
setting the value and returning &true; or false. If the callback returns true,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
setting the value and returning &true; or false. If the callback returns true,
setting the value and returning &true; or &false;. If the callback returns &true;,

&reftitle.returnvalues;
<para>
Returns TRUE if the offset exists, otherwise FALSE.
Returns &true; if the offset exists, otherwise FALSE.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Returns &true; if the offset exists, otherwise FALSE.
Returns &true; if the offset exists, otherwise &false;.

&reftitle.returnvalues;
<para>
Returns TRUE if the current iterator position is valid, otherwise FALSE.
Returns &true; if the current iterator position is valid, otherwise FALSE.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Returns &true; if the current iterator position is valid, otherwise FALSE.
Returns &true; if the current iterator position is valid, otherwise &false;.

@@ -32,7 +32,7 @@
<listitem>
<para>
Callback function to invoke when the device is idle. Returning false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Callback function to invoke when the device is idle. Returning false
Callback function to invoke when the device is idle. Returning &false;

@@ -32,7 +32,7 @@
<listitem>
<para>
Callback function to invoke when the device is idle. Returning false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Callback function to invoke when the device is idle. Returning false
Callback function to invoke when the device is idle. Returning &false;

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>Returns an array with calculated data or false on failure.</para>
<para>Returns an array with calculated data or &false; on failure.</para>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This text is repeated over 150 times for other trader functions. Suggestion (not in this PR): make it an entity in language-snippets.ent. Note: doing so will break builds for any translations that have not translated the file and not added the entity.

@kamil-tekiela kamil-tekiela left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have been reviewing for an hour and I am only 1/3 of the way through.

from the server. The callback is passed the Memcached object, the requested
key, and the by-reference value variable. The callback is responsible for
setting the value and returning true or false. If the callback returns true,
setting the value and returning &true; or false. If the callback returns true,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
setting the value and returning &true; or false. If the callback returns true,
setting the value and returning &true; or &false;. If the callback returns &true;,

<listitem>
<para>
<code>required</code>: bool, (optional) true if the field is required to exist in the document.
<code>required</code>: bool, (optional) &true; if the field is required to exist in the document.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
<code>required</code>: bool, (optional) &true; if the field is required to exist in the document.
<code>required</code>: &boolean;, (optional) &true; if the field is required to exist in the document.

<term><parameter>destroy</parameter></term>
<listitem>
<para>When true pthreads will destroy the Mutex after a successful unlock.</para>
<para>When &true; pthreads will destroy the Mutex after a successful unlock.</para>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
<para>When &true; pthreads will destroy the Mutex after a successful unlock.</para>
<para>When &true;, pthreads will destroy the Mutex after a successful unlock.</para>

</para>
<para>
$allowDups = false is the same as $overwrite = true
$allowDups = &false; is the same as $overwrite = &true;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be rewritten to use parameter names (separate PR). Don't change this now.

&reftitle.returnvalues;
<para>
Returns a string on success and null if there is nothing to return.
Returns a string on success and &null; if there is nothing to return.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Returns a string on success and &null; if there is nothing to return.
Returns a string on success or &null; if there is nothing to return.

It doesn't return both values at the same time.

&warn.undocumented.func;
<para>
Deletes a file or a directory, return true if all is ok, false otherwise
Deletes a file or a directory, return &true; if all is ok, &false; otherwise

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Deletes a file or a directory, return &true; if all is ok, &false; otherwise
Deletes a file or a directory, returns &true; if all is ok, &false; otherwise

<refnamediv>
<refname>svn_fs_delete</refname>
<refpurpose>Deletes a file or a directory, return true if all is ok, false otherwise</refpurpose>
<refpurpose>Deletes a file or a directory, return &true; if all is ok, &false; otherwise</refpurpose>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
<refpurpose>Deletes a file or a directory, return &true; if all is ok, &false; otherwise</refpurpose>
<refpurpose>Deletes a file or a directory, returns &true; if all is ok, &false; otherwise</refpurpose>

</methodsynopsis>
<para>
If $remove is set to be true and $offset is set to be 0, the data will be removed from the buffer.
If $remove is set to be &true; and $offset is set to be 0, the data will be removed from the buffer.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For future PR: parameter names should be using <parameter> tags instead of PHP syntax.

@salathe

salathe commented Sep 10, 2021

Copy link
Copy Markdown
Contributor

TL;DR – I am vetoing this change.


What bothers me most about this particular PR, is that many (most?) of the changes will be changed again soon, based on the plan in the parent PR #858. Further changes, such as adding lots and lots of &return.falseforfailure;, adding an entity for the 150+ identical return values for the trader functions, etc.. Even if this PR is applied, there will be further sweeping changes requested to the same lines changed in this PR.

I also do not share the author's view point that this PR "should not have any impact whatsoever on translators". Impacting translators is spelled out as the main point of this PR. Translators are expected to pick up the changes in this PR (and all changes coming from the parent PR), otherwise what is the point? To that end, the use of the [skip-revcheck] tag in the commit message is inappropriate.

Because of the above, and the comments from other authors and translators in this PR and the parent PR that I won't repeat here, I don't think it is worth our (the author, reviewers, translators) while to continue with this PR.

Where to go from here? The experiment failed. @fulldecent and interested parties, let us regroup (in the parent PR, or a new Issue perhaps) and consider alternative directions to approach this from.

@salathe salathe closed this Sep 10, 2021
@kamil-tekiela kamil-tekiela mentioned this pull request Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mahoosive-change Grab a cup of coffee and dive in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants