Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Plugin / DMU / Fixer / Implement.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\drupalmoduleupgrader\Plugin\DMU\Fixer\Implement.
6  */
7
8 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Fixer;
9
10 use Drupal\drupalmoduleupgrader\FixerBase;
11 use Pharborist\DocCommentNode;
12 use Pharborist\Objects\ClassMethodNode;
13
14 /**
15  * @Fixer(
16  *  id = "implement"
17  * )
18  */
19 class Implement extends FixerBase {
20
21   public function execute() {
22     /** @var \Pharborist\Objects\ClassNode $class */
23     $class = $this
24       ->target
25       ->getIndexer('class')
26       ->get($this->configuration['target']);
27
28     // Use reflection to get the method definition.
29     list ($interface, $method) = explode('::', $this->configuration['definition']);
30     $interface = new \ReflectionClass($interface);
31     $method = $interface->getMethod($method);
32
33     $node = ClassMethodNode::create($method->getName());
34     $node->setDocComment(DocCommentNode::create('@inheritdoc'));
35     $class->appendMethod($node);
36     $node->matchReflector($method);
37
38     // @TODO There needs to be a way to implement the method body!
39
40     $this->target->save($class);
41   }
42
43 }