Avoid using undefined variables such as '$extra' which will lead to PHP notices. Open
$extra['node']['stanford_publication']['display']['citation_type'] = [
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$extra' which will lead to PHP notices. Open
return $extra;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid assigning values to variables in if clauses and the like (line '211', column '7'). Open
function stanford_publication_node_delete(NodeInterface $entity) {
if ($citation_entity = _stanford_pubs_get_citation_entity($entity)) {
// Clean up nested Citation entity after node deletion.
$citation_entity->delete();
}
- 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 assigning values to variables in if clauses and the like (line '75', column '5'). Open
function stanford_publication_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
if (
$entity instanceof NodeInterface &&
$entity->bundle() == 'stanford_publication' &&
$display->getComponent('citation_type') &&
- 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
Argument 1 (parent)
is \Drupal\node\NodeInterface
but \Drupal\stanford_publication\Entity\CitationInterface::setParentEntity()
takes \Drupal\Core\Entity\ContentEntityInterface
defined at /code/src/Entity/CitationInterface.php:67
Invalid
$citation_entity->setParentEntity($entity, 'su_publication_citation')
- Exclude checks