Avoid unused parameters such as '$c'. Open
$this->_set($this->_createContainerId($container), function (BaseContainerInterface $c, $previous = null) use ($container) {
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused local variables such as '$_value'. Open
foreach ($this->serviceDefinitions as $_key => $_value) {
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Avoid unused parameters such as '$container'. Open
protected function _createContainerId(BaseContainerInterface $container)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused parameters such as '$previous'. Open
$this->_set($this->_createContainerId($container), function (BaseContainerInterface $c, $previous = null) use ($container) {
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid assigning values to variables in if clauses and the like (line '72', column '15'). Open
protected function _getDelegated($id)
{
if (!($having = $this->_hasDelegated($id))) {
throw $this->_createNotFoundException(sprintf('Could not create service for ID "%1$s": no service defined', $id));
}
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid variables with short names like $id. Configured minimum length is 3. Open
protected function _hasDelegated($id)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $id. Configured minimum length is 3. Open
protected function _getDelegated($id)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $id. Configured minimum length is 3. Open
$id = uniqid(static::CONTAINER_ID_PREFIX);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The variable $_container is not named in camelCase. Open
protected function _hasDelegated($id)
{
$containers = $this->_getContainersReversed();
foreach ($containers as $_container) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_key is not named in camelCase. Open
protected function _getContainers()
{
$containers = array();
foreach ($this->serviceDefinitions as $_key => $_value) {
$service = $this->_get($_key);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_key is not named in camelCase. Open
protected function _getContainers()
{
$containers = array();
foreach ($this->serviceDefinitions as $_key => $_value) {
$service = $this->_get($_key);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_key is not named in camelCase. Open
protected function _getContainers()
{
$containers = array();
foreach ($this->serviceDefinitions as $_key => $_value) {
$service = $this->_get($_key);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_container is not named in camelCase. Open
protected function _hasDelegated($id)
{
$containers = $this->_getContainersReversed();
foreach ($containers as $_container) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_container is not named in camelCase. Open
protected function _hasDelegated($id)
{
$containers = $this->_getContainersReversed();
foreach ($containers as $_container) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_value is not named in camelCase. Open
protected function _getContainers()
{
$containers = array();
foreach ($this->serviceDefinitions as $_key => $_value) {
$service = $this->_get($_key);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The method _hasDelegated is not named in camelCase. Open
protected function _hasDelegated($id)
{
$containers = $this->_getContainersReversed();
foreach ($containers as $_container) {
- 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 _add is not named in camelCase. Open
protected function _add(BaseContainerInterface $container)
{
$this->_set($this->_createContainerId($container), function (BaseContainerInterface $c, $previous = null) use ($container) {
return $container;
});
- 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 _getContainersReversed is not named in camelCase. Open
protected function _getContainersReversed()
{
return array_reverse($this->_getContainers());
}
- 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 _getContainers is not named in camelCase. Open
protected function _getContainers()
{
$containers = array();
foreach ($this->serviceDefinitions as $_key => $_value) {
$service = $this->_get($_key);
- 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 _createContainerId is not named in camelCase. Open
protected function _createContainerId(BaseContainerInterface $container)
{
do {
$id = uniqid(static::CONTAINER_ID_PREFIX);
} while ($this->_hasDefinition($id));
- 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 _getDelegated is not named in camelCase. Open
protected function _getDelegated($id)
{
if (!($having = $this->_hasDelegated($id))) {
throw $this->_createNotFoundException(sprintf('Could not create service for ID "%1$s": no service defined', $id));
}
- 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() {
}
}