From 5b34d26eea8ad8345e14e0ff48d6492b9ce89595 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 7 Aug 2026 12:54:58 +0100 Subject: [PATCH 1/3] Fix grammar in language/types --- language/types/array.xml | 4 +- language/types/callable.xml | 4 +- language/types/declarations.xml | 9 ++-- language/types/float.xml | 28 ++++++------ language/types/integer.xml | 9 ++-- language/types/iterable.xml | 4 +- language/types/mixed.xml | 4 +- language/types/never.xml | 4 +- language/types/null.xml | 2 +- language/types/numeric-strings.xml | 10 ++--- language/types/object.xml | 4 +- language/types/relative-class-types.xml | 2 +- language/types/resource.xml | 2 +- language/types/singleton.xml | 2 +- language/types/string.xml | 58 +++++++++++++------------ language/types/type-juggling.xml | 36 +++++++-------- language/types/type-system.xml | 8 ++-- language/types/void.xml | 4 +- 18 files changed, 99 insertions(+), 95 deletions(-) diff --git a/language/types/array.xml b/language/types/array.xml index a81ce3188f44..1ea26f2e0b01 100644 --- a/language/types/array.xml +++ b/language/types/array.xml @@ -483,7 +483,7 @@ $arr[] = value; also an alternative way to create an array. This practice is however discouraged because if $arr already contains some value (e.g. string from request variable) then this - value will stay in the place and [] may actually stand + value will stay in place and [] may actually stand for string access operator. It is always better to initialize a variable by a direct assignment. @@ -1056,7 +1056,7 @@ $error_descriptions[8] = "This is just an informal notice"; If an object is converted to an array, the result is an array whose elements are the object's properties. The keys are the member variable names, with a few notable - exceptions: integer properties are unaccessible; + exceptions: integer properties are inaccessible; private variables have the class name prepended to the variable name; protected variables have a '*' prepended to the variable name. These prepended values have NUL bytes on either side. diff --git a/language/types/callable.xml b/language/types/callable.xml index 71df364a1bcb..a5530d55bf5d 100644 --- a/language/types/callable.xml +++ b/language/types/callable.xml @@ -142,7 +142,7 @@ print implode(' ', $new_numbers); Static class methods can be used without instantiating an - object of that class by either, creating an array with + object of that class by either creating an array with the class name at index 0 and the method name at index 1, or by using the special syntax with the scope resolution operator ::, as in 'ClassName::methodName'. @@ -196,7 +196,7 @@ print implode(' ', $new_numbers); - Calling various types of callables with <function>call_user_function</function> + Calling various types of callables with <function>call_user_func</function> Every single type that PHP supports, with the exception of - resource can be used within a user-land type declaration. + resource, can be used within a user-land type declaration. This page contains a changelog of availability of the different types and documentation about usage of them in type declarations. @@ -137,7 +137,7 @@ Atomic Types Usage Notes - Atomic types have straight forward behaviour with some minor caveats which + Atomic types have straightforward behaviour with some minor caveats which are described in this section. @@ -219,7 +219,8 @@ function &test(): void {} If a pass-by-reference parameter has a type declaration, the type of the variable is only checked on function entry, at the beginning of the call, but not when the function returns. - This means that a function can change the type of variable reference. + This means that a function can change the type of the variable + passed by reference. Typed pass-by-reference Parameters @@ -307,7 +308,7 @@ Stack trace: It is also possible to achieve nullable arguments by making &null; the default value. - This is not recommended as if the default value is changed in a child + This is not recommended because if the default value is changed in a child class a type compatibility violation will be raised as the null type will need to be added to the type declaration. This behavior is also deprecated since PHP 8.4. diff --git a/language/types/float.xml b/language/types/float.xml index 2abe101d3729..aa01d89c8558 100644 --- a/language/types/float.xml +++ b/language/types/float.xml @@ -1,10 +1,10 @@ - Floating point numbers + Floating-point numbers - Floating point numbers (also known as "floats", "doubles", or "real numbers") + Floating-point numbers (also known as "floats", "doubles", or "real numbers") can be specified using any of the following syntaxes: @@ -42,22 +42,22 @@ EXPONENT_DNUM (({LNUM} | {DNUM}) [eE][+-]? {LNUM}) - Floating point precision + Floating-point precision - Floating point numbers have limited precision. Although it depends on the + Floating-point numbers have limited precision. Although it depends on the system, PHP typically uses the IEEE 754 double precision format, which will give a maximum relative error due to rounding in the order of 1.11e-16. - Non elementary arithmetic operations may give larger errors, and, of course, + Non-elementary arithmetic operations may give larger errors, and, of course, error propagation must be considered when several operations are compounded. - Additionally, rational numbers that are exactly representable as floating - point numbers in base 10, like 0.1 or - 0.7, do not have an exact representation as floating - point numbers in base 2, which is used internally, no matter the size of + Additionally, rational numbers that are exactly representable as floating-point + numbers in base 10, like 0.1 or + 0.7, do not have an exact representation as floating-point + numbers in base 2, which is used internally, no matter the size of the mantissa. Hence, they cannot be converted into their internal binary counterparts without a small loss of precision. This can lead to confusing results: for example, floor((0.1+0.7)*10) will usually @@ -67,8 +67,8 @@ EXPONENT_DNUM (({LNUM} | {DNUM}) [eE][+-]? {LNUM}) - So never trust floating number results to the last digit, and do not compare - floating point numbers directly for equality. If higher precision is + So never trust floating-point number results to the last digit, and do not compare + floating-point numbers directly for equality. If higher precision is necessary, the arbitrary precision math functions and gmp functions are available. @@ -118,14 +118,14 @@ EXPONENT_DNUM (({LNUM} | {DNUM}) [eE][+-]? {LNUM}) Comparing floats - As noted in the warning above, testing floating point values for equality is + As noted in the warning above, testing floating-point values for equality is problematic, due to the way that they are represented internally. However, - there are ways to make comparisons of floating point values that work around + there are ways to make comparisons of floating-point values that work around these limitations. - To test floating point values for equality, an upper bound on the relative + To test floating-point values for equality, an upper bound on the relative error due to rounding is used. This value is known as the machine epsilon, or unit roundoff, and is the smallest acceptable difference in calculations. diff --git a/language/types/integer.xml b/language/types/integer.xml index 426abf6545c8..c194ddeae2ab 100644 --- a/language/types/integer.xml +++ b/language/types/integer.xml @@ -32,8 +32,8 @@ To use octal notation, precede the number with a 0 (zero). As of PHP 8.1.0, octal notation can also be preceded with 0o or 0O. - To use hexadecimal notation precede the number with 0x. - To use binary notation precede the number with 0b. + To use hexadecimal notation, precede the number with 0x. + To use binary notation, precede the number with 0b. @@ -126,7 +126,7 @@ var_dump(PHP_INT_MAX + 1); // 32-bit system: float(2147483648) Integer division - There is no int division operator in PHP, to achieve this + There is no int division operator in PHP. To achieve this, use the intdiv function. 1/2 yields the float 0.5. The value can be cast to an int to round it towards zero, or @@ -185,7 +185,8 @@ var_dump(round(25/7)); // float(4) When converting from float to int, the number will be rounded towards zero. - As of PHP 8.1.0, a deprecation notice is emitted when implicitly converting a non-integral &float; to &integer; which loses precision. + As of PHP 8.1.0, a deprecation notice is emitted when implicitly converting + a non-integral &float; to an &integer; which loses precision. diff --git a/language/types/iterable.xml b/language/types/iterable.xml index 6e8471131e20..86d93a1af37d 100644 --- a/language/types/iterable.xml +++ b/language/types/iterable.xml @@ -4,14 +4,14 @@ Iterables - Iterable is a built-in compile time type alias for + Iterable is a built-in compile-time type alias for array|Traversable. From its introduction in PHP 7.1.0 and prior to PHP 8.2.0, iterable was a built-in pseudo-type that acted as the - aforementioned type alias and can be used as a type declaration. + aforementioned type alias and could be used as a type declaration. An iterable type can be used in &foreach; and with yield from within a generator. diff --git a/language/types/mixed.xml b/language/types/mixed.xml index 3d65f66ddb25..b1f093dc2b11 100644 --- a/language/types/mixed.xml +++ b/language/types/mixed.xml @@ -16,8 +16,8 @@ - mixed is, in type theory parlance, the top type. - Meaning every other type is a subtype of it. + mixed is, in type theory parlance, the top type, + meaning every other type is a subtype of it. diff --git a/language/types/never.xml b/language/types/never.xml index c7b1703516cc..1e6d0932a007 100644 --- a/language/types/never.xml +++ b/language/types/never.xml @@ -11,8 +11,8 @@ declaration. Available as of PHP 8.1.0. - never is, in type theory parlance, the bottom type. - Meaning it is the subtype of every other type and can replace any other + never is, in type theory parlance, the bottom type, + meaning it is the subtype of every other type and can replace any other return type during inheritance. diff --git a/language/types/null.xml b/language/types/null.xml index 0acaa42bd8de..689d1a13ed68 100644 --- a/language/types/null.xml +++ b/language/types/null.xml @@ -9,7 +9,7 @@ - Undefined, and unset variables will resolve to the + Undefined and unset variables resolve to the value &null;. diff --git a/language/types/numeric-strings.xml b/language/types/numeric-strings.xml index 5f36aab79958..c0053053ed79 100644 --- a/language/types/numeric-strings.xml +++ b/language/types/numeric-strings.xml @@ -54,7 +54,7 @@ var_dump("2E1" == "020"); // true, "2E1" is 2 * (10 ^ 1), or 20 Strings used in numeric contexts - When a string needs to be evaluated as number (e.g. arithmetic + When a string needs to be evaluated as a number (e.g. arithmetic operations, int type declaration, etc.) the following steps are taken to determine the outcome: @@ -81,7 +81,7 @@ var_dump("2E1" == "020"); // true, "2E1" is 2 * (10 ^ 1), or 20 - The string is not numeric, throw a + If the string is not numeric, throw a TypeError. @@ -92,8 +92,8 @@ var_dump("2E1" == "020"); // true, "2E1" is 2 * (10 ^ 1), or 20 Behavior prior to PHP 8.0.0 - Prior to PHP 8.0.0, a string was considered numeric only if it - had leading whitespaces, if it had + Prior to PHP 8.0.0, a string was considered numeric if it only + had leading whitespaces. If it had trailing whitespaces then the string was considered to be leading numeric. @@ -110,7 +110,7 @@ var_dump("2E1" == "020"); // true, "2E1" is 2 * (10 ^ 1), or 20 - If the string is not numeric, an E_WARNING was + If the string was not numeric, an E_WARNING was raised and the value 0 would be returned. diff --git a/language/types/object.xml b/language/types/object.xml index 771b29f0b2ef..f61b0dd25ef9 100644 --- a/language/types/object.xml +++ b/language/types/object.xml @@ -47,8 +47,8 @@ $bar->do_foo(); object, a new instance of the stdClass built-in class is created. If the value was &null;, the new instance will be empty. An array converts to an object with properties - named by keys and corresponding values. Note that in this case before PHP 7.2.0 numeric keys - have been inaccessible unless iterated. + named by keys and with their corresponding values. + Prior to PHP 7.2.0, numeric keys would have been inaccessible unless iterated. diff --git a/language/types/relative-class-types.xml b/language/types/relative-class-types.xml index 565bae8d685f..672ecc751e04 100644 --- a/language/types/relative-class-types.xml +++ b/language/types/relative-class-types.xml @@ -4,7 +4,7 @@ Relative class types - These types declarations can only be used within classes. + These type declarations can only be used within classes. diff --git a/language/types/resource.xml b/language/types/resource.xml index 3ddceb720485..687cb0dc439c 100644 --- a/language/types/resource.xml +++ b/language/types/resource.xml @@ -28,7 +28,7 @@ Freeing resources - Thanks to the reference-counting system being part of Zend Engine, + Thanks to the reference-counting system being part of the Zend Engine, a resource with no more references to it is detected automatically, and it is freed by the garbage collector. For this reason, it is rarely necessary to free the memory manually. diff --git a/language/types/singleton.xml b/language/types/singleton.xml index a5d15bc36e4c..6f71013e8f4e 100644 --- a/language/types/singleton.xml +++ b/language/types/singleton.xml @@ -12,7 +12,7 @@ - Prior to PHP 8.2.0 the false type + Prior to PHP 8.2.0, the false type could only be used as part of a union type. diff --git a/language/types/string.xml b/language/types/string.xml index fcfb74084454..d8dadf1ce6dc 100644 --- a/language/types/string.xml +++ b/language/types/string.xml @@ -13,7 +13,7 @@ - On 32-bit builds, a string can be as large as up to 2GB + On 32-bit builds, a string can be as large as 2GB (2147483647 bytes maximum) @@ -264,7 +264,8 @@ c - If the closing identifier is indented further than any lines of the body, then a ParseError will be thrown: + If the closing identifier is indented further than any lines of the body, + then a ParseError will be thrown: @@ -288,23 +289,24 @@ Parse error: Invalid body indentation level (expecting an indentation level of a - If the closing identifier is indented, tabs can be used as well, however, - tabs and spaces must not be intermixed regarding - the indentation of the closing identifier and the indentation of the body - (up to the closing identifier). In any of these cases, a ParseError will be thrown. + If the closing identifier is indented, tabs can be used as well. However, + tabs and spaces must not be intermixed. + The indentation of the body and the closing identifier must use one or the + other consistently. If tabs and spaces are mixed, + then a ParseError will be thrown. These whitespace constraints have been included because mixing tabs and spaces for indentation is harmful to legibility. - Different indentation for body (spaces) closing identifier + Different indentation for body and closing identifier - If the closing identifier was found at the start of a line, then - regardless of whether it was a part of another word, it may be considered - as the closing identifier and causes a ParseError. + If the closing identifier is found at the start of a line, then + regardless of whether it is a part of another word, it is considered + as the closing identifier and causes a ParseError. - Closing identifier in body of the string tends to cause ParseError + Closing identifier in body of the string tends to cause <exceptionname>ParseError</exceptionname> Nowdocs are to single-quoted strings what heredocs are to double-quoted strings. A nowdoc is specified similarly to a heredoc, but no - String interpolation is done inside a nowdoc. The construct is ideal for + string interpolation is done inside a nowdoc. The construct is ideal for embedding PHP code or other large blocks of text without the need for escaping. It shares some features in common with the SGML <![CDATA[ ]]> construct, in that it declares a @@ -804,7 +806,7 @@ string(3) "bar" If it is not possible to form a valid name the dollar sign remains - as verbatim in the string: + verbatim in the string: @@ -873,8 +875,8 @@ Object value: string. - As of PHP 7.1.0 also negative numeric indices are - supported. + As of PHP 7.1.0, negative numeric indices are + supported too. Negative numeric indices @@ -991,7 +993,7 @@ echo "C:\\directory\\{$great}.txt" . PHP_EOL; - As this syntax allows arbitrary expressions it is possible to use + As this syntax allows arbitrary expressions, it is possible to use variable variables within the advanced syntax. @@ -1032,9 +1034,9 @@ echo "C:\\directory\\{$great}.txt" . PHP_EOL; - Writing to an out of range offset pads the string with spaces. - Non-integer types are converted to integer. - Illegal offset type emits E_WARNING. + Writing to an out-of-range offset pads the string with spaces. + Non-integer types are converted to an integer. + An illegal offset type emits E_WARNING. Only the first character of an assigned string is used. As of PHP 7.1.0, assigning an empty string throws a fatal error. Formerly, it assigned a NULL byte. @@ -1284,9 +1286,9 @@ string(1) "b" those bytes translate to characters, leaving that task to the programmer. There are no limitations on the values the string can be composed of; in particular, bytes with value 0 (“NUL bytes”) are allowed - anywhere in the string (however, a few functions, said in this manual not to + anywhere in the string. However, a few functions, said in this manual not to be “binary safe”, may hand off the strings to libraries that ignore data - after a NUL byte.) + after a NUL byte. This nature of the string type explains why there is no separate “byte” type @@ -1300,7 +1302,7 @@ string(1) "b" "á" equivalent to "\xE1" (ISO-8859-1), "\xC3\xA1" (UTF-8, C form), "\x61\xCC\x81" (UTF-8, D form) or any other possible - representation? The answer is that string will be encoded in whatever fashion + representation? The answer is that the string will be encoded in whatever fashion it is encoded in the script file. Thus, if the script is written in ISO-8859-1, the string will be encoded in ISO-8859-1 and so on. However, this does not apply if Zend Multibyte is enabled; in that case, the script @@ -1324,17 +1326,17 @@ string(1) "b" Some functions assume that the string is encoded in some (any) single-byte encoding, but they do not need to interpret those bytes as specific - characters. This is case of, for instance, substr, + characters. This is the case of, for instance, substr, strpos, strlen or strcmp. Another way to think of these functions is - that operate on memory buffers, i.e., they work with bytes and byte + that they operate on memory buffers, i.e., they work with bytes and byte offsets. - Other functions are passed the encoding of the string, possibly they also - assume a default if no such information is given. This is the case of + Other functions receive the encoding of the string as a parameter or + assume a default when it's not provided. This is the case of htmlentities and the majority of the functions in the mbstring extension. diff --git a/language/types/type-juggling.xml b/language/types/type-juggling.xml index 6c4efcb7aa15..920f9c515f6c 100644 --- a/language/types/type-juggling.xml +++ b/language/types/type-juggling.xml @@ -58,13 +58,13 @@ - In this context if either operand is a float (or not + In this context, if either operand is a float (or not interpretable as an int), both operands are interpreted as floats, and the result will be a float. Otherwise, the operands will be interpreted as ints, and the result will also be an int. - As of PHP 8.0.0, if one of the operands cannot be interpreted a - TypeError is thrown. + As of PHP 8.0.0, if one of the operands cannot be interpreted, a + TypeError is thrown. @@ -80,8 +80,8 @@ - In this context the value will be interpreted as string. - If the value cannot be interpreted a TypeError is thrown. + In this context, the value will be interpreted as string. + If the value cannot be interpreted, a TypeError is thrown. Prior to PHP 7.4.0, an E_RECOVERABLE_ERROR was raised. @@ -96,7 +96,7 @@ - In this context the value will be interpreted as bool. + In this context, the value will be interpreted as bool. @@ -109,12 +109,12 @@ - In this context if all operands are of type string the result + In this context, if all operands are of type string, the result will also be a string. Otherwise, the operands will be interpreted as ints, and the result will also be an int. - As of PHP 8.0.0, if one of the operands cannot be interpreted a - TypeError is thrown. + As of PHP 8.0.0, if one of the operands cannot be interpreted, a + TypeError is thrown. @@ -142,13 +142,13 @@ - In this context the value must be a value of the type. - Two exceptions exist, the first one is: if the value is of type + In this context, the value must be a value of the type. + Two exceptions exist. The first one is: if the value is of type int and the declared type is float, then the integer is converted to a floating point number. The second one is: if the declared type is a scalar - type, the value is convertable to a scalar type, + type, the value is convertible to a scalar type, and the coercive typing mode is active (the default), the value may be converted to an accepted scalar value. See below for a description of this behaviour. @@ -157,8 +157,8 @@ Internal functions - automatically coerce &null; to scalar types, - this behaviour is DEPRECATED as of PHP 8.1.0. + automatically coerce &null; to scalar types. + This behaviour is DEPRECATED as of PHP 8.1.0. @@ -173,14 +173,14 @@ int type declaration: value is interpreted as int - if the conversion is well-defined. For example the string is + if the conversion is well-defined. For example, the string is numeric. float type declaration: value is interpreted as float - if the conversion is well-defined. For example the string is + if the conversion is well-defined. For example, the string is numeric. @@ -242,7 +242,7 @@ Types that are not part of the above preference list are not eligible - targets for implicit coercion. In particular no implicit coercions to + targets for implicit coercion. In particular, no implicit coercions to the null, false, and true types occur. @@ -352,7 +352,7 @@ var_dump($bar); - The (binary) cast and b prefix exists + The (binary) cast and b prefix exist for forward support. Currently (binary) and (string) are identical, however this may change and should not be relied upon. diff --git a/language/types/type-system.xml b/language/types/type-system.xml index db9f2a9fd673..89d0e9173423 100644 --- a/language/types/type-system.xml +++ b/language/types/type-system.xml @@ -18,7 +18,7 @@ Atomic types Some atomic types are built-in types which are tightly integrated with the - language and cannot be reproduced with user defined types. + language and cannot be reproduced with user-defined types. @@ -160,7 +160,7 @@ Intersection types - An intersection type accepts values which satisfies multiple + An intersection type accepts values which satisfy multiple class-type declarations, rather than a single one. Individual types which form the intersection type are joined by the & symbol. Therefore, an intersection type comprised @@ -179,7 +179,7 @@ of the types T, U, and V will be written as T|U|V. If one of the types is an intersection type, it needs to be bracketed - with parenthesis for it to be written in DNF: + with parentheses for it to be written in DNF: T|(X&Y). @@ -190,7 +190,7 @@ PHP supports two type aliases: mixed and - iterable which corresponds to the + iterable which correspond to the union type of object|resource|array|string|float|int|bool|null and Traversable|array respectively. diff --git a/language/types/void.xml b/language/types/void.xml index 5f3bd1025955..60352d2f3e51 100644 --- a/language/types/void.xml +++ b/language/types/void.xml @@ -12,8 +12,8 @@ - Even if a function has a return type of void it will - still return a value, this value is always &null;. + Even if a function has a return type of void, it will + still return a value. This value is always &null;. From c14dfe5bdca47a00b15d3756f90d3eadebf72269 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 7 Aug 2026 13:21:09 +0100 Subject: [PATCH 2/3] Change "para" to "simpara" --- language/types/array.xml | 8 ++++---- language/types/declarations.xml | 4 ++-- language/types/float.xml | 24 ++++++++++++------------ language/types/integer.xml | 10 +++++----- language/types/iterable.xml | 4 ++-- language/types/mixed.xml | 4 ++-- language/types/never.xml | 4 ++-- language/types/null.xml | 4 ++-- language/types/numeric-strings.xml | 4 ++-- language/types/object.xml | 4 ++-- language/types/relative-class-types.xml | 4 ++-- language/types/resource.xml | 4 ++-- language/types/string.xml | 18 +++++++++--------- language/types/type-juggling.xml | 8 ++++---- language/types/type-system.xml | 12 ++++++------ 15 files changed, 58 insertions(+), 58 deletions(-) diff --git a/language/types/array.xml b/language/types/array.xml index 1ea26f2e0b01..d6330168f11a 100644 --- a/language/types/array.xml +++ b/language/types/array.xml @@ -478,7 +478,7 @@ $arr[] = value; // key may be an int or string // value may be any value of any type - + If $arr doesn't exist yet or is set to &null; or &false;, it will be created, so this is also an alternative way to create an array. This practice is however discouraged because if $arr already contains @@ -487,7 +487,7 @@ $arr[] = value; for string access operator. It is always better to initialize a variable by a direct assignment. - + As of PHP 7.1.0, applying the empty index operator on a string throws a fatal @@ -1052,7 +1052,7 @@ $error_descriptions[8] = "This is just an informal notice"; array($scalarValue). - + If an object is converted to an array, the result is an array whose elements are the object's properties. The keys are the member variable names, with a few notable @@ -1062,7 +1062,7 @@ $error_descriptions[8] = "This is just an informal notice"; prepended values have NUL bytes on either side. Uninitialized typed properties are silently discarded. - + Converting to an Array diff --git a/language/types/declarations.xml b/language/types/declarations.xml index b6f61479cf2f..63718d4f020e 100644 --- a/language/types/declarations.xml +++ b/language/types/declarations.xml @@ -10,12 +10,12 @@ otherwise a TypeError is thrown. - + Every single type that PHP supports, with the exception of resource, can be used within a user-land type declaration. This page contains a changelog of availability of the different types and documentation about usage of them in type declarations. - + diff --git a/language/types/float.xml b/language/types/float.xml index aa01d89c8558..65a0d1661c17 100644 --- a/language/types/float.xml +++ b/language/types/float.xml @@ -3,10 +3,10 @@ Floating-point numbers - + Floating-point numbers (also known as "floats", "doubles", or "real numbers") can be specified using any of the following syntaxes: - + @@ -44,16 +44,16 @@ EXPONENT_DNUM (({LNUM} | {DNUM}) [eE][+-]? {LNUM}) Floating-point precision - + Floating-point numbers have limited precision. Although it depends on the system, PHP typically uses the IEEE 754 double precision format, which will give a maximum relative error due to rounding in the order of 1.11e-16. Non-elementary arithmetic operations may give larger errors, and, of course, error propagation must be considered when several operations are compounded. - + - + Additionally, rational numbers that are exactly representable as floating-point numbers in base 10, like 0.1 or 0.7, do not have an exact representation as floating-point @@ -64,14 +64,14 @@ EXPONENT_DNUM (({LNUM} | {DNUM}) [eE][+-]? {LNUM}) return 7 instead of the expected 8, since the internal representation will be something like 7.9999999999999991118.... - + - + So never trust floating-point number results to the last digit, and do not compare floating-point numbers directly for equality. If higher precision is necessary, the arbitrary precision math functions and gmp functions are available. - + For a "simple" explanation, see the floating point guide @@ -117,18 +117,18 @@ EXPONENT_DNUM (({LNUM} | {DNUM}) [eE][+-]? {LNUM}) Comparing floats - + As noted in the warning above, testing floating-point values for equality is problematic, due to the way that they are represented internally. However, there are ways to make comparisons of floating-point values that work around these limitations. - + - + To test floating-point values for equality, an upper bound on the relative error due to rounding is used. This value is known as the machine epsilon, or unit roundoff, and is the smallest acceptable difference in calculations. - + $a and $b are equal to 5 digits of diff --git a/language/types/integer.xml b/language/types/integer.xml index c194ddeae2ab..ef2256093f0c 100644 --- a/language/types/integer.xml +++ b/language/types/integer.xml @@ -12,7 +12,7 @@ &reftitle.seealso; - Floating point numbers + Floating-point numbers Arbitrary precision / BCMath Arbitrary length integer / GMP @@ -29,12 +29,12 @@ can be used to denote a negative int. - + To use octal notation, precede the number with a 0 (zero). As of PHP 8.1.0, octal notation can also be preceded with 0o or 0O. To use hexadecimal notation, precede the number with 0x. To use binary notation, precede the number with 0b. - + As of PHP 7.4.0, integer literals may contain underscores (_) between digits, @@ -125,13 +125,13 @@ var_dump(PHP_INT_MAX + 1); // 32-bit system: float(2147483648) Integer division - + There is no int division operator in PHP. To achieve this, use the intdiv function. 1/2 yields the float 0.5. The value can be cast to an int to round it towards zero, or the round function provides finer control over rounding. - + Divisions diff --git a/language/types/iterable.xml b/language/types/iterable.xml index 86d93a1af37d..c0319347c933 100644 --- a/language/types/iterable.xml +++ b/language/types/iterable.xml @@ -3,7 +3,7 @@ Iterables - + Iterable is a built-in compile-time type alias for