GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — 8.x-2.x ( bdb6af...21ed67 )
by Devin
56:27
created

UndoContext::runAll()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 0
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Acquia\DFExtension\Context;
4
5
use Drupal\DrupalExtension\Context\DrupalSubContextBase;
6
7
/**
8
 * A context allowing easy undo of anything done during a scenario.
9
 */
10
class UndoContext extends DrupalSubContextBase {
11
12
  /**
13
   * Whether the stack is locked (i.e., not accepting new operations).
14
   *
15
   * @var bool
16
   */
17
  protected $locked = FALSE;
18
19
  /**
20
   * The operation stack.
21
   *
22
   * @var array
23
   */
24
  protected $stack = [];
25
26
  /**
27
   * Executes all undo operations in the stack.
28
   *
29
   * @AfterScenario
30
   */
31
  public function runAll() {
32
    $this->locked = TRUE;
33
34
    while ($this->stack) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->stack of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
35
      $operation = array_pop($this->stack);
36
      call_user_func_array($operation[0], $operation[1]);
37
    }
38
39
    $this->locked = FALSE;
40
  }
41
42
  /**
43
   * Adds an operation to the undo stack.
44
   *
45
   * @param callable $callback
46
   *   The function to call.
47
   * @param array $arguments
48
   *   (optional) Arguments to pass to the callback. None of the arguments can
49
   *   be passed by reference.
50
   */
51
  public function push(callable $callback, array $arguments = []) {
0 ignored issues
show
Unused Code introduced by
The parameter $callback is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $arguments is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
52
    if ($this->locked == FALSE) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
53
      $this->stack[] = func_get_args();
54
    }
55
  }
56
57
}
58