Skip to content

Commit 99888eb

Browse files
Crellheiglandreas
andauthored
Move SHOULD/MUST statements to each bullet point
Co-authored-by: Andreas Heigl <[email protected]>
1 parent 0ab2db9 commit 99888eb

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

src/Pure.php

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@
2828
* 2. The function has no side effects (no mutation of non-local variables,
2929
* mutable reference arguments or input/output streams).
3030
*
31-
* In PHP, that means a pure function MUST NOT:
31+
* In PHP, that means a pure function:
3232
*
33-
* 1. Use or modify any global variable.
34-
* 2. Perform any IO operations, even read-only ones.
35-
* 3. Modify any property of an object provided to it as an argument,
36-
* even transitively.
37-
* 4. Read from an object property on the same object unless that property
38-
* is `readonly`.
39-
* 5. Accept a parameter by reference.
40-
* 6. Call any function that is not also marked "pure." (It may invoke a
41-
* callable passed to it as an explicit argument.)
33+
* 1. MUST NOT use or modify any global variable.
34+
* 2. MIST NOT perform any IO operations, even read-only ones.
35+
* 3. MUST NOT modify any property of an object provided to it as an
36+
* argument, even transitively.
37+
* 4. MUST NOT read from an object property on the same object unless
38+
* that property is `readonly`.
39+
* 5. MUST NOT accept a parameter by reference.
40+
* 6. MUST NOT call any function that is not also marked "pure." (It
41+
* may invoke a callable passed to it as an explicit argument.)
4242
*
4343
* ## When should the attribute be applied
4444
*
@@ -48,20 +48,23 @@
4848
* If this attribute is placed on a method in an interface, it means that all
4949
* implementations of that method MUST themselves be marked pure.
5050
*
51-
* Static analysis tools SHOULD
52-
* - Verify that the function indeed meets the rules above, and treat it as
53-
* an error if not.
51+
* Static analysis tools
52+
* - SHOULD verify that the function indeed meets the rules above,
53+
* and treat it as an error if not.
5454
*
55-
* Static analysis tools MUST
56-
* - Treat PHP standard library functions that conform to these rules as pure.
57-
* As an example, `strtolower()` is pure. `sort()` is not.
58-
* - Flag as an error any function that is marked pure but is demonstrably not.
59-
* - Treat any method implementing an interface method marked pure as pure.
55+
* Static analysis tools
56+
* - MUST treat PHP standard library functions that conform to these
57+
* rules as pure. As an example, `strtolower()` is pure. `sort()`
58+
* is not.
59+
* - MUST flag as an error any function that is marked pure but is
60+
* demonstrably not.
61+
* - MUST treat any method implementing an interface method marked
62+
* pure as pure.
6063
*
61-
* Optimization tools and pre-compilation tools MAY:
62-
* - Implement optimizations based on the knowledge that a function is pure.
63-
* For example, they may safely cache its results indefinitely, or inline its
64-
* code into another routine.
64+
* Optimization tools and pre-compilation tools:
65+
* - MAY implement optimizations based on the knowledge that a function
66+
* is pure. For example, they may safely cache its results indefinitely,
67+
* or inline its code into another routine.
6568
*
6669
*/
6770
#[\Attribute(\Attribute::TARGET_FUNCTION | \Attribute::TARGET_METHOD)]

0 commit comments

Comments
 (0)