/**
  * @param string $classDefinition
  *
  * @return string
  */
 public function rewrite($classDefinition)
 {
     $this->namespaceResolver->analyse($classDefinition);
     $this->reset();
     $tokens = $this->stripTypeHints(token_get_all($classDefinition));
     $tokensToString = $this->tokensToString($tokens);
     return $tokensToString;
 }
 function it_delegates_analysis_to_wrapped_resolver(NamespaceResolver $namespaceResolver)
 {
     $this->analyse('foo');
     $namespaceResolver->analyse('foo')->shouldhaveBeenCalled();
 }
    function it_indexes_invalid_typehints(TypeHintIndex $typeHintIndex, NamespaceResolver $namespaceResolver)
    {
        $e = new DisallowedScalarTypehintException();
        $namespaceResolver->analyse(Argument::any())->shouldBeCalled();
        $namespaceResolver->resolve('Foo')->willReturn('Foo');
        $namespaceResolver->resolve('int')->willThrow($e);
        $this->rewrite('
        <?php

        class Foo
        {
            public function bar(int $bar)
            {
            }
        }

        ');
        $typeHintIndex->addInvalid('Foo', 'bar', '$bar', $e)->shouldHaveBeenCalled();
        $typeHintIndex->add('Foo', 'bar', '$bar', Argument::any())->shouldNotHaveBeenCalled();
    }