You are here

function ClassMirrorSpec::it_marks_required_args_without_types_as_not_optional in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpspec/prophecy/spec/Prophecy/Doubler/Generator/ClassMirrorSpec.php \spec\Prophecy\Doubler\Generator\ClassMirrorSpec::it_marks_required_args_without_types_as_not_optional()

Parameters

ReflectionClass $class:

ReflectionMethod $method:

ReflectionParameter $param1:

File

vendor/phpspec/prophecy/spec/Prophecy/Doubler/Generator/ClassMirrorSpec.php, line 265

Class

ClassMirrorSpec

Namespace

spec\Prophecy\Doubler\Generator

Code

function it_marks_required_args_without_types_as_not_optional($class, $method, $param1) {
  $class
    ->getName()
    ->willReturn('Custom\\ClassName');
  $class
    ->isInterface()
    ->willReturn(false);
  $class
    ->isFinal()
    ->willReturn(false);
  $class
    ->getMethods(ReflectionMethod::IS_ABSTRACT)
    ->willReturn(array());
  $class
    ->getMethods(ReflectionMethod::IS_PUBLIC)
    ->willReturn(array(
    $method,
  ));
  $method
    ->getName()
    ->willReturn('methodWithArgs');
  $method
    ->isFinal()
    ->willReturn(false);
  $method
    ->isProtected()
    ->willReturn(false);
  $method
    ->isStatic()
    ->willReturn(false);
  $method
    ->returnsReference()
    ->willReturn(false);
  $method
    ->getParameters()
    ->willReturn(array(
    $param1,
  ));
  if (version_compare(PHP_VERSION, '7.0', '>=')) {
    $method
      ->hasReturnType()
      ->willReturn(false);
  }
  $param1
    ->getName()
    ->willReturn('arg_1');
  $param1
    ->isArray()
    ->willReturn(false);
  if (version_compare(PHP_VERSION, '5.4', '>=')) {
    $param1
      ->isCallable()
      ->willReturn(false);
  }
  $param1
    ->getClass()
    ->willReturn(null);
  if (version_compare(PHP_VERSION, '7.0', '>=')) {
    $param1
      ->hasType()
      ->willReturn(false);
  }
  $param1
    ->isDefaultValueAvailable()
    ->willReturn(false);
  $param1
    ->isOptional()
    ->willReturn(false);
  $param1
    ->isPassedByReference()
    ->willReturn(false);
  $param1
    ->allowsNull()
    ->willReturn(true);
  if (defined('HHVM_VERSION')) {
    $param1
      ->getTypehintText()
      ->willReturn(null);
  }
  $classNode = $this
    ->reflect($class, array());
  $methodNodes = $classNode
    ->getMethods();
  $argNodes = $methodNodes['methodWithArgs']
    ->getArguments();
  $argNodes[0]
    ->isOptional()
    ->shouldReturn(false);
}