Skip to content

Commit

Permalink
Prepare for PHP7.2 (#708)
Browse files Browse the repository at this point in the history
* Run composer with --ignore-platform-reqs for nightly
* Run composer with weak deprecation warnings (PHPUnit still uses each())
* Rewrote usage of each() (which is deprecated in PHP7.2)
  • Loading branch information
Hidde Boomsma authored and theofidry committed Mar 24, 2017
1 parent b428491 commit 0976436
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ php:
- '5.6'
- '7.0'
- '7.1'
- nightly

matrix:
fast_finish: true
Expand All @@ -33,8 +32,13 @@ matrix:
env: SYMFONY_VERSION='~3.2.0'
- php: '7.1'
env: SYMFONY_VERSION='~3.3.0@dev'
- php: 'nightly'
env:
- COMPOSER_FLAGS='--ignore-platform-reqs'
- SYMFONY_DEPRECATIONS_HELPER='weak'
- SYMFONY_VERSION='~3.3.0@dev'
allow_failures:
- php: nightly
- php: 'nightly'
- env: SYMFONY_VERSION='~3.3.0@dev'

install:
Expand Down
26 changes: 16 additions & 10 deletions src/Nelmio/Alice/Fixtures/Fixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,19 +368,25 @@ protected function getConstructorComponents()
throw new \UnexpectedValueException("The __construct call in object '{$this}' must be defined as an array of arguments or false to bypass it");
}

list($method, $args) = each($constructorValue);
if ($method !== 0) {
if (!is_callable([$this->class, $method])) {
throw new \UnexpectedValueException("Cannot call static method '{$method}' on class '{$this->class}' as a constructor for object '{$this}'");
}
if (!is_array($args)) {
throw new \UnexpectedValueException("The static '{$method}' call in object '{$this}' must be given an array");
foreach ($constructorValue as $method => $args) {
if ($method !== 0) {
if (!is_callable([$this->class, $method])) {
throw new \UnexpectedValueException(
"Cannot call static method '{$method}' on class '{$this->class}' as a constructor for object '{$this}'"
);
}

if (!is_array($args)) {
throw new \UnexpectedValueException(
"The static '{$method}' call in object '{$this}' must be given an array"
);
}

return ['method' => $method, 'args' => $args];
}

return ['method' => $method, 'args' => $args];
return ['method' => '__construct', 'args' => $constructorValue];
}

return ['method' => '__construct', 'args' => $constructorValue];
}

/**
Expand Down

0 comments on commit 0976436

Please sign in to comment.