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

Fixed php-error "undefined offset" when adding an item-converter and multiple mappings #96

Merged
merged 1 commit into from
Jul 28, 2014

Conversation

gries
Copy link
Contributor

@gries gries commented Jul 15, 2014

A php error was thrown:

Undefined offset: 0

when adding a CallbackItemConverter and after that adding multiple mappings:

$workflow->addItemConverter(new CallbackItemConverter(function($item) {
    return $item;
}));

$workflow
    ->addMapping('foo', 'bar') // works
    ->addMapping('baz', 'bazzoo') // breaks
;

This is caused by the getMappingItemConverter method which accesses $converters with an index 0 instead of current

$converters = \array_filter(
    $this->itemConverters,
    function ($converter) {
        return $converter instanceof MappingItemConverter;
    }
);

if (count($converters) > 0) {
    // this breaks because the MappingItemConverter is located at "1"
    // because array_filter preservers the keys
    $converter = $converters[0];
}

@gries gries changed the title Fixed php-error "undefined offset" when adding an item-convert and multiple mappings Fixed php-error "undefined offset" when adding an item-converter and multiple mappings Jul 15, 2014
@Baachi
Copy link
Collaborator

Baachi commented Jul 25, 2014

Can you rebase? It seems your PR conflicts with the current master.

@Baachi Baachi added the bug label Jul 25, 2014
…item-converter and later on adding multiple mappings.
@gries
Copy link
Contributor Author

gries commented Jul 25, 2014

done

@gries
Copy link
Contributor Author

gries commented Jul 28, 2014

ping @Baachi

ddeboer added a commit that referenced this pull request Jul 28, 2014
Fixed php-error "undefined offset" when adding an item-converter and multiple mappings
@ddeboer ddeboer merged commit 72d4f93 into ddeboer:master Jul 28, 2014
@ddeboer
Copy link
Owner

ddeboer commented Jul 28, 2014

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants