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

Add support for PHP 8, fix tests #57

Closed
wants to merge 10 commits into from
Closed

Conversation

ocean
Copy link

@ocean ocean commented Oct 15, 2020

Targeting issue #55

Still some test errors because of needing to change testing
for private/protected properties with PHPUnit 9 - I'm not sure how to test these properties now.

Signed-off-by: Drew Robinson drew.robinson@gmail.com

Still some test errors because of needing to change testing
for private/protected properties with PHPUnit 9

Signed-off-by: Drew Robinson <drew.robinson@gmail.com>
Signed-off-by: Drew Robinson <drew.robinson@gmail.com>
Thanks to the PR from @gennadigennadigennadi
I've incorporated those fixes into this PR to get PHPUnit 9 support.

Signed-off-by: Drew Robinson <drew.robinson@gmail.com>
Can't figure out how to deal with the `getClass()` deprecations cleanly
in all instances in the files in this PR.

Signed-off-by: Drew Robinson <drew.robinson@gmail.com>
Signed-off-by: Drew Robinson <drew.robinson@gmail.com>
@ocean
Copy link
Author

ocean commented Oct 16, 2020

The problematic area I need help with is around /src/AbstractFactory/ReflectionBasedAbstractFactory.php:222

@boesing boesing added Enhancement hacktoberfest-accepted Issues/Pull-Requests which can be fixed during Hacktoberfest: https://hacktoberfest.digitalocean.com labels Oct 16, 2020
@boesing boesing added this to In progress in PHP 8.0 via automation Oct 16, 2020
@boesing boesing linked an issue Oct 16, 2020 that may be closed by this pull request
6 tasks
@snapshotpl
Copy link
Member

@ocean this patch helps for me:

--- a/src/AbstractFactory/ReflectionBasedAbstractFactory.php
+++ b/src/AbstractFactory/ReflectionBasedAbstractFactory.php
@@ -217,13 +217,13 @@ class ReflectionBasedAbstractFactory implements AbstractFactoryInterface
             return [];
         }
 
-        if ($parameter->hasType() && ! $parameter->getType()->isBuiltin()) {
+        if (! $parameter->hasType() || ($parameter->hasType() && $parameter->getType()->isBuiltin())) {
             if (! $parameter->isDefaultValueAvailable()) {
                 throw new ServiceNotFoundException(sprintf(
                     'Unable to create service "%s"; unable to resolve parameter "%s" '
                     . 'to a class, interface, or array type',
                     $requestedName,
-                    $parameter->getType()
+                    $parameter->getName()
                 ));
             }

Thanks https://github.com/snapshotpl

Signed-off-by: Drew Robinson <drew.robinson@gmail.com>
Perhaps test should not look at this, given it's ignored by the class?

Signed-off-by: Drew Robinson <drew.robinson@gmail.com>
@ocean
Copy link
Author

ocean commented Nov 12, 2020

@froschdesign This is ready for review now 😃

PHP 8.0 automation moved this from In progress to Review in progress Nov 12, 2020
Copy link
Member

@froschdesign froschdesign 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 your contribution! 👍

Two changes are necessary and I have added a question.

src/AbstractFactory/ReflectionBasedAbstractFactory.php Outdated Show resolved Hide resolved
src/Tool/FactoryCreator.php Outdated Show resolved Hide resolved
@@ -171,7 +174,7 @@ public function testFactoryCanSupplyAMixOfParameterTypes()
self::assertInstanceOf(TestAsset\ClassWithMixedConstructorParameters::class, $instance);

self::assertEquals($config, $instance->config);
self::assertEquals([], $instance->options);
self::assertEquals(null, $instance->options);
Copy link
Member

Choose a reason for hiding this comment

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

Does this change mean that there was an error before?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, there was an error in the tests when I ran them locally. I thought I saw a comment something about $options always being treated as null, but now I can't find it. I'll revert this change and then you can see the error that shows up in Travis.

Copy link
Author

Choose a reason for hiding this comment

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

@froschdesign Yep, in the test the options instance property is set to null, not to an empty array, see:
https://github.com/laminas/laminas-servicemanager/blob/3.5.x/test/AbstractFactory/TestAsset/ClassWithMixedConstructorParameters.php#L24

So either the assertion or the test class constructor needs changing I guess.

Signed-off-by: Drew Robinson <drew.robinson@gmail.com>
Signed-off-by: Drew Robinson <drew.robinson@gmail.com>
Signed-off-by: Drew Robinson <drew.robinson@gmail.com>
@boesing
Copy link
Member

boesing commented Nov 17, 2020

@ocean Is there anything we can help with? Feel free to ping me.

Update: I've merged #56 which already had phpunit 9 fixes and thus your tests might pass after rebasing against 3.5.x branch 👍

@boesing
Copy link
Member

boesing commented Nov 17, 2020

Oh, I wasnt aware that there was already #51 which added PHP 8.0 compatibility back in july.
I'll close this in favor of #51 as its tests are already passing.

@boesing boesing closed this Nov 17, 2020
PHP 8.0 automation moved this from Review in progress to Done Nov 17, 2020
@FabianKoestring
Copy link

Could you tag a new release for this feature?

@Ocramius Ocramius added the Duplicate This issue or pull request already exists label Dec 1, 2020
@Ocramius Ocramius added this to the 3.5.0 milestone Dec 1, 2020
@Ocramius
Copy link
Member

Ocramius commented Dec 1, 2020

@FabianKoestring done

@Ocramius
Copy link
Member

Ocramius commented Dec 1, 2020

@FabianKoestring beware: due to #59, this has been reverted for now, and will therefore be delayed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate This issue or pull request already exists Enhancement hacktoberfest-accepted Issues/Pull-Requests which can be fixed during Hacktoberfest: https://hacktoberfest.digitalocean.com
Projects
No open projects
PHP 8.0
  
Done
Development

Successfully merging this pull request may close these issues.

PHP 8.0 support
6 participants