Example #1
0
 /**
  * {@inheritdoc}
  */
 public function addMethod(MethodInterface $method)
 {
     if ($method instanceof InterfaceMethod) {
         throw new InvalidArgumentException(sprintf('Class method %s must not be instance of "InterfaceMethod".', $method->getName()));
     }
     AbstractWriter::addMethod($method);
 }
Example #2
0
 /**
  * getObjectBody
  *
  * @param Writer $writer
  *
  * @return Writer
  */
 protected function writeObjectBody(WriterInterface $writer)
 {
     $this->writeConstants($writer);
     return parent::writeObjectBody($writer);
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 protected function writeObjectBody(WriterInterface $writer)
 {
     $this->writeTraits($writer, $resolver = $this->getImportResolver());
     $this->writeProperties($writer, $resolver);
     return parent::writeObjectBody($writer);
 }
 /**
  * completeTraitList
  *
  * @param WriterInterface $writer
  * @param ImportResolver $resolver
  *
  * @return void
  */
 protected function completeTraitList(WriterInterface $writer, ImportResolver $resolver)
 {
     $useRpl = [];
     $cflRpl = [];
     $replUse = isset($this->replacements['trait_use_as']);
     $replCfl = isset($this->replacements['trait_conflict']);
     foreach ($this->traits as $trait) {
         if ($replUse) {
             $useRpl = array_merge($useRpl, array_filter($this->replacements['trait_use_as'], function ($def) use($trait) {
                 return AbstractWriter::trimNs($trait) === AbstractWriter::trimNs($def[0]);
             }));
         }
         if ($replCfl) {
             $cflRpl = array_merge($cflRpl, array_filter($this->replacements['trait_conflict'], function ($def) use($trait, $resolver) {
                 // conflicting trait exists:
                 $cflExists = false;
                 foreach ($this->traits as $strait) {
                     if ($clfExists = AbstractWriter::trimNs($strait) === AbstractWriter::trimNs($def[1])) {
                         break;
                     }
                 }
                 return $clfExists && AbstractWriter::trimNs($trait) === AbstractWriter::trimNs($def[0]);
             }));
         }
     }
     if (empty($useRpl) && empty($cflRpl)) {
         $writer->appendln(';');
         return;
     }
     $writer->appendln(' {')->indent();
     foreach ($useRpl as $urpl) {
         list($trait, $method, $replacement, $visibility) = $urpl;
         $this->writeUseReplacement($writer, $resolver->getAlias($trait), $method, $replacement, $visibility);
     }
     foreach ($cflRpl as $crpl) {
         list($trait, $conflict, $method) = $crpl;
         $this->writeConflictReplacement($writer, $resolver->getAlias($trait), $method, $resolver->getAlias($conflict));
     }
     $writer->outdent()->writeln('}');
 }