Skip to content

\CRM\CivixBundle\Builder\PhpData::save set strict flag on in_array#382

Merged
totten merged 1 commit intototten:masterfrom
semseysandor:phpdata-save
Jan 18, 2025
Merged

\CRM\CivixBundle\Builder\PhpData::save set strict flag on in_array#382
totten merged 1 commit intototten:masterfrom
semseysandor:phpdata-save

Conversation

@semseysandor
Copy link
Copy Markdown
Contributor

PhpData::save generates strange output from the input data on PHP<8.0.0.
For example during convert-entity command:

If the legacy xml entity files contains <import> or <export> elements in a <field> element

<field>
...
  <import>true</import>
  <export>true</export>
...
</field>

will be converted in the generated .entityType.php to

'usage' => [
  constant(fn() => 'import'),
  'export',
  'duplicate_matching',
],

which emits a PHP WARNING when evaluated.

This is due to loose type checking in in_array() in PHP prior to 8.0.0

This PR adds strict type checking to in_array().

@totten
Copy link
Copy Markdown
Owner

totten commented Jan 18, 2025

Nice catch @semseysandor. I tried it out -- and that new output definitely makes more sense!

@totten totten merged commit c67746b into totten:master Jan 18, 2025
@semseysandor semseysandor deleted the phpdata-save branch January 18, 2025 11:26
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.

2 participants