composer / semver

Semantic versioning utilities with the addition of version constraints parsing and checking.
MIT License
3.15k stars 76 forks source link

Implement a matcher using PHP code generation #71

Closed naderman closed 3 years ago

naderman commented 4 years ago

Instead of directly matching a constraint, implement functions on the constraints to generate code which verifies if a particular version number matches the constraint. In particular the multi constraint should optimize the expression by checking only the minimally necessary boundaries on a conjunctive constraint.

This is useful to generate code in composer install which later gets verified at runtime and needs to be very fast.

stof commented 4 years ago

I'm not sure generating a php matcher is needed in this package. What would be a good fit for this package would be a constraint optimizer (which would reduce a MultiConstraint to as few ranges as possible. https://github.com/Roave/SecurityAdvisoriesBuilder have some code for that.

naderman commented 4 years ago

@stof it's needed for https://github.com/composer/composer/issues/8451 - I don't think this belongs anywhere else. I do agree that more optimization than what is currently implemented in the parser should be implemented as well.

stof commented 4 years ago

@Seldaek should this be closed thanks to the referenced PRs or is there still something to do here ?

staabm commented 4 years ago

Ping @naderman. Can this be closed?

Seldaek commented 3 years ago

Closing as I don't think we really want to spend time implementing this, even though it's strictly speaking not done I think. What we have is not php-code generation, but it doesn't seem we really need it.