Qual: Optimize PHP Code sniffer rules

This commit is contained in:
Laurent Destailleur 2011-08-28 17:40:51 +00:00
parent 69892eccf8
commit 76a6d6a6fe
4 changed files with 30 additions and 20 deletions

View File

@ -33,7 +33,7 @@
<!-- Lines can be 85 chars long, but never show errors -->
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="320" />
<property name="lineLimit" value="1000" />
<property name="absoluteLineLimit" value="0" />
</properties>
</rule>
@ -169,8 +169,14 @@
<rule ref="PEAR.Functions.ValidDefaultValue" />
<rule ref="PEAR.NamingConventions.ValidClassName" />
<rule ref="PEAR.NamingConventions.ValidClassName.StartWithCaptial">
<severity>0</severity>
</rule>
<rule ref="PEAR.NamingConventions.ValidFunctionName" />
<rule ref="PEAR.NamingConventions.ValidFunctionName.NotCamelCaps">
<severity>0</severity>
</rule>
<rule ref="PEAR.NamingConventions.ValidFunctionName.FunctionNoCaptial">
<severity>0</severity>

View File

@ -151,7 +151,7 @@ $targetcontent=$sourcecontent;
$targetcontent=preg_replace('/skeleton_class\.class\.php/', $classmin.'.class.php', $targetcontent);
$targetcontent=preg_replace('/\$element=\'skeleton\'/', '\$element=\''.$classmin.'\'', $targetcontent);
$targetcontent=preg_replace('/\$table_element=\'skeleton\'/', '\$table_element=\''.$classmin.'\'', $targetcontent);
$targetcontent=preg_replace('/Skeleton_class/', $classname, $targetcontent);
$targetcontent=preg_replace('/Skeleton_Class/', $classname, $targetcontent);
// Substitute comments
$targetcontent=preg_replace('/This file is an example to create a new class file/', 'Put here description of this class', $targetcontent);
@ -206,7 +206,7 @@ foreach($property as $key => $prop)
if ($addfield)
{
$varprop.="\t\t\$sql.= \"".$prop['field'];
if ($i < sizeof($property)) $varprop.=",";
if ($i < count($property)) $varprop.=",";
$varprop.="\";";
$varprop.="\n";
}
@ -233,7 +233,7 @@ foreach($property as $key => $prop)
$varprop.='".(! isset($this->'.$prop['field'].') || dol_strlen($this->'.$prop['field'].')==0?\'NULL\':$this->db->idate(';
$varprop.="\$this->".$prop['field']."";
$varprop.='))."';
if ($i < sizeof($property)) $varprop.=",";
if ($i < count($property)) $varprop.=",";
$varprop.="\";";
}
elseif ($prop['ischar'])
@ -241,7 +241,7 @@ foreach($property as $key => $prop)
$varprop.='".(! isset($this->'.$prop['field'].')?\'NULL\':"\'".';
$varprop.='$this->db->escape($this->'.$prop['field'].')';
$varprop.='."\'")."';
if ($i < sizeof($property)) $varprop.=",";
if ($i < count($property)) $varprop.=",";
$varprop.='";';
}
else
@ -249,7 +249,7 @@ foreach($property as $key => $prop)
$varprop.='".(! isset($this->'.$prop['field'].')?\'NULL\':"\'".';
$varprop.="\$this->".$prop['field']."";
$varprop.='."\'")."';
if ($i < sizeof($property)) $varprop.=",";
if ($i < count($property)) $varprop.=",";
$varprop.='";';
}
$varprop.="\n";
@ -287,7 +287,7 @@ foreach($property as $key => $prop)
$varprop.=".\"";
}
if ($i < sizeof($property)) $varprop.=',';
if ($i < count($property)) $varprop.=',';
$varprop.='";';
$varprop.="\n";
}
@ -306,7 +306,7 @@ foreach($property as $key => $prop)
{
$varprop.="\t\t\$sql.= \" ";
$varprop.="t.".$prop['field'];
if ($i < sizeof($property)) $varprop.=",";
if ($i < count($property)) $varprop.=",";
$varprop.="\";";
$varprop.="\n";
}
@ -385,7 +385,7 @@ $targetcontent=preg_replace('/skeleton_class\.class\.php/', $classmin.'.class.ph
$targetcontent=preg_replace('/skeleton_script\.php/', $classmin.'_script.php', $targetcontent);
$targetcontent=preg_replace('/\$element=\'skeleton\'/', '\$element=\''.$classmin.'\'', $targetcontent);
$targetcontent=preg_replace('/\$table_element=\'skeleton\'/', '\$table_element=\''.$classmin.'\'', $targetcontent);
$targetcontent=preg_replace('/Skeleton_class/', $classname, $targetcontent);
$targetcontent=preg_replace('/Skeleton_Class/', $classname, $targetcontent);
// Substitute comments
$targetcontent=preg_replace('/This file is an example to create a new class file/', 'Put here description of this class', $targetcontent);

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -38,8 +38,9 @@ include_once(DOL_DOCUMENT_ROOT ."/includes/modules/DolibarrModules.class.php");
class modMyModule extends DolibarrModules
{
/**
* \brief Constructor. Define names, constants, directories, boxes, permissions
* \param DB Database handler
* Constructor. Define names, constants, directories, boxes, permissions
*
* @param DoliDB $DB Database handler
*/
function modMyModule($DB)
{
@ -232,7 +233,8 @@ class modMyModule extends DolibarrModules
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories.
* It also creates data directories
*
* @return int 1 if OK, 0 if KO
*/
function init()
@ -247,7 +249,8 @@ class modMyModule extends DolibarrModules
/**
* Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database.
* Data directories are not deleted.
* Data directories are not deleted
*
* @return int 1 if OK, 0 if KO
*/
function remove()
@ -259,11 +262,12 @@ class modMyModule extends DolibarrModules
/**
* \brief Create tables, keys and data required by module
* Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys
* and create data commands must be stored in directory /mymodule/sql/
* This function is called by this->init.
* \return int <=0 if KO, >0 if OK
* Create tables, keys and data required by module
* Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys
* and create data commands must be stored in directory /mymodule/sql/
* This function is called by this->init
*
* @return int <=0 if KO, >0 if OK
*/
function load_tables()
{

View File

@ -31,7 +31,7 @@
/**
* \class Skeleton_class
* \class Skeleton_Class
* \brief Put here description of your class
* \remarks Put here some comments
*/