Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Adjust Symfony eventDispatcher->dispatch calls#36897

Merged
micbar merged 1 commit intomasterfrom
adjust-Symfony4-eventDispatcher
Feb 6, 2020
Merged

Adjust Symfony eventDispatcher->dispatch calls#36897
micbar merged 1 commit intomasterfrom
adjust-Symfony4-eventDispatcher

Conversation

@phil-davis
Copy link
Contributor

@phil-davis phil-davis commented Feb 6, 2020

Description

We updated from Symfony 3.4 to 4.4 in PR #36881
Symfony 4.3 (and thus 4.4) adjusted the EventDispatcher dispatch method to take parameters in the opposite order.
https://symfony.com/blog/new-in-symfony-4-3-simpler-event-dispatching
symfony/symfony#28920
symfony/symfony#33115

The change was made in a BC way - if the parameters are provided the old way around, then the dispatch method flips them. So existing code is OK. But in Symfony5 the "old way" is likely to have been removed.

I noticed this because some apps have phan code analysis that reports that the parameters are around the "wrong way" (the old way). e.g.

lib/Jobs/PasswordExpirationNotifierJob.php:170 PhanTypeMismatchArgument Argument 1 (event) is 'user.passwordAboutToExpire' but \Symfony\Component\EventDispatcher\EventDispatcher::dispatch() takes object defined at ../../lib/composer/symfony/event-dispatcher/EventDispatcher.php:51
lib/Jobs/PasswordExpirationNotifierJob.php:215 PhanTypeMismatchArgument Argument 1 (event) is 'user.passwordExpired' but \Symfony\Component\EventDispatcher\EventDispatcher::dispatch() takes object defined at ../../lib/composer/symfony/event-dispatcher/EventDispatcher.php:51

IMO it is good to refactor this in core now, rather than leave it waiting to break things when we go to Symfony5 some day.

I adjusted the existing Symfony4 update changelog to include this PR.

How Has This Been Tested?

Local unit test runs and CI

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:
  • Changelog item, see TEMPLATE

@phil-davis phil-davis self-assigned this Feb 6, 2020
@phil-davis phil-davis force-pushed the adjust-Symfony4-eventDispatcher branch from 56ea2a4 to 2eefd93 Compare February 6, 2020 06:45
@codecov
Copy link

codecov bot commented Feb 6, 2020

Codecov Report

Merging #36897 into master will increase coverage by 0.16%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #36897      +/-   ##
============================================
+ Coverage     64.01%   64.18%   +0.16%     
  Complexity    19135    19135              
============================================
  Files          1270     1270              
  Lines         74848    74872      +24     
  Branches       1329     1329              
============================================
+ Hits          47917    48057     +140     
+ Misses        26540    26424     -116     
  Partials        391      391              
Flag Coverage Δ Complexity Δ
#javascript 54.17% <ø> (ø) 0.00 <ø> (ø) ⬆️
#phpunit 65.30% <92.62%> (+0.18%) 19135.00 <0.00> (ø) ⬆️
Impacted Files Coverage Δ Complexity Δ
lib/private/Files/Storage/DAV.php 78.48% <0.00%> (-0.62%) 0.00% <0.00%> (ø%)
lib/private/Files/View.php 84.54% <0.00%> (-0.30%) 389.00% <0.00%> (ø%)
lib/private/DB/MDB2SchemaWriter.php 93.75% <0.00%> (+1.04%) 34.00% <0.00%> (ø%) ⬆️
lib/private/DB/Connection.php 66.91% <0.00%> (+1.47%) 49.00% <0.00%> (ø%) ⬆️
lib/private/Repair/Collation.php 87.50% <0.00%> (+5.00%) 12.00% <0.00%> (ø%) ⬆️
lib/private/DB/MDB2SchemaManager.php 89.47% <0.00%> (+5.26%) 17.00% <0.00%> (ø%) ⬆️
...eryBuilder/ExpressionBuilder/ExpressionBuilder.php 95.89% <0.00%> (+5.47%) 20.00% <0.00%> (ø%) ⬆️
core/Command/Db/ConvertType.php 38.01% <0.00%> (+11.15%) 55.00% <0.00%> (ø%) ⬆️
lib/private/DB/ConnectionFactory.php 83.56% <0.00%> (+15.06%) 22.00% <0.00%> (ø%) ⬆️
lib/private/DB/AdapterSqlite.php 83.33% <0.00%> (+83.33%) 7.00% <0.00%> (ø%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0ef16be...2eefd93. Read the comment docs.

@owncloud owncloud deleted a comment from update-docs bot Feb 6, 2020
@phil-davis phil-davis requested a review from micbar February 6, 2020 06:54
@phil-davis phil-davis marked this pull request as ready for review February 6, 2020 06:55
@phil-davis
Copy link
Contributor Author

@micbar please review or select someone to review this.

It would be nice if we can merge this refactoring before making the 10.4 release branch.

@micbar micbar merged commit 18831fa into master Feb 6, 2020
@delete-merged-branch delete-merged-branch bot deleted the adjust-Symfony4-eventDispatcher branch February 6, 2020 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants