Skip to content

Commit

Permalink
Adding link to changed behavior site
Browse files Browse the repository at this point in the history
  • Loading branch information
christopheexakat committed Jan 7, 2024
1 parent 11fc94a commit ba426e6
Show file tree
Hide file tree
Showing 128 changed files with 584 additions and 398 deletions.
1 change: 1 addition & 0 deletions Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Here is the release note of exakat.
+ New analysis : could use strcontains()
+ New analysis : suggest removing unused variable in catch
+ New analysis : suggest adding readonly to property
+ New analysis : spot calls just after an instanciation

+ Tokenizer
+ Added CALLED link to new calls
Expand Down
8 changes: 4 additions & 4 deletions Reference/Cases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2880,10 +2880,10 @@ This code could be turned into a switch() structure.
if ($field[3] === 'text') {
echo '
<input type="text" id="edit_field_'.$field[0].'_'.$elem[0].'" class="edit_item_field input_text text ui-widget-content ui-corner-all" size="40" data-field-type="'.$field[3].'" data-field-masked="'.$field[4].'" data-field-is-mandatory="'.$field[5].'" data-template-id="'.$templateID.'">';
<input type=text id=edit_field_.$field[0]._.$elem[0]. class=edit_item_field input_text text ui-widget-content ui-corner-all size=40 data-field-type=.$field[3]. data-field-masked=.$field[4]. data-field-is-mandatory=.$field[5]. data-template-id=.$templateID.>';
} else if ($field[3] === 'textarea') {
echo '
<textarea id="edit_field_'.$field[0].'_'.$elem[0].'" class="edit_item_field input_text text ui-widget-content ui-corner-all" colums="40" rows="5" data-field-type="'.$field["3"].'" data-field-masked="'.$field[4].'" data-field-is-mandatory="'.$field[5].'" data-template-id="'.$templateID.'"></textarea>';
<textarea id=edit_field_.$field[0]._.$elem[0]. class=edit_item_field input_text text ui-widget-content ui-corner-all colums=40 rows=5 data-field-type=.$field["3"]. data-field-masked=.$field[4]. data-field-is-mandatory=.$field[5]. data-template-id=.$templateID.></textarea>';
}
Expand Down Expand Up @@ -10839,7 +10839,7 @@ $product is defined with a reference in the method signature, but it is also use
$props_to_update = $force ? $meta_key_to_props : $this->get_props_to_update( $product, $meta_key_to_props );
foreach ( $props_to_update as $meta_key => $prop ) {
$value = $product->{"get_$prop"}( 'edit' );
$value = $product->{get_$prop}( 'edit' );
$updated = update_post_meta( $product->get_id(), $meta_key, $value );
if ( $updated ) {
$this->updated_props[] = $prop;
Expand Down Expand Up @@ -11323,7 +11323,7 @@ This code actually loads the file, join it, then split it again. file() would be

.. code-block:: php
$markerdata = explode( "\n", implode( '', file( $filename ) ) );
$markerdata = explode( \n, implode( '', file( $filename ) ) );
.. _case-wrong-number-of-arguments:
Expand Down
4 changes: 1 addition & 3 deletions Reference/Reports/meters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ _____
+--------------+------------------------------------------------------------------+
| Short name | Meters |
+--------------+------------------------------------------------------------------+
| Rulesets | This reports works with an arbitrary list of results. |
| | |
| | |
| Rulesets | None. |
+--------------+------------------------------------------------------------------+
| Type | JSON |
+--------------+------------------------------------------------------------------+
Expand Down
66 changes: 44 additions & 22 deletions Reference/Rules.rst

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Reference/Rules/Arrays/NegativeStart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ _____
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Time To Fix | Quick (30 mins) |
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Changed Behavior | PHP 8.0 |
| Changed Behavior | PHP 8.0 - `More <https://php-changed-behaviors.readthedocs.io/en/latest/behavior/.html>`__ |
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Precision | Very high |
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Expand Down
47 changes: 24 additions & 23 deletions Reference/Rules/Arrays/NullBoolean.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
Null Or Boolean Arrays
++++++++++++++++++++++

Null and booleans are valid PHP array base. Yet, they only produces ``null`` values. They also did not emits any warning until PHP 7.4.
Null, int, floats, booleans are valid with PHP array syntx. Yet, they only produces ``null`` values. They also did not emits any warning until PHP 7.4.

This analysis has been upgraded to cover int and float types too.
Older code used to initialize variables as null, sometimes explictly, and then, use them as arrays. The current support for this syntax is for backward compatibility.

Illegal keys, such as another array, will also generate a `NULL <https://www.php.net/manual/en/language.types.null.php>`_ value, instead of a Fatal `error <https://www.php.net/error>`_.


.. code-block:: php
Expand All @@ -16,6 +18,7 @@ This analysis has been upgraded to cover int and float types too.
// outputs NULL
var_dump(null[0]);
var_dump(null[[]]);
const MY_CONSTANT = true;
// outputs NULL
Expand All @@ -38,26 +41,24 @@ ___________
Specs
_____

+------------------+-------------------------------------------------------------------------------------------------------------------------+
| Short name | Arrays/NullBoolean |
+------------------+-------------------------------------------------------------------------------------------------------------------------+
| Rulesets | :ref:`All <ruleset-All>`, :ref:`Analyze <ruleset-Analyze>`, :ref:`Changed Behavior <ruleset-Changed-Behavior>` |
+------------------+-------------------------------------------------------------------------------------------------------------------------+
| Exakat since | 1.8.6 |
+------------------+-------------------------------------------------------------------------------------------------------------------------+
| PHP Version | All |
+------------------+-------------------------------------------------------------------------------------------------------------------------+
| Severity | Minor |
+------------------+-------------------------------------------------------------------------------------------------------------------------+
| Time To Fix | Quick (30 mins) |
+------------------+-------------------------------------------------------------------------------------------------------------------------+
| Changed Behavior | PHP 7.4 |
+------------------+-------------------------------------------------------------------------------------------------------------------------+
| Precision | Very high |
+------------------+-------------------------------------------------------------------------------------------------------------------------+
| Features | null, boolean, array |
+------------------+-------------------------------------------------------------------------------------------------------------------------+
| Available in | `Entreprise Edition <https://www.exakat.io/entreprise-edition>`_, `Exakat Cloud <https://www.exakat.io/exakat-cloud/>`_ |
+------------------+-------------------------------------------------------------------------------------------------------------------------+
+--------------+-------------------------------------------------------------------------------------------------------------------------+
| Short name | Arrays/NullBoolean |
+--------------+-------------------------------------------------------------------------------------------------------------------------+
| Rulesets | :ref:`All <ruleset-All>`, :ref:`Analyze <ruleset-Analyze>`, :ref:`Changed Behavior <ruleset-Changed-Behavior>` |
+--------------+-------------------------------------------------------------------------------------------------------------------------+
| Exakat since | 1.8.6 |
+--------------+-------------------------------------------------------------------------------------------------------------------------+
| PHP Version | All |
+--------------+-------------------------------------------------------------------------------------------------------------------------+
| Severity | Minor |
+--------------+-------------------------------------------------------------------------------------------------------------------------+
| Time To Fix | Quick (30 mins) |
+--------------+-------------------------------------------------------------------------------------------------------------------------+
| Precision | Very high |
+--------------+-------------------------------------------------------------------------------------------------------------------------+
| Features | null, boolean, float, int, array |
+--------------+-------------------------------------------------------------------------------------------------------------------------+
| Available in | `Entreprise Edition <https://www.exakat.io/entreprise-edition>`_, `Exakat Cloud <https://www.exakat.io/exakat-cloud/>`_ |
+--------------+-------------------------------------------------------------------------------------------------------------------------+


1 change: 0 additions & 1 deletion Reference/Rules/Arrays/RandomlySortedLiterals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ This may reduce the reading and proofing of the arrays, and induce confusion. Th

Unless order is important, it is recommended to always use the same order when defining literal arrays. This makes it easier to match different part of the code by recognizing one of its literal.


.. code-block:: php
<?php
Expand Down
6 changes: 3 additions & 3 deletions Reference/Rules/Arrays/SliceFirst.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Slice Arrays First
Always start by reducing an array before applying some transformation on it. The shorter array will be processed faster.



The gain produced here is greater with longer arrays, or greater reductions. They may also be used in loops. This is a micro-optimisation when used on short arrays.

.. code-block:: php
<?php
Expand All @@ -19,9 +22,6 @@ Slice Arrays First
$a = array_slice(array_map('foo', $array), 2, 5);
?>
The gain produced here is greater with longer arrays, or greater reductions. They may also be used in loops. This is a micro-optimisation when used on short arrays.

Suggestions
___________

Expand Down
10 changes: 5 additions & 5 deletions Reference/Rules/Arrays/TooManyDimensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ Too Many Array Dimensions
This analysis reports when arrays have too many dimensions. This happens when arrays are too deeply nested inside other arrays.



PHP has no nesting limit, and accepts any number of of dimensions. This is usually very memory hungry, and could be better replaced with classes.

The default threshold for this rule is 3 (see examples above).

.. code-block:: php
<?php
Expand All @@ -19,11 +24,6 @@ Too Many Array Dimensions
?>
PHP has no nesting limit, and accepts any number of of dimensions. This is usually very memory hungry, and could be better replaced with classes.

The default threshold for this rule is 3 (see examples above).

+---------------+---------+---------+-----------------------------------------+
| Name | Default | Type | Description |
+---------------+---------+---------+-----------------------------------------+
Expand Down
2 changes: 2 additions & 0 deletions Reference/Rules/Attributes/Friend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ _____
+--------------+-------------------------------------------------------------------------------------------------------------------------+
| Exakat since | 2.6.2 |
+--------------+-------------------------------------------------------------------------------------------------------------------------+
| PHP Version | With PHP 8.0 and more recent |
+--------------+-------------------------------------------------------------------------------------------------------------------------+
| Severity | Minor |
+--------------+-------------------------------------------------------------------------------------------------------------------------+
| Time To Fix | Quick (30 mins) |
Expand Down
2 changes: 1 addition & 1 deletion Reference/Rules/Attributes/NestedAttributes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ _____
+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Time To Fix | |
+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Changed Behavior | PHP 8.1 |
| Changed Behavior | PHP 8.1 - `More <https://php-changed-behaviors.readthedocs.io/en/latest/behavior/nestedAttributes.html>`__ |
+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Precision | Very high |
+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Expand Down
3 changes: 1 addition & 2 deletions Reference/Rules/Attributes/Override.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Override signals that the class has a method which overrides the `parent <https:

This analysis is not valid after PHP 8.3, as PHP does that itself.


.. code-block:: php
<?php
Expand Down Expand Up @@ -58,7 +57,7 @@ _____
+--------------+-------------------------------------------------------------------------------------------------------------------------+
| Exakat since | 2.6.1 |
+--------------+-------------------------------------------------------------------------------------------------------------------------+
| PHP Version | With PHP 8.3 and older |
| PHP Version | From PHP 8.0 to 8.3 |
+--------------+-------------------------------------------------------------------------------------------------------------------------+
| Severity | Minor |
+--------------+-------------------------------------------------------------------------------------------------------------------------+
Expand Down
1 change: 0 additions & 1 deletion Reference/Rules/Attributes/UsingDeprecated.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Using Deprecated Feature

Note that the class ` :ref:`rulesets-deprecated` ` does not need to be defined anywhere.


.. code-block:: php

<?php
Expand Down

0 comments on commit ba426e6

Please sign in to comment.