Skip to content

Comments

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

Merged
alexandre-daubois merged 2 commits intoalexandre-daubois:os-composer-jsonfrom
asgrim:os-composer-json
Dec 3, 2024
Merged

Make (in)compatible OS families non-empty-list or a nullable to express intent better#2
alexandre-daubois merged 2 commits intoalexandre-daubois:os-composer-jsonfrom
asgrim:os-composer-json

Conversation

@asgrim
Copy link

@asgrim asgrim commented Nov 28, 2024

Proposed enhancement to your PR php#116

? $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

: [];
: null;

/** @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

$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