Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make (in)compatible OS families non-empty-list or a nullable to express intent better #2

Merged

Conversation

asgrim
Copy link

@asgrim asgrim commented Nov 28, 2024

Proposed enhancement to your PR php#116

@@ -74,17 +75,15 @@ public static function fromComposerCompletePackage(CompletePackageInterface $com
? $phpExtOptions['build-path']
: null;

/** @var list<string> $compatibleOsFamilies */
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not necessary; we need upstream Composer support first


/** @var list<string> $incompatibleOsFamilies */
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not necessary; we need upstream Composer support first

* @param list<OperatingSystemFamily> $compatibleOsFamilies
* @param list<OperatingSystemFamily> $incompatibleOsFamilies
* @param list<ConfigureOption> $configureOptions
* @param non-empty-list<OperatingSystemFamily>|null $compatibleOsFamilies
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key change here is that the OS families can either be null (explicitly not specified in php-ext), or a non-empty-list; I think this helps express intent better, otherwise, maybe someone could try:

  "os-families": []

which does not make sense

if ($input === null) {
return null;
}

$osFamilies = [];
foreach ($input as $value) {
// try to normalize a bit the input
$valueToTry = ucfirst(strtolower($value));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One improvement I didn't do, but I think it could make sense to always lowercase (including the enum values), to avoid case sensitivity nonsense, as this approach isn't flawless.

@alexandre-daubois alexandre-daubois merged commit c9d2677 into alexandre-daubois:os-composer-json Dec 3, 2024
@asgrim asgrim deleted the os-composer-json branch December 4, 2024 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants