-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Use 'static' instead of 'self' method call to process command result #88
Conversation
Could you also add the failing case you reported in the test case? I think it would be good to capture it :) |
It seems my test case is not principally different from one you already have here: cpu-core-counter/tests/Finder/WmicLogicalFinderTest.php Lines 35 to 43 in 3a46820
I think the issue is that you test it by calling the same
Whereas the real counter uses cpu-core-counter/src/CpuCoreCounter.php Line 62 in 3a46820
I think |
Needless to say, I have verified that this change has fixed the issue on my machine and my test script echoed the correct number of cores 😁 |
Just for good measure maybe we can add another one without the blank line?
Ha I see indeed. Yeah that sucks because
before your fix it would return |
I added a test case, although I think the extra line in between may be due to Windows line endings (CRLF), it actually doesn't appear on screen. Anyway it passed when I tried it locally and the regex looked fine to me in the first place, it would work either way. As for testing the |
It's a mix of several things:
In light of this case though, I guess injecting the proc opener would be fine and at the very least it has the merit of covering close to all finders now.
I do plan to close the implementation details, but the finders themselves should still be part of the public API. One of the goals of the libraries over using a one liner |
I'm not convinced you'd call it over-engineering, at least not by much :) There's already a factory in
would become something like:
As another added benefit, inheritance won't be required anymore, static method won't be required (unless you have a reason for keeping it) and the code of proc open based finders would become simpler for the first-time readers (well I guess it's a subjective measure, but I'm sure it won't be more complicated than currently). It should be even possible to make it backwards compatible if needed, but it would look a little hacky. But anyway I guess this is outside of the scope of this issue :) For now, could you make reasonably sure this fix is actually correct and accept it? If you wish, I may send another PR with the above later when I get more time. For now I just wish to be able to use PHPStan at the full speed again :) Oh and another thing, Github says: 'The base branch requires all commits to be signed' and I never had to bother setting this up before, could you also rebase this and use your signature? |
Inheritance will still be needed. Truth be told it could be done without, but there is some benefits to it namely that you can create a class instance for which the name reflects the command it does.
Removed |
Thank you @czukowski |
Also fixed in #89 |
It might fix #87