221 Commits (6a466a120a404d1c5d492e5ca715841c491517fc)

Author SHA1 Message Date
Jordi Boggiano 6a466a120a
Enable strict types on all files 2 years ago
Jordi Boggiano 0db443ba5f
Add visibility to all consts, fixes #10550 2 years ago
Jordi Boggiano 6da38f83a0
Add parameter types to all the things 2 years ago
Jordi Boggiano eda9014bef
Add return types to all code which is not being extended by open source packages 2 years ago
Jordi Boggiano a16ed3d0ed
Add return types to private/internal methods 2 years ago
Jordi Boggiano abdc6893a6
Add void types where no return statement is present 2 years ago
Jordi Boggiano e3d99cac59
Fix phpstan issues, update baseline and pin PHPStan version in 2.2 branch (#10474) 2 years ago
Jordi Boggiano e30a6b0b9b
Add support for ignoring the upper bound of platform requirements using "name+" notation 2 years ago
Jordi Boggiano f509c41280
Upgrade PHPStan to 1.0 (#10253)
Co-authored-by: Martin Herndl <martin@herndl.org>
3 years ago
Martin Herndl 3013674c92
Refactor ignore platform reqs checks (#10079)
Introduces a `PlatformRequirementFilter` with methods that help to decide if a requirement is ignored or not as discussed in #10045 but without changing behaviour.
3 years ago
immeëmosol 50d738eeee
Reaching phpstan level 6 in Composer/DependencyResolver (refs #10159) (#10178) 3 years ago
Jordi Boggiano a6f1e803b1
Use more BasePackage instead of PackageInterface 3 years ago
Jordi Boggiano b209816056
Type annotations 3 years ago
Jordi Boggiano 4bcd860b65
Add more type annotations 3 years ago
Jordi Boggiano b7d770659b
CS fixes 4 years ago
Jordi Boggiano b74afd772b
Merge pull request #9309 from naderman/fix-solver-9290
MultiConflictRule conflict analysis handling on level 1 decisions
4 years ago
Nils Adermann 9338401be7 CS: Typehint array, remove unnecessary docblock, call spl_object_hash once 4 years ago
Nils Adermann 7b4cb9c370 Solver: Prevent infinite recursion in analyzeUnsolvableRule
In complex scenarios reasons for learned rules can themselves be learned
rules caused by other learned rules which had the some of the same
reasons. In this situation iterating over all problem rules requires
keeping track of which rules have previously been analyzed to avoid and
endless loop.

Side effect is that the sorting of problems including learned rules
changes slightly.
4 years ago
Nils Adermann 7f41698157 Solver: on analyze, when reaching last decision > l1 skip other multi rule literals 4 years ago
Nils Adermann 74fb313c39 Separate locked packages from fixed packages in request
Locked packages are basically like removable fixed packages, so we still
only load one version, but we do not require their installation unless
something the user needs requires their use. So they automatically get
removed if they are no longer needed on any update.
4 years ago
Simon Berger 974e7ba296 Removed unneccesary elseifs 4 years ago
Simon Berger 33d7a64df9 Removed unused private functions 4 years ago
Simon Berger a6475a7118 Removed unused variables, properties and parameters of private functions 4 years ago
Yanick Witschi bd6f62c535 Consistently reuse the new PlatformRepository::isPlatformPackage() method 4 years ago
Nils Adermann 3f5dde9873 Solver: Ensure multi conflict rules still get added to learned pool 4 years ago
Nils Adermann edef748169 Solver: Clarify when/why undecided literals can get skipped in analyze 4 years ago
Nils Adermann 851050e85c Solver: multiconflict analyze handles positive decision same as regular literal 4 years ago
Nils Adermann 6e05345be7 Solver: Move analyze handling of multiconflict rule to clearer location
This way we're not looking at the previous decision at the top of the
loop but working with the current decision at the bottom
4 years ago
Nils Adermann b34f916470 Solver: No need to check previous decision if we reached the first one 4 years ago
Nils Adermann 2631210493 Solver: analyze multi conflict rules in conflict resolution correctly 4 years ago
Jordi Boggiano c0f5c13516
RuleSetGenerator instance does not need to be kept around anymore 4 years ago
Jordi Boggiano e85da00dff
Add a way to ignore only some packages in --ignore-platform-reqs, and make the platform check ignore those packages which were ignored as requirements, fixes #8861 4 years ago
Jordi Boggiano 81bf47ffa2
Use fully qualified calls in hot classes 4 years ago
Jordi Boggiano 80505e745e
Fix phpstan issues 4 years ago
Jordi Boggiano 9cab8c10cc
Merge branch 'master' into 2.0 4 years ago
arai 1f08138379 Delete variable 4 years ago
Jordi Boggiano c41df325d8
Remove RepositorySet from Solver and remove getPool from RepositorySet 4 years ago
Jordi Boggiano 3fc7e10c5c
Improve error reporting of solver issues, refs #7779
Fixes #8525
Fixes #6513
4 years ago
Nils Adermann 5bdc0fc9c5 Request jobs replaced by root require / fixed package
The only type of request job remaining was "install" which is really a
root requirement. The only other kind of input for the solver is now a
set of fixed packages.

Rules have been updated to account for only two kinds of former job
reason: FIXED or ROOT_REQUIRE. The job property has always been
redundant and has been removed, since reasonData suffices.

Problem reasons are always rules, so the unnecessary wrapping in an
array has been removed.

We now only ever generate a single rule per root require or fixed
package, so there is no need for the solver to special handle disabling
"jobs" anymore, the rule can just be disabled as usual.

For consistency special handling of rules for jobs in problems has been
integrated into the rule class like all other rule reasons. As part of
this change the error message for root requirements has been improved a
bit to make it clearer where the package installation request came from.

The word job has also been removed from operations, which are called
operations, not jobs.
4 years ago
Nils Adermann 6f9b1e76e3 Remove disableRules code from Solver, leftover from original C code
This goes back to an input option to install recommended packages, which
would in turn allow removal of these packages if that was needed to
resolve the rest. This was supported in very early versions of Composer
with suggested packages. We later realized this was not useful in the
context of a project based dependency manager with a lock file, so it
was removed but the solver was never cleaned up.
5 years ago
Nils Adermann 25de5218c3 Reunify lock and local repo transaction code and apply the same sorting 5 years ago
Nils Adermann 0ff07015a1 Only load package info from lock file for fixed packages
As a result some lock file packages are no longer in the pool, so the
former installed map, now present map cannot use package ids anymore

Need to revisit some more code later to simplify this, todo notes left
5 years ago
Nils Adermann 4481cc4a88 Allow an install request for a package name which is already fixed
Ensures packages get loaded from locked repo correctly. We may not want
to support this particular use-case at all, but for now it fixes the
existing test, so we may want to revisit this later.
5 years ago
Nils Adermann 9053d74282 Merge branch '2.0' into solve-without-installed
* 2.0: (101 commits)
  SVN: hide passwords for debug output
  Free $solver asap
  fixes #8179
  [minor] Fixed a typo in the CHANGELOG.md.
  Update deps
  Update changelog
  Revert "Allow overriding self-update target file with envvar COMPOSER_SELF_UPDATE_TARGET" Revert "Add docs for COMPOSER_SELF_UPDATE_TARGET, refs #8151"
  Add docs for COMPOSER_SELF_UPDATE_TARGET, refs #8151
  Fix display of HHVM warning appearing when HHVM is not in use, fixes #8138
  Read classmap-authoritative and apcu-autoloader from project config when installing via create-project, fixes #8155
  Use possessive quantifiers
  Update xdebug-handler to 1.3.3
  fixes #8159
  Allow overriding self-update target file with envvar COMPOSER_SELF_UPDATE_TARGET
  flag should come before script name
  use full command name, not abbreviated/alias
  modify text
  Document the alternatives to disable the default script timeout
  Anchor pattern
  Fix URL resolution for Composer repositories
  ...
5 years ago
Matthew Brown 65903aacfd Fix type issues (#7996)
* Fix type issues found by Psalm
5 years ago
Nils Adermann 10ada7bf82 Refactor Installer class into separate install and update processes
- Introduce separate Lock and LocalRepo transactions, one for changes
  to the lock file, one for changes to locally installed packages based
  on lock file
- Remove various hacks to keep dev dependencies updated and
  incorporated the functionality into the transaction classes
- Remove installed repo, there are now local repo, locked repo and
  platform repo
- Remove access to local repo from solver, only supply locked packages
- Update can now be run to modify the lock file but not install packages
  to local repo
5 years ago
Nils Adermann 287419f6a0 Merge branch 'master' into 2.0
* master:
  Follow up to #7946 test: add solver flag to assert path execution
  Fix tests
  Make sure config command output is also output on --quiet so that warnings can be hidden, fixes #7963
  Recognize composer-plugin-api as a platform package, fixes #7951
  Quote wildcards to avoid issues in some shells, fixes #7960
  Avoid dumping null values for dist reference/shasum and source reference, fixes #7955
  Soften hard exit after revert of composer file
  Make unixy proxy code POSIX compatible
  Update aliases.md
  Same but for Problem.php
  Better error message for present but incompatible versions
  Fix inconsistent casing
  Don't do (new Foo())->bar() - not 5.3-compatible
  Support identifying the HHVM version when not running with HHVM
5 years ago
Nils Adermann 29ff6a40ae Follow up to #7946 test: add solver flag to assert path execution 5 years ago
Nils Adermann 728e57b9e0 Merge branch 'master' into 2.0
* master:
  Fix solver problem exceptions with unexpected contradictory "Conclusions"
  Also load config into IO if not freshly created
  Only load configuration into IO if IO is available
  Fix defaultRepos fallback does not use auth config
  Add warning/info msg when tweaking disable-tls setting to avoid confusion, fixes #7935
5 years ago
Nils Adermann 6b2edeae56 Fix solver problem exceptions with unexpected contradictory "Conclusions"
This 5 character fix comes with a solver test as well as a functional
installer test essentially verifying the same thing. The solver test is
more useful when working on the solver. But the functional test is less
likely to be accidentally modified incorrectly during refactoring, as
every single package, version and link in the rather complex test
scenario is essential, and a modified version of the test may very well
still result in a successful installation but no longer verify the bug
described below.

Background:

In commit 451bab1c2c from May 19, 2012 I
refactored literals from complex objects into pure integers to reduce
memory consumption. The absolute value of an integer literal is the id
of the package it refers to in the package pool. The sign indicates
whether the package should be installed (positive) or removed (negative),

So a major part of the refactoring was swapping this call:

$literal->getPackageId()

For this:

abs($literal)

Unintentionally in line 554/523 I incorrectly applied this change to the
line:

$this->literalFromId(-$literal->getPackageId());

It was converted to:

-abs($literal);

The function literalFromId used to create a new literal object. By using
the abs() function this change essentially forces the resulting literal
to be negative, while the minus sign previously inverted the literal, so
positive into negative and vice versa.

This particular line is in a function meant to analyze a conflicting
decision during dependency resolution and to draw a conclusion from it,
then revert the state of the solver to an earlier position, and attempt
to solve the rest of the rules again with this new "learned" conclusion.

Because of this bug these conclusions could only ever occur in the
negative, e.g. "don't install package X". This is by far the most likely
scenario when the solver reaches this particular line, but there are
exceptions.

If you experienced a solver problem description that contained a
statement like "Conclusion: don't install vendor/package 1.2.3" which
directly contradicted other statements listed as part of the problem,
this could likely have been the cause.
5 years ago