Skip to content

Commit

Permalink
Version 2.6.5
Browse files Browse the repository at this point in the history
  • Loading branch information
christopheexakat committed Jan 31, 2024
1 parent 16840dc commit 1ce55d8
Show file tree
Hide file tree
Showing 150 changed files with 1,971 additions and 1,383 deletions.
34 changes: 32 additions & 2 deletions Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ Release Note

Here is the release note of exakat.

**Version 2.6.5 (, 2024-01-11)**
**Version 2.6.6 (, 2024-01-11)**


+ Architecture
+ Speed up Load with less arrays, more classes
+

+ Cobbler
+
Expand All @@ -24,13 +24,43 @@ Here is the release note of exakat.
+ Tokenizer
+

**Version 2.6.5 (, 2024-01-11)**


+ Architecture
+ Added support for NEXT in Sequence, Method definition, Functioncall, concatenations

+ Cobbler
+

+ Report
+

+ Analysis
+ Refactored analysis : Structures/UselessTrailingComma handles method calls
+ Refactored analysis : Structures/UnreachableCode handles never returntype
+ Refactored analysis : Classes/AbstractOrImplements
+ Fixed analysis : Complete/ReturnType had a bug with Classanonymous
+ Refactored analysis : Variables/InconsistentUsage had a bug with Classanonymous
+ New analysis : report useless nullsafe operator usage
+ New analysis : report file_put_contents(, [])
+ New analysis : report nested match() calls
+ New analysis : report useless short ternary
+ New analysis : dump all combined method calls

+ Tokenizer
+ Fixed display of ?-> inside strings
+ Refactored Goto labels with a common atom between goto and labels
+ Fixed minor errors with SEQUENCE (via NEXT)

**Version 2.6.4 (, 2023-12-31)**


+ Architecture
+ Moved assert configuration to ini_set and php.ini
+ Added a set of token values for Debian 12 and 8.3
+ Void is now a single atom in the graph (speed up, less resources)
+ Speed up Load with less arrays, more classes

+ Analysis
+ New analysis : report PHP native attribute usage
Expand Down
2 changes: 1 addition & 1 deletion Introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Introduction
============

This is the documentation of the Exakat engine, version 2.6.4 (Build 1501), on Mon, 18 Dec 2023 15:28:36 +0000.
This is the documentation of the Exakat engine, version 2.6.5 (Build 1502), on Fri, 12 Jan 2024 15:44:26 +0000.

What is Exakat ?
----------------
Expand Down
272 changes: 136 additions & 136 deletions Reference/Cases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1681,6 +1681,98 @@ break is used here for cases, unless the case includes a if/then structures, in
}
.. _case-could-be-a-static-variable:

Could Be A Static Variable
##########################

.. _case-dolphin-structures-couldbestatic:

Dolphin
+++++++


:ref:`could-be-a-static-variable`, in inc/utils.inc.php:673.

Dolphin pro relies on HTMLPurifier to handle cleaning of values : it is used to prevent xss threat. In this method, oHtmlPurifier is first checked, and if needed, created. Since creation is long and costly, it is only created once. Once the object is created, it is stored as a global to be accessible at the next call of the method. In fact, oHtmlPurifier is never used outside this method, so it could be turned into a 'static' variable, and prevent other methods to modify it. This is a typical example of variable that could be static instead of global.

.. code-block:: php
function clear_xss($val)
{
// HTML Purifier plugin
global $oHtmlPurifier;
if (!isset($oHtmlPurifier) && !$GLOBALS['logged']['admin']) {
require_once(BX_DIRECTORY_PATH_PLUGINS . 'htmlpurifier/HTMLPurifier.standalone.php');
/..../
$oHtmlPurifier = new HTMLPurifier($oConfig);
}
if (!$GLOBALS['logged']['admin']) {
$val = $oHtmlPurifier->purify($val);
}
$oZ = new BxDolAlerts('system', 'clear_xss', 0, 0,
array('oHtmlPurifier' => $oHtmlPurifier, 'return_data' => &$val));
$oZ->alert();
return $val;
}
.. _case-contao-structures-couldbestatic:

Contao
++++++


:ref:`could-be-a-static-variable`, in system/helper/functions.php:184.

$arrScanCache is a typical cache variables. It is set as global for persistence between calls. If it contains an already stored answer, it is returned immediately. If it is not set yet, it is then filled with a value, and later reused. This global could be turned into static, and avoid pollution of global space.

.. code-block:: php
function scan($strFolder, $blnUncached=false)
{
global $arrScanCache;
// Add a trailing slash
if (substr($strFolder, -1, 1) != '/')
{
$strFolder .= '/';
}
// Load from cache
if (!$blnUncached && isset($arrScanCache[$strFolder]))
{
return $arrScanCache[$strFolder];
}
$arrReturn = array();
// Scan directory
foreach (scandir($strFolder) as $strFile)
{
if ($strFile == '.' || $strFile == '..')
{
continue;
}
$arrReturn[] = $strFile;
}
// Cache the result
if (!$blnUncached)
{
$arrScanCache[$strFolder] = $arrReturn;
}
return $arrReturn;
}
.. _case-could-be-abstract-class:

Could Be Abstract Class
Expand Down Expand Up @@ -1815,98 +1907,6 @@ The code includes a fair number of class constants. The one listed here are only
const TEXT_LONG = 4294967295;
.. _case-could-be-static:

Could Be Static
###############

.. _case-dolphin-structures-couldbestatic:

Dolphin
+++++++


:ref:`could-be-static`, in inc/utils.inc.php:673.

Dolphin pro relies on HTMLPurifier to handle cleaning of values : it is used to prevent xss threat. In this method, oHtmlPurifier is first checked, and if needed, created. Since creation is long and costly, it is only created once. Once the object is created, it is stored as a global to be accessible at the next call of the method. In fact, oHtmlPurifier is never used outside this method, so it could be turned into a 'static' variable, and prevent other methods to modify it. This is a typical example of variable that could be static instead of global.

.. code-block:: php
function clear_xss($val)
{
// HTML Purifier plugin
global $oHtmlPurifier;
if (!isset($oHtmlPurifier) && !$GLOBALS['logged']['admin']) {
require_once(BX_DIRECTORY_PATH_PLUGINS . 'htmlpurifier/HTMLPurifier.standalone.php');
/..../
$oHtmlPurifier = new HTMLPurifier($oConfig);
}
if (!$GLOBALS['logged']['admin']) {
$val = $oHtmlPurifier->purify($val);
}
$oZ = new BxDolAlerts('system', 'clear_xss', 0, 0,
array('oHtmlPurifier' => $oHtmlPurifier, 'return_data' => &$val));
$oZ->alert();
return $val;
}
.. _case-contao-structures-couldbestatic:

Contao
++++++


:ref:`could-be-static`, in system/helper/functions.php:184.

$arrScanCache is a typical cache variables. It is set as global for persistence between calls. If it contains an already stored answer, it is returned immediately. If it is not set yet, it is then filled with a value, and later reused. This global could be turned into static, and avoid pollution of global space.

.. code-block:: php
function scan($strFolder, $blnUncached=false)
{
global $arrScanCache;
// Add a trailing slash
if (substr($strFolder, -1, 1) != '/')
{
$strFolder .= '/';
}
// Load from cache
if (!$blnUncached && isset($arrScanCache[$strFolder]))
{
return $arrScanCache[$strFolder];
}
$arrReturn = array();
// Scan directory
foreach (scandir($strFolder) as $strFile)
{
if ($strFile == '.' || $strFile == '..')
{
continue;
}
$arrReturn[] = $strFile;
}
// Cache the result
if (!$blnUncached)
{
$arrScanCache[$strFolder] = $arrReturn;
}
return $arrReturn;
}
.. _case-could-be-static-closure:

Could Be Static Closure
Expand Down Expand Up @@ -2606,6 +2606,44 @@ The replacement with ``yield from``is not straigthforward here. Yield is only ca
}
.. _case-don't-mix-++:

Don't Mix ++
############

.. _case-contao-structures-dontmixplusplus:

Contao
++++++


:ref:`don't-mix-++`, in core-bundle/src/Resources/contao/drivers/DC_Table.php:1272.

Incrementing and multiplying at the same time.

.. code-block:: php
$this->Database->prepare("UPDATE " . $this->strTable . " SET sorting=? WHERE id=?")
->execute(($count++ * 128), $objNewSorting->id);
.. _case-typo3-structures-dontmixplusplus:

Typo3
+++++


:ref:`don't-mix-++`, in typo3/sysext/backend/Classes/Controller/SiteConfigurationController.php:74.

The post-increment is not readable at first glance.

.. code-block:: php
foreach ($row['rootline'] as &$record) {
$record['margin'] = $i++ * 20;
}
.. _case-don't-send-$this-in-constructor:

Don't Send $this In Constructor
Expand Down Expand Up @@ -2725,44 +2763,6 @@ The property errorParams is emptied by unsetting it. The property is actually de
protected $errorParams = [];
.. _case-dont-mix-++:

Dont Mix ++
###########

.. _case-contao-structures-dontmixplusplus:

Contao
++++++


:ref:`dont-mix-++`, in core-bundle/src/Resources/contao/drivers/DC_Table.php:1272.

Incrementing and multiplying at the same time.

.. code-block:: php
$this->Database->prepare("UPDATE " . $this->strTable . " SET sorting=? WHERE id=?")
->execute(($count++ * 128), $objNewSorting->id);
.. _case-typo3-structures-dontmixplusplus:

Typo3
+++++


:ref:`dont-mix-++`, in typo3/sysext/backend/Classes/Controller/SiteConfigurationController.php:74.

The post-increment is not readable at first glance.

.. code-block:: php
foreach ($row['rootline'] as &$record) {
$record['margin'] = $i++ * 20;
}
.. _case-double-array\_flip():

Double array_flip()
Expand Down Expand Up @@ -3511,7 +3511,7 @@ Here, $advocateid may be directly read from ocsql_fetch_assoc(), although, check
$advocateid = false;
if (isset($GLOBALS['OC_configAR']['OC_paperAdvocates']) && $GLOBALS['OC_configAR']['OC_paperAdvocates']) {
$ar = ocsql_query(""SELECT `advocateid` FROM `"" . OCC_TABLE_PAPERADVOCATE . ""` WHERE `paperid`='"" . safeSQLstr($pid) . ""'"") or err('Unable to retrieve advocate');
$ar = ocsql_query(SELECT `advocateid` FROM ` . OCC_TABLE_PAPERADVOCATE . ` WHERE `paperid`=' . safeSQLstr($pid) . ') or err('Unable to retrieve advocate');
if (ocsql_num_rows($ar) == 1) {
$al = ocsql_fetch_assoc($ar);
$advocateid = $al['advocateid'];
Expand Down Expand Up @@ -3913,8 +3913,8 @@ $request is used successively as an object (IXR_Request), then as a string (The
$request = new IXR_Request($method, $args);
$length = $request->getLength();
$xml = $request->getXml();
$r = "\r\n";
$request = "POST {$this->path} HTTP/1.0$r";
$r = \r\n;
$request = POST {$this->path} HTTP/1.0$r;
.. _case-indices-are-int-or-string:
Expand Down Expand Up @@ -7562,9 +7562,9 @@ Simply calling print once is better than three times. Here too, echo usage would

.. code-block:: php
print '<input type="text" name="quicksearch" value="'.$quicksearch.'" size="10" '.$pattern.' title="'.__('Minimum:').$min_chars.__('characters').'">';
print ' <input type="submit" value="'.__('Search').'">';
print "</form>";
print '<input type=text name=quicksearch value=.$quicksearch. size=10 '.$pattern.' title=.__(Minimum:).$min_chars.__(characters).>';
print ' <input type=submit value=.__(Search).>';
print </form>;
.. _case-rethrown-exceptions:
Expand Down

0 comments on commit 1ce55d8

Please sign in to comment.