prismicio-community / php-kit

Community maintained development kit for Prismic and the PHP language
https://prismic.io
Other
108 stars 82 forks source link

getStructuredText throwing errors #107

Closed fireproofsocks closed 9 years ago

fireproofsocks commented 9 years ago

When trying to use the getStructuredText function, I'm encountering this error:

Argument 2 passed to Prismic\Fragment\StructuredText::insertSpans() must be of the type array, null given, 
called in vendor/prismic/php-sdk/src/Prismic/Fragment/StructuredText.php on line 277 

The line in question is here:

$content = StructuredText::insertSpans($block->getText(), $block->getSpans(), $linkResolver);

Which in turn comes down to the TextBlock.php class. Seems like forcing the $spans class variable to default to a null fixes the problem inside the Fragment\Block\TextBlock class:

private $spans = array();

but I can't say whether that's the correct way to handle this.

srenault commented 9 years ago

Thanks for reported this! Fix here: 06e95a548bda6e69f3b5d5c22d6bf95687576eee