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

EventsExtension: fix compatibility with Nette 2.4 #100

Merged
merged 1 commit into from
Jul 6, 2016
Merged

EventsExtension: fix compatibility with Nette 2.4 #100

merged 1 commit into from
Jul 6, 2016

Conversation

mrtnzlml
Copy link
Contributor

@mrtnzlml mrtnzlml commented Jun 6, 2016

Closes: #99

@enumag
Copy link
Member

enumag commented Jun 6, 2016

@mrtnzlml It's not so easy, that method does not exist in Nette 2.3.

@mrtnzlml
Copy link
Contributor Author

mrtnzlml commented Jun 6, 2016

Oh, I see. I did not realize that.

@mrtnzlml mrtnzlml changed the title EventsExtension: fix compatibility with Nette 2.4 WIP: EventsExtension: fix compatibility with Nette 2.4 Jun 6, 2016
@mrtnzlml
Copy link
Contributor Author

mrtnzlml commented Jun 7, 2016

@enumag Fixed.

What is the right way to run all tests using tester? I tried this, but without success:

screenshot from 2016-06-07 16 52 27

@@ -313,8 +313,14 @@ private function autowireEvents(Nette\DI\ContainerBuilder $builder)
continue;
}
}
if ($def->getImplementType() === 'get') {
continue;
if (method_exists($def, 'getImplementMode')) { //BC (Nette 2.4)
Copy link
Member

Choose a reason for hiding this comment

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

Nette 2.4 is new so "BC" comment is wrong here imho. Also I'd rather put the detection outside of the foreach. It's not really important in compile time but still.

@enumag
Copy link
Member

enumag commented Jun 7, 2016

@mrtnzlml I'm not sure I understand - if you want to run all tests, just don't specify any (remove the last argument of your command).

@enumag
Copy link
Member

enumag commented Jun 7, 2016

What do you think about this instead?

$implementGetter = method_exists('Nette\DI\ServiceDefinition', 'getImplementMode') ? 'getImplementMode' : 'getImplementType';
...
if ($def->{$implementGetter}() === 'get') {

@mrtnzlml
Copy link
Contributor Author

mrtnzlml commented Jun 7, 2016

@enumag Irrelevant. Same behavior...

About your solution - I don't like it, but you are the boss here, so should I change it?

@Majkl578
Copy link
Member

Majkl578 commented Jun 7, 2016

Dynamic getter is by magnitude worse than method_exists in foreach imho. You can always declare boolean variable outside foreach and do a simple if check inside foreach.

@enumag
Copy link
Member

enumag commented Jun 7, 2016

@Majkl578 I know. It just seemed more readable.

@mrtnzlml Actually I'm not the boss here, that's @fprochazka of course. I don't have push rights to this repo.

The fastest solution is probably this:

$newApi = method_exists('Nette\DI\ServiceDefinition', 'getImplementMode');
...
if (($newApi ? $def->getImplementMode() : $def->getImplementType()) === 'get') {

@mrtnzlml
Copy link
Contributor Author

mrtnzlml commented Jun 7, 2016

I know it's @fprochazka... :)
@enumag Rebased. What about now?

@Majkl578
Copy link
Member

Majkl578 commented Jun 7, 2016

Btw there's also new constant for this, ServiceDefinition::IMPLEMENT_MODE_GET, so how about this?

$newApi = defined('Nette\DI\ServiceDefinition::IMPLEMENT_MODE_GET');
if ($newApi ? $def->getImplementMode() === $def::IMPLEMENT_MODE_GET : $def->getImplementType() === 'get')

@enumag
Copy link
Member

enumag commented Jun 7, 2016

@Majkl578 Nice. I didn't know about the constant.

@mrtnzlml
Copy link
Contributor Author

mrtnzlml commented Jun 7, 2016

Me neither. I suppose this is faster (maybe)? I am getting tired of rebases. Every solution except the first one worked just fine. Please chose the Chosen One and I'll do rebase (again)... :)

@enumag
Copy link
Member

enumag commented Jun 7, 2016

You don't need rebase, just amend last commit and force push.

I don't think it's my call but Majkl's last suggestion is good imo so personally I'd go with that.

@mrtnzlml
Copy link
Contributor Author

mrtnzlml commented Jun 7, 2016

@enumag I am using rebase so often, that I completely forgot about --amend. Thanks. But this was not the point... :)

Anyway, amended and green. Still cannot use vender/bin/tester with tests, because it doesn't work for some reason, but whatever...

@mrtnzlml mrtnzlml changed the title WIP: EventsExtension: fix compatibility with Nette 2.4 EventsExtension: fix compatibility with Nette 2.4 Jun 7, 2016
@enumag
Copy link
Member

enumag commented Jun 7, 2016

@mrtnzlml Thanks!

@fprochazka Ready to merge in my opinion.

@Majkl578
Copy link
Member

Majkl578 commented Jun 7, 2016

Hmm, tests are indeed a bit strange... But it might be a missing extension in my case (no idea which one though?).

$ vendor/bin/tester -p php7.0-local tests/ | tail -n +6 | grep -vE '^\s*$'
PHP 7.0.7 | php7.0-local | 8 threads
...........................................................
OK (59 tests, 0.8 seconds)

$ vendor/bin/tester -p php7.0 tests/ | tail -n +6 | grep -vE '^\s*$'
PHP 7.0.7-4 | php7.0 | 8 threads
FFFFFFF
-- FAILED: Kdyby\Events\Event. | KdybyTests/Events/Event.phpt
-- FAILED: Kdyby\Events\EventArgs. | KdybyTests/Events/EventArgs.phpt
-- FAILED: Kdyby\Events\EventManager. | KdybyTests/Events/EventManager.phpt
-- FAILED: Kdyby\Events\Extension. | KdybyTests/Events/Extension.phpt
-- FAILED: Kdyby\Events\IExceptionHandler. | KdybyTests/Events/IExceptionHandler.phpt
-- FAILED: Kdyby\Events\LazyEventManager. | KdybyTests/Events/LazyEventManager.phpt
-- FAILED: Kdyby\Events\NamespacedEventManager. | KdybyTests/Events/NamespacedEventManager.phpt
FAILURES! (7 tests, 7 failures, 0.1 seconds)

$ vendor/bin/tester -p php5.6 tests/ | tail -n +6 | grep -vE '^\s*$'
PHP 5.6.22-2+0~20160601121249.1+jessie~1.gbp701a45 | php5.6 | 8 threads
FFFFFFF
-- FAILED: Kdyby\Events\Event. | KdybyTests/Events/Event.phpt
-- FAILED: Kdyby\Events\EventArgs. | KdybyTests/Events/EventArgs.phpt
-- FAILED: Kdyby\Events\EventManager. | KdybyTests/Events/EventManager.phpt
-- FAILED: Kdyby\Events\Extension. | KdybyTests/Events/Extension.phpt
-- FAILED: Kdyby\Events\IExceptionHandler. | KdybyTests/Events/IExceptionHandler.phpt
-- FAILED: Kdyby\Events\LazyEventManager. | KdybyTests/Events/LazyEventManager.phpt
-- FAILED: Kdyby\Events\NamespacedEventManager. | KdybyTests/Events/NamespacedEventManager.phpt
FAILURES! (7 tests, 7 failures, 0.1 seconds)

$ vendor/bin/tester -p php5.5 tests/ | tail -n +6 | grep -vE '^\s*$'
PHP 5.5.36-2+0~20160601121612.1+jessie~1.gbp08f27b | php5.5 | 8 threads
FFFFFFF
-- FAILED: Kdyby\Events\Event. | KdybyTests/Events/Event.phpt
-- FAILED: Kdyby\Events\EventArgs. | KdybyTests/Events/EventArgs.phpt
-- FAILED: Kdyby\Events\EventManager. | KdybyTests/Events/EventManager.phpt
-- FAILED: Kdyby\Events\Extension. | KdybyTests/Events/Extension.phpt
-- FAILED: Kdyby\Events\IExceptionHandler. | KdybyTests/Events/IExceptionHandler.phpt
-- FAILED: Kdyby\Events\LazyEventManager. | KdybyTests/Events/LazyEventManager.phpt
-- FAILED: Kdyby\Events\NamespacedEventManager. | KdybyTests/Events/NamespacedEventManager.phpt
FAILURES! (7 tests, 7 failures, 0.1 seconds)

@mrtnzlml
Copy link
Contributor Author

mrtnzlml commented Jun 7, 2016

Hmm, tests are indeed a bit strange... But it might be a missing extension in my case (no idea which one though?).

@Majkl578 Good point! In my case it's always JSON, so vendor/bin/tester tests/ -d extension=json.so works fine... :) But the error is little bit strange.

@Majkl578
Copy link
Member

Majkl578 commented Jun 7, 2016

Yep, I needed json.so and tokenizer.so.

@foxycode
Copy link

foxycode commented Jul 6, 2016

@fprochazka Will you please merge it and make new release?

@fprochazka fprochazka merged commit 49158bc into Kdyby:master Jul 6, 2016
@fprochazka
Copy link
Member

Thank you guys

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.

5 participants