Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Fixes $options = null check when use Zend\Valdator\Barcode #52

Merged
merged 1 commit into from
Feb 17, 2016

Conversation

samsonasik
Copy link
Contributor

the constructor has optional $options = null but no check for it, this PR fixes it.

@samsonasik samsonasik changed the title Fixes $options = null when use Zend\Valdator\Barcode Fixes $options = null check when use Zend\Valdator\Barcode Jan 17, 2016
@Maks3w
Copy link
Member

Maks3w commented Jan 17, 2016

Next if initialize the adapter value as null and getAdatper has a test for it and then do a lazy initialization.

Can you paste the results of the added test without "the fix"?

/**
* @dataProvider provideBarcodeConstructor
*/
public function testBarcodeConstructorIsNullOrArrayButNoOptionsKey($options)
Copy link
Member

Choose a reason for hiding this comment

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

Don't detail constructor types in the function name, this is already provided by the provider.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@samsonasik
Copy link
Contributor Author

without the fix, it will got error:

    Adapter NULL does not implement Zend\Validator\Barcode\AdapterInterface

@Maks3w
Copy link
Member

Maks3w commented Jan 17, 2016

Then the source of the issue is:

  1. getAdapter try to lazy initializate the adapter if this one does not exists
  2. parent constructor calls setAdapter with null value and setAdapter check if the argument is a valid instance.

For me the easiest solution is allow null on setAdapter

@samsonasik
Copy link
Contributor Author

@Maks3w I've updated setAdapter() to allow null

@Maks3w
Copy link
Member

Maks3w commented Jan 17, 2016

Your choice of set an empty array is better

@samsonasik
Copy link
Contributor Author

if use set empty array, it will got:

Zend\Validator\Exception\InvalidArgumentException: Adapter array does not implement Zend\Validator\Barcode\AdapterInterface

@Maks3w
Copy link
Member

Maks3w commented Jan 17, 2016

With this? #52 (comment)

@samsonasik
Copy link
Contributor Author

@Maks3w oops, missed that, I've just updated in 2fd04e5

@samsonasik
Copy link
Contributor Author

@Maks3w should be ok now 👍

@Maks3w
Copy link
Member

Maks3w commented Jan 17, 2016

Rebase and go

@Maks3w
Copy link
Member

Maks3w commented Jan 17, 2016

*squash

@samsonasik
Copy link
Contributor Author

@Maks3w squashed.

@samsonasik
Copy link
Contributor Author

@Maks3w merge-able ?

@weierophinney weierophinney merged commit 137564c into zendframework:master Feb 17, 2016
weierophinney added a commit that referenced this pull request Feb 17, 2016
Fixes $options = null check when use Zend\Valdator\Barcode
weierophinney added a commit that referenced this pull request Feb 17, 2016
weierophinney added a commit that referenced this pull request Feb 17, 2016
weierophinney added a commit that referenced this pull request Feb 17, 2016
@weierophinney weierophinney added this to the 2.5.4 milestone Feb 17, 2016
@weierophinney weierophinney self-assigned this Feb 17, 2016
@samsonasik samsonasik deleted the hotfix/options-null branch February 17, 2016 16:54
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants