Fix phpstan issues

main
Jordi Boggiano 4 years ago
parent 7b273e2e25
commit 80505e745e
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -73,7 +73,7 @@ before_script:
script:
- if [[ $PHPSTAN == "1" ]]; then
bin/composer require --dev phpstan/phpstan:^0.12 phpunit/phpunit:^7.5 --no-update &&
bin/composer update phpstan/* phpunit/* sebastian/* --with-dependencies &&
bin/composer update phpstan/* phpunit/* sebastian/* --with-all-dependencies &&
vendor/bin/phpstan analyse --configuration=phpstan/config.neon;
else
vendor/bin/simple-phpunit;

@ -35,9 +35,6 @@ parameters:
# variable defined in eval
- '~^Undefined variable: \$res$~'
# erroneous detection of missing const, see https://github.com/phpstan/phpstan/issues/2960
- '~^Access to undefined constant ZipArchive::LIBZIP_VERSION.$~'
# we don't have different constructors for parent/child
- '~^Unsafe usage of new static\(\)\.$~'

@ -61,8 +61,8 @@ class ClassMapGenerator
*/
public static function createMap($path, $blacklist = null, IOInterface $io = null, $namespace = null, $autoloadType = null, &$scannedFiles = array())
{
$basePath = $path;
if (is_string($path)) {
$basePath = $path;
if (is_file($path)) {
$path = array(new \SplFileInfo($path));
} elseif (is_dir($path)) {

@ -86,6 +86,7 @@ EOT
if ($candidates) {
$reqResults = array();
foreach ($candidates as $candidate) {
$candidateConstraint = null;
if ($candidate->getName() === $require) {
$candidateConstraint = new Constraint('=', $candidate->getVersion());
$candidateConstraint->setPrettyString($candidate->getPrettyVersion());
@ -98,6 +99,11 @@ EOT
}
}
// safety check for phpstan, but it should not be possible to get a candidate out of findPackagesWithReplacersAndProviders without a constraint matching $require
if (!$candidateConstraint) {
continue;
}
foreach ($links as $link) {
if (!$link->getConstraint()->matches($candidateConstraint)) {
$reqResults[] = array(

@ -411,6 +411,7 @@ class Solver
}
}
}
unset($literal);
$l1retry = true;
while ($l1retry) {

@ -396,7 +396,7 @@ class Installer
$pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher);
// solve dependencies
$solver = new Solver($policy, $pool, $this->io, $repositorySet);
$solver = new Solver($policy, $pool, $this->io);
try {
$lockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
$ruleSetSize = $solver->getRuleSetSize();
@ -556,7 +556,7 @@ class Installer
$pool = $repositorySet->createPoolWithAllPackages();
$solver = new Solver($policy, $pool, $this->io, $repositorySet);
$solver = new Solver($policy, $pool, $this->io);
try {
$nonDevLockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
$solver = null;
@ -615,7 +615,7 @@ class Installer
$pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher);
// solve dependencies
$solver = new Solver($policy, $pool, $this->io, $repositorySet);
$solver = new Solver($policy, $pool, $this->io);
try {
$lockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
$solver = null;

@ -210,12 +210,12 @@ class InstallationManager
continue;
}
if ($opType === 'install' || $opType === 'uninstall') {
$package = $operation->getPackage();
$initialPackage = null;
} elseif ($opType === 'update') {
if ($opType === 'update') {
$package = $operation->getTargetPackage();
$initialPackage = $operation->getInitialPackage();
} else {
$package = $operation->getPackage();
$initialPackage = null;
}
$installer = $this->getInstaller($package->getType());

@ -228,6 +228,8 @@ abstract class BasePackage implements PackageInterface
case PackageInterface::DISPLAY_DIST_REF:
$reference = $this->getDistReference();
break;
default:
throw new \UnexpectedValueException('Display mode '.$displayMode.' is not supported');
}
// if source reference is a sha1 hash -- truncate

@ -206,6 +206,8 @@ interface PackageInterface
* @param bool $truncate If the source reference is a sha1 hash, truncate it
* @param int $displayMode One of the DISPLAY_ constants on this interface determining display of references
* @return string version
*
* @psalm-param self::DISPLAY_SOURCE_REF_IF_DEV|self::DISPLAY_SOURCE_REF|self::DISPLAY_DIST_REF $displayMode
*/
public function getFullPrettyVersion($truncate = true, $displayMode = self::DISPLAY_SOURCE_REF_IF_DEV);

@ -90,6 +90,7 @@ class PoolBuilderTest extends TestCase
}
$pool = $repositorySet->createPool($request, new NullIO());
$result = array();
for ($i = 1, $count = count($pool); $i <= $count; $i++) {
$result[] = $pool->packageById($i);
}
@ -156,6 +157,7 @@ class PoolBuilderTest extends TestCase
);
$section = null;
$data = array();
foreach ($tokens as $i => $token) {
if (null === $section && empty($token)) {
continue; // skip leading blank

Loading…
Cancel
Save