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

Update index.php #842

Closed
wants to merge 2 commits into from
Closed

Update index.php #842

wants to merge 2 commits into from

Conversation

hedho
Copy link
Contributor

@hedho hedho commented May 18, 2023

Explanation of changes:

  1. Extracted the runtime options array into a separate variable for better readability.
  2. Used the runtime options array when accessing the context values, making it easier to change the options in the future.
  3. Introduced a null check when accessing the environment variable to avoid warnings if it's not present in the context.
  4. Used the null coalescing operator (??) to provide a default value of null for the environment variable if it's not present in the context.
  5. Simplified the debug variable assignment using the ternary operator and explicit type casting to bool.
  6. Added a use statement to import the $runtimeOptions variable into the anonymous function, allowing access to the options within the function.

hedho added 2 commits May 19, 2023 01:49
Explanation of changes:

1. Extracted the runtime options array into a separate variable for better readability.
2. Used the runtime options array when accessing the context values, making it easier to change the options in the future.
3. Introduced a null check when accessing the environment variable to avoid warnings if it's not present in the context.
4. Used the null coalescing operator (??) to provide a default value of null for the environment variable if it's not present in the context.
5. Simplified the debug variable assignment using the ternary operator and explicit type casting to bool.
6. Added a use statement to import the $runtimeOptions variable into the anonymous function, allowing access to the options within the function.
@codecov
Copy link

codecov bot commented May 18, 2023

Codecov Report

Patch coverage: 51.57% and project coverage change: +0.19 🎉

Comparison is base (558daa1) 50.51% compared to head (d1b92c4) 50.71%.

Additional details and impacted files
@@             Coverage Diff              @@
##              2.3.x     #842      +/-   ##
============================================
+ Coverage     50.51%   50.71%   +0.19%     
+ Complexity     2208     2179      -29     
============================================
  Files           437      438       +1     
  Lines          8241     8026     -215     
============================================
- Hits           4163     4070      -93     
+ Misses         4078     3956     -122     
Flag Coverage Δ
unittests 50.71% <51.57%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...le/Event/Listener/AuthenticationSuccessHandler.php 0.00% <0.00%> (ø)
src/ApiBundle/Security/ApiTokenAuthenticator.php 66.66% <ø> (-2.39%) ⬇️
src/ClientBundle/Action/Add.php 0.00% <0.00%> (ø)
src/ClientBundle/Action/Ajax/Address/Edit.php 0.00% <0.00%> (ø)
src/ClientBundle/Action/Ajax/Contact/Add.php 0.00% <0.00%> (ø)
src/ClientBundle/Action/Ajax/Contact/Edit.php 0.00% <0.00%> (ø)
src/ClientBundle/Action/Ajax/Credit.php 0.00% <0.00%> (ø)
src/ClientBundle/Action/Ajax/Delete.php 0.00% <0.00%> (ø)
src/ClientBundle/Action/Ajax/Info.php 0.00% <0.00%> (ø)
src/ClientBundle/Action/Edit.php 0.00% <0.00%> (ø)
... and 104 more

... and 149 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@pierredup pierredup left a comment

Choose a reason for hiding this comment

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

Thanks for the change! Just a few minor comments

@@ -11,13 +11,18 @@

use SolidInvoice\Kernel;

$_SERVER['APP_RUNTIME_OPTIONS'] = [
$runtimeOptions = [
'env_var_name' => 'SOLIDINVOICE_ENV',
Copy link
Member

Choose a reason for hiding this comment

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

These values might be better of to be defined as a constant if we want to make them re-usable

return static function (array $context) {
return new Kernel($context['SOLIDINVOICE_ENV'], (bool) $context['SOLIDINVOICE_DEBUG']);
return static function (array $context) use ($runtimeOptions) {
$environment = $context[$runtimeOptions['env_var_name']] ?? null;
Copy link
Member

Choose a reason for hiding this comment

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

I think we should set a default environment here (maybe prod?) Having the environment as null will cause some issues, since a lot of the standard config won't be loaded. The kernel also expects a string as the environment value, so this might cause an error if we use null.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, I'm not sure if there will be a case where these values are not set. Since we use the Symfony runtime, it loads the values by default from the .env file, so we should always have a default value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood I do agree with you.

@hedho hedho closed this May 19, 2023
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.

None yet

2 participants