Run accesses the super-global variable $_SERVER. Open
public static function Run($strClassName, $strNamespace = null) {
QApplication::$EncodingType = 'UTF-8';
$objWsdlCache = new QCache('soap', QApplication::$ScriptName, 'wsdl', QApplication::$ScriptFilename);
$objDiscoCache = new QCache('soap', QApplication::$ScriptName, 'disco', QApplication::$ScriptFilename);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
GetLocation accesses the super-global variable $_SERVER. Open
public function GetLocation() {
return sprintf('http%s://%s%s',
(array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS']) ? 's' : '',
$_SERVER['HTTP_HOST'],
QApplication::$ScriptName);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
GetLocation accesses the super-global variable $_SERVER. Open
public function GetLocation() {
return sprintf('http%s://%s%s',
(array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS']) ? 's' : '',
$_SERVER['HTTP_HOST'],
QApplication::$ScriptName);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Run accesses the super-global variable $_SERVER. Open
public static function Run($strClassName, $strNamespace = null) {
QApplication::$EncodingType = 'UTF-8';
$objWsdlCache = new QCache('soap', QApplication::$ScriptName, 'wsdl', QApplication::$ScriptFilename);
$objDiscoCache = new QCache('soap', QApplication::$ScriptName, 'disco', QApplication::$ScriptFilename);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
GetLocation accesses the super-global variable $_SERVER. Open
public function GetLocation() {
return sprintf('http%s://%s%s',
(array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS']) ? 's' : '',
$_SERVER['HTTP_HOST'],
QApplication::$ScriptName);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Run accesses the super-global variable $_SERVER. Open
public static function Run($strClassName, $strNamespace = null) {
QApplication::$EncodingType = 'UTF-8';
$objWsdlCache = new QCache('soap', QApplication::$ScriptName, 'wsdl', QApplication::$ScriptFilename);
$objDiscoCache = new QCache('soap', QApplication::$ScriptName, 'disco', QApplication::$ScriptFilename);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Function SetupSoapMethods
has a Cognitive Complexity of 97 (exceeds 5 allowed). Consider refactoring. Open
protected function SetupSoapMethods(ReflectionClass $objReflection) {
$objReflectionMethods = $objReflection->getMethods();
if ($objReflectionMethods) foreach ($objReflectionMethods as $objReflectionMethod) {
if ($objReflectionMethod->isPublic() && !$objReflectionMethod->isAbstract() &&
!$objReflectionMethod->isStatic() && !$objReflectionMethod->isConstructor() &&
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File QSoapService.class.php
has 476 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
// The built in SOAP WSDL Cache doesn't work very well
// We use QCache to implement a much smarter WSDL cache mechanism
// Because of this, we *MUST* set wsdl_cache_enabled to FALSE
ini_set('soap.wsdl_cache_enabled', false);
The class QSoapService has an overall complexity of 72 which is very high. The configured complexity threshold is 50. Open
class QSoapService extends QBaseClass {
public static $DefaultNamespace = 'http://qcubed.defaultnamespace.com';
protected $objMethodArray = array();
protected $strNamespace;
- Exclude checks
Method SetupSoapMethods
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function SetupSoapMethods(ReflectionClass $objReflection) {
$objReflectionMethods = $objReflection->getMethods();
if ($objReflectionMethods) foreach ($objReflectionMethods as $objReflectionMethod) {
if ($objReflectionMethod->isPublic() && !$objReflectionMethod->isAbstract() &&
!$objReflectionMethod->isStatic() && !$objReflectionMethod->isConstructor() &&
Function GetClassWrapper
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function GetClassWrapper() {
$strNewClass = sprintf('<?php class %sWrapper extends %s { ', $this->strClassName, $this->strClassName);
foreach ($this->objMethodArray as $objMethod) {
$strParameterArray = array();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method Run
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function Run($strClassName, $strNamespace = null) {
QApplication::$EncodingType = 'UTF-8';
$objWsdlCache = new QCache('soap', QApplication::$ScriptName, 'wsdl', QApplication::$ScriptFilename);
$objDiscoCache = new QCache('soap', QApplication::$ScriptName, 'disco', QApplication::$ScriptFilename);
Method GetClassWrapper
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function GetClassWrapper() {
$strNewClass = sprintf('<?php class %sWrapper extends %s { ', $this->strClassName, $this->strClassName);
foreach ($this->objMethodArray as $objMethod) {
$strParameterArray = array();
Function GetSoapFromPhpCode
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function GetSoapFromPhpCode($strArgumentName) {
// Check to see if it's an object
if ($this->IsObject()) {
if ($this->blnArray)
return sprintf('%s::GetSoapArrayFromArray(%s)', $this->strType, $strArgumentName);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function GetPhpFromSoapCode
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function GetPhpFromSoapCode($strArgumentName) {
// Check to see if it's an object
if ($this->IsObject()) {
if ($this->blnArray)
// Handle Array of Objects
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function Run
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function Run($strClassName, $strNamespace = null) {
QApplication::$EncodingType = 'UTF-8';
$objWsdlCache = new QCache('soap', QApplication::$ScriptName, 'wsdl', QApplication::$ScriptFilename);
$objDiscoCache = new QCache('soap', QApplication::$ScriptName, 'disco', QApplication::$ScriptFilename);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if ($strType != 'void')
$objMethod->ReturnParameter = new QSoapParameter($objMethod->Name . 'Result', $strType, $blnArray, false);
Avoid deeply nested control flow statements. Open
if (array_key_exists($strName, $blnArrayArray))
$blnArray = $blnArrayArray[$strName];
Consider simplifying this complex logical expression. Open
if ($objReflectionMethod->isPublic() && !$objReflectionMethod->isAbstract() &&
!$objReflectionMethod->isStatic() && !$objReflectionMethod->isConstructor() &&
!$objReflectionMethod->isDestructor() &&
($objReflectionMethod->getDeclaringClass()->getName() != 'QBaseClass')) {
$objMethod = new QSoapMethod($objReflectionMethod->getName());
Avoid too many return
statements within this method. Open
default: return parent::__get($strName);
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
default: return parent::__set($strName, $mixValue);
Avoid too many return
statements within this method. Open
return $strArgumentName;
Function GetWsdlMessagePart
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function GetWsdlMessagePart(&$strComplexTypesArray) {
if ($this->blnArray) {
try {
$strType = QType::SoapType($this->strType);
$strArrayTypeName = QSoapService::GetArrayTypeName($strType);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
The method SetupSoapMethods() has a Cyclomatic Complexity of 29. The configured cyclomatic complexity threshold is 10. Open
protected function SetupSoapMethods(ReflectionClass $objReflection) {
$objReflectionMethods = $objReflection->getMethods();
if ($objReflectionMethods) foreach ($objReflectionMethods as $objReflectionMethod) {
if ($objReflectionMethod->isPublic() && !$objReflectionMethod->isAbstract() &&
!$objReflectionMethod->isStatic() && !$objReflectionMethod->isConstructor() &&
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method GetClassWrapper() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public function GetClassWrapper() {
$strNewClass = sprintf('<?php class %sWrapper extends %s { ', $this->strClassName, $this->strClassName);
foreach ($this->objMethodArray as $objMethod) {
$strParameterArray = array();
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method Run() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public static function Run($strClassName, $strNamespace = null) {
QApplication::$EncodingType = 'UTF-8';
$objWsdlCache = new QCache('soap', QApplication::$ScriptName, 'wsdl', QApplication::$ScriptFilename);
$objDiscoCache = new QCache('soap', QApplication::$ScriptName, 'disco', QApplication::$ScriptFilename);
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Missing class import via use statement (line '508', column '23'). Open
$objMethod = new QSoapMethod($objReflectionMethod->getName());
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '284', column '26'). Open
$objReflection = new ReflectionClass($strClassName);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '276', column '24'). Open
$objWsdlCache = new QCache('soap', QApplication::$ScriptName, 'wsdl', QApplication::$ScriptFilename);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '559', column '45'). Open
$objMethod->ReturnParameter = new QSoapParameter($objMethod->Name . 'Result', $strType, $blnArray, false);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '577', column '19'). Open
throw new QCallerException('Unable to determine Parameter Type for Method from PHPDoc Comment: ' . $objReflectionMethod->getName() . '(' . $strName . ')');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '583', column '37'). Open
$objMethod->AddParameter(new QSoapParameter($strName, $strType, $blnArray, $objParameter->isPassedByReference()));
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '277', column '25'). Open
$objDiscoCache = new QCache('soap', QApplication::$ScriptName, 'disco', QApplication::$ScriptFilename);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '42', column '25'). Open
$objReflection = new ReflectionMethod($this->strType, 'AlterSoapComplexTypeArray');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '278', column '32'). Open
$objClassWrapperCache = new QCache('soap', QApplication::$ScriptName, 'class.php', QApplication::$ScriptFilename);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '345', column '37'). Open
$objService->objSoapServer = new SoapServer($objWsdlCache->GetFilePath());
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid using static access to class 'QType' in method '__set'. Open
case 'Name': return ($this->strName = QType::Cast($mixValue, QType::String));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QString' in method 'Run'. Open
if (QString::LastCharacter($strNamespace) == '/')
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method SetupSoapMethods uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$strMatches = array();
preg_match_all ("/[\s]*\*[\s]*@return[\s]+([a-zA-Z0-9_]+)(\[\])?/", $strCommentLine, $strMatches);
if ((count($strMatches) == 3) &&
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'QType' in method 'GetWsdlMessagePart'. Open
return sprintf('<part name="%s" type="xsd:%s"/>', $this->strName, QType::SoapType($this->strType));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method SetupSoapMethods uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
throw new QCallerException('Unable to determine Parameter Type for Method from PHPDoc Comment: ' . $objReflectionMethod->getName() . '(' . $strName . ')');
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'QType' in method '__set'. Open
case 'Reference': return ($this->blnReference = QType::Cast($mixValue, QType::Boolean));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QType' in method 'SetupSoapMethods'. Open
$strType = QType::TypeFromDoc($strType);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QSoapService' in method 'GetWsdlMessagePart'. Open
$strArrayTypeName = QSoapService::GetArrayTypeName($this->strType);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QSoapService' in method 'GetWsdlMessagePart'. Open
$strArrayTypeName = QSoapService::GetArrayTypeName($strType);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QType' in method '__set'. Open
case 'Array': return ($this->blnArray = QType::Cast($mixValue, QType::Boolean));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QType' in method 'SetupSoapMethods'. Open
$strType = QType::TypeFromDoc($strTypeArray[$strName]);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QSoapService' in method 'GetWsdlMessagePart'. Open
QSoapService::AlterComplexTypesArrayForArrayType($strArrayTypeName, 'xsd1:' . $this->strType, $strComplexTypesArray);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method GetWsdlMessagePart uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
try {
return sprintf('<part name="%s" type="xsd:%s"/>', $this->strName, QType::SoapType($this->strType));
} catch (QInvalidCastException $objExc) {}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'QType' in method 'GetWsdlMessagePart'. Open
$strType = QType::SoapType($this->strType);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QSoapService' in method 'GetWsdlMessagePart'. Open
QSoapService::AlterComplexTypesArrayForArrayType($strArrayTypeName, $strType, $strComplexTypesArray);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QType' in method '__set'. Open
case 'Type': return ($this->strType= QType::Cast($mixValue, QType::String));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QType' in method '__set'. Open
case 'Name': return ($this->strName = QType::Cast($mixValue, QType::String));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QType' in method '__set'. Open
case 'ReturnParameter': return ($this->objReturnParameter = QType::Cast($mixValue, 'QSoapParameter'));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using empty try-catch blocks in GetWsdlMessagePart. Open
} catch (QInvalidCastException $objExc) {}
- Read upRead up
- Exclude checks
EmptyCatchBlock
Since: 2.7.0
Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.
Example
class Foo {
public function bar()
{
try {
// ...
} catch (Exception $e) {} // empty catch block
}
}
Source https://phpmd.org/rules/design.html#emptycatchblock
Avoid using empty try-catch blocks in GetWsdlMessagePart. Open
} catch (QInvalidCastException $objExc) {}
- Read upRead up
- Exclude checks
EmptyCatchBlock
Since: 2.7.0
Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.
Example
class Foo {
public function bar()
{
try {
// ...
} catch (Exception $e) {} // empty catch block
}
}
Source https://phpmd.org/rules/design.html#emptycatchblock
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function __set($strName, $mixValue) {
try {
switch ($strName) {
case 'Name': return ($this->strName = QType::Cast($mixValue, QType::String));
case 'Type': return ($this->strType= QType::Cast($mixValue, QType::String));
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 154.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Avoid excessively long variable names like $objReflectionProperties. Keep variable name length under 20. Open
$objReflectionProperties = $objReflection->getStaticProperties();
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $strOutputParameterArray. Keep variable name length under 20. Open
$strOutputParameterArray = array();
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $strParameterDefinition. Keep variable name length under 20. Open
$strParameterDefinition = sprintf('%s %s$%s',
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $strInputParameterArray. Keep variable name length under 20. Open
$strInputParameterArray = array();
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
The method GetWsdlPortType is not named in camelCase. Open
protected function GetWsdlPortType() {
$strToReturn = '<portType name="PortType">';
foreach ($this->objMethodArray as $objMethod)
$strToReturn .= $objMethod->GetWsdlPortTypeOperation();
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method GetDisco is not named in camelCase. Open
protected function GetDisco() {
$strUrl = $this->GetLocation();
$strToReturn = '<discovery xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' .
'xmlns="http://schemas.xmlsoap.org/disco/">';
$strToReturn .= sprintf('<contractRef ref="%s?wsdl" docRef="%s" xmlns="http://schemas.xmlsoap.org/disco/scl/" />', $strUrl, $strUrl);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method GetWsdlTypes is not named in camelCase. Open
public function GetWsdlTypes($strComplexTypesArray) {
$strToReturn = sprintf('<types><schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="%s" ' .
'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">',
$this->strNamespace);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method GetPhpFromSoapCode is not named in camelCase. Open
public function GetPhpFromSoapCode($strArgumentName) {
// Check to see if it's an object
if ($this->IsObject()) {
if ($this->blnArray)
// Handle Array of Objects
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method GetParameter is not named in camelCase. Open
public function GetParameter($strName) {
if (array_key_exists($strName, $this->objParameters))
return $this->objParameters[$strName];
else
return null;
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method GetArrayTypeName is not named in camelCase. Open
public static function GetArrayTypeName($strType) {
return sprintf('ArrayOf%s', ucfirst($strType));
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method GetSoapFromPhpCode is not named in camelCase. Open
public function GetSoapFromPhpCode($strArgumentName) {
// Check to see if it's an object
if ($this->IsObject()) {
if ($this->blnArray)
return sprintf('%s::GetSoapArrayFromArray(%s)', $this->strType, $strArgumentName);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method GetAllParameters is not named in camelCase. Open
public function GetAllParameters() {
return $this->objParameters;
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method GetWsdlMessagePart is not named in camelCase. Open
public function GetWsdlMessagePart(&$strComplexTypesArray) {
if ($this->blnArray) {
try {
$strType = QType::SoapType($this->strType);
$strArrayTypeName = QSoapService::GetArrayTypeName($strType);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method Display is not named in camelCase. Open
public function Display() {
$strParameters = '';
foreach ($this->objParameters as $objParameter)
$strParameters .= ', ' . $objParameter->Display();
if ($strParameters)
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method Run is not named in camelCase. Open
public static function Run($strClassName, $strNamespace = null) {
QApplication::$EncodingType = 'UTF-8';
$objWsdlCache = new QCache('soap', QApplication::$ScriptName, 'wsdl', QApplication::$ScriptFilename);
$objDiscoCache = new QCache('soap', QApplication::$ScriptName, 'disco', QApplication::$ScriptFilename);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method DisplayReturn is not named in camelCase. Open
public function DisplayReturn() {
return sprintf('%s%s',
$this->strType,
($this->blnArray) ? '[]' : '');
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method GetClassWrapper is not named in camelCase. Open
public function GetClassWrapper() {
$strNewClass = sprintf('<?php class %sWrapper extends %s { ', $this->strClassName, $this->strClassName);
foreach ($this->objMethodArray as $objMethod) {
$strParameterArray = array();
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method GetLocation is not named in camelCase. Open
public function GetLocation() {
return sprintf('http%s://%s%s',
(array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS']) ? 's' : '',
$_SERVER['HTTP_HOST'],
QApplication::$ScriptName);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method IsObject is not named in camelCase. Open
public function IsObject() {
switch ($this->strType) {
case QType::String:
case QType::Integer:
case QType::Float:
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method GetWsdlBindingOperation is not named in camelCase. Open
public function GetWsdlBindingOperation($strNamespace) {
$strSoapBody = sprintf('<soap:body use="encoded" namespace="%s/%s" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>',
$strNamespace, $this->strName);
return sprintf('<operation name="%s"><soap:operation soapAction="%s/%s"/>' .
'<input>%s</input>' .
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method GetWsdlService is not named in camelCase. Open
protected function GetWsdlService() {
$strToReturn = sprintf('<service name="%s"><documentation/>', $this->strClassName);
$strToReturn .= '<port name="Port" binding="tns:Binding">';
$strToReturn .= sprintf('<soap:address location="%s"/></port></service>', $this->GetLocation());
return $strToReturn;
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method GetWsdl is not named in camelCase. Open
protected function GetWsdl() {
$strToReturn = sprintf('<definitions name="%s" ' .
'targetNamespace="%s" ' .
'xmlns="http://schemas.xmlsoap.org/wsdl/" ' .
'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' .
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method Display is not named in camelCase. Open
public function Display() {
return sprintf('%s%s %s$%s',
$this->strType,
($this->blnArray) ? '[]' : '',
($this->blnReference) ? '&' : '',
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method AddParameter is not named in camelCase. Open
public function AddParameter(QSoapParameter $objParameter) {
$this->objParameters[$objParameter->Name] = $objParameter;
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method GetWsdlPortTypeOperation is not named in camelCase. Open
public function GetWsdlPortTypeOperation() {
return sprintf('<operation name="%s">' .
'<input message="tns:%sRequest"/>' .
'<output message="tns:%sResponse"/>' .
'</operation>',
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method AlterComplexTypesArrayForArrayType is not named in camelCase. Open
public static function AlterComplexTypesArrayForArrayType($strArrayTypeName, $strType, &$strComplexTypesArray) {
if (!array_key_exists($strArrayTypeName, $strComplexTypesArray))
$strComplexTypesArray[$strArrayTypeName] = sprintf(
'<complexType name="%s"><complexContent><restriction base="soapenc:Array">' .
'<attribute ref="soapenc:arrayType" wsdl:arrayType="%s[]"/>' .
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method GetWsdlMethodMessages is not named in camelCase. Open
public function GetWsdlMethodMessages(&$strComplexTypesArray) {
$strRequest = '';
foreach ($this->objParameters as $objParameter)
$strRequest .= $objParameter->GetWsdlMessagePart($strComplexTypesArray);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method GetWsdlBinding is not named in camelCase. Open
protected function GetWsdlBinding() {
$strToReturn = '<binding name="Binding" type="tns:PortType"><soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>';
foreach ($this->objMethodArray as $objMethod)
$strToReturn .= $objMethod->GetWsdlBindingOperation($this->strNamespace);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method SetupSoapMethods is not named in camelCase. Open
protected function SetupSoapMethods(ReflectionClass $objReflection) {
$objReflectionMethods = $objReflection->getMethods();
if ($objReflectionMethods) foreach ($objReflectionMethods as $objReflectionMethod) {
if ($objReflectionMethod->isPublic() && !$objReflectionMethod->isAbstract() &&
!$objReflectionMethod->isStatic() && !$objReflectionMethod->isConstructor() &&
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}