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

Encapsulate processed data #749

Merged

Conversation

dvdoug
Copy link
Contributor

@dvdoug dvdoug commented May 14, 2020

Hello @sebastianbergmann

This the next piece of work for #380. Like the previous PR, this doesn't add new functionality, it merely reworks some of the existing code to use an object instead of an array.

I've also (as a seperate commit) added in the named constructors you requested in #748

@codecov
Copy link

codecov bot commented May 14, 2020

Codecov Report

Merging #749 into master will increase coverage by 0.59%.
The diff coverage is 93.90%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #749      +/-   ##
============================================
+ Coverage     83.27%   83.87%   +0.59%     
- Complexity      845      846       +1     
============================================
  Files            37       37              
  Lines          2476     2480       +4     
============================================
+ Hits           2062     2080      +18     
+ Misses          414      400      -14     
Impacted Files Coverage Δ Complexity Δ
src/Driver/PCOV.php 33.33% <0.00%> (ø) 3.00 <0.00> (ø)
src/Driver/PHPDBG.php 0.00% <0.00%> (ø) 13.00 <0.00> (ø)
src/Driver/Xdebug.php 0.00% <0.00%> (ø) 6.00 <0.00> (ø)
src/CodeCoverage.php 69.85% <80.00%> (-2.32%) 157.00 <4.00> (-24.00)
src/Node/Builder.php 97.14% <100.00%> (-0.08%) 24.00 <19.00> (ø)
src/ProcessedCodeCoverageData.php 100.00% <100.00%> (ø) 27.00 <27.00> (?)
src/RawCodeCoverageData.php 100.00% <100.00%> (ø) 9.00 <4.00> (-1.00)
src/Report/PHP.php 69.23% <100.00%> (+69.23%) 8.00 <0.00> (ø)
... and 1 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 06bfa0c...01033e4. Read the comment docs.

return $coverage;
}

private function __construct()

Choose a reason for hiding this comment

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

Thank you formaking the constructor private and for adopting the concept of named constructors. However, the named constructor must not first create an object and then assign data to it. Instead, the named constructor should pass its parameter, maybe after mapping or processing it, to the constructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 🤞

*/
private $lineCoverage = [];

public static function __set_state(array $serialisedData)

Choose a reason for hiding this comment

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

Why do you think we need a __set_state() method? A value object must not know about persistence or serialization.

Copy link
Contributor Author

@dvdoug dvdoug May 15, 2020

Choose a reason for hiding this comment

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

It's because of https://github.com/sebastianbergmann/php-code-coverage/blob/master/src/Report/PHP.php#L37

As this is now an object and not an array, the output from var_export automatically includes a call to __set_state which means it needs to exist as a method for the generated code to continue working.

I could change the PHP export to use serialize/unserialize instead of var_export?

Choose a reason for hiding this comment

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

Do not worry about the PHP report. We can always bump the major version number and change the output of the PHP report.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

__set_state has been removed

@dvdoug dvdoug force-pushed the encapsulate_processed_data branch from 118ec2d to 01033e4 Compare May 15, 2020 19:58
@sebastianbergmann sebastianbergmann merged commit 4dcffe3 into sebastianbergmann:master May 16, 2020
@dvdoug dvdoug deleted the encapsulate_processed_data branch May 16, 2020 15:15
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