These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Drupal\DrupalExtension\Context\Annotation; |
||
4 | |||
5 | use Behat\Behat\Context\Annotation\AnnotationReader; |
||
6 | use Drupal\DrupalExtension\Hook\Dispatcher; |
||
7 | use ReflectionMethod; |
||
8 | |||
9 | /** |
||
10 | * Annotated contexts reader. |
||
11 | * |
||
12 | * @see \Behat\Behat\Context\Loader\AnnotatedLoader |
||
13 | */ |
||
14 | class Reader implements AnnotationReader |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | private static $regex = '/^\@(beforenodecreate|afternodecreate|beforetermcreate|aftertermcreate|beforeusercreate|afterusercreate)(?:\s+(.+))?$/i'; |
||
21 | |||
22 | /** |
||
23 | * @var string[] |
||
24 | */ |
||
25 | private static $classes = array( |
||
26 | 'afternodecreate' => 'Drupal\DrupalExtension\Hook\Call\AfterNodeCreate', |
||
27 | 'aftertermcreate' => 'Drupal\DrupalExtension\Hook\Call\AfterTermCreate', |
||
28 | 'afterusercreate' => 'Drupal\DrupalExtension\Hook\Call\AfterUserCreate', |
||
29 | 'beforenodecreate' => 'Drupal\DrupalExtension\Hook\Call\BeforeNodeCreate', |
||
30 | 'beforetermcreate' => 'Drupal\DrupalExtension\Hook\Call\BeforeTermCreate', |
||
31 | 'beforeusercreate' => 'Drupal\DrupalExtension\Hook\Call\BeforeUserCreate', |
||
32 | ); |
||
33 | |||
34 | /** |
||
35 | * {@inheritDoc} |
||
36 | */ |
||
37 | public function readCallee($contextClass, ReflectionMethod $method, $docLine, $description) |
||
38 | { |
||
39 | |||
40 | if (!preg_match(self::$regex, $docLine, $match)) { |
||
41 | return null; |
||
42 | } |
||
43 | |||
44 | $type = strtolower($match[1]); |
||
45 | $class = self::$classes[$type]; |
||
46 | $pattern = isset($match[2]) ? $match[2] : null; |
||
47 | $callable = array($contextClass, $method->getName()); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
48 | |||
49 | return new $class($pattern, $callable, $description); |
||
50 | } |
||
51 | } |
||
52 |