basdenooijer/solarium — Issue #69: "Invalid argument supplied for foreach" in Solarium/Client/ResponseParser/Analysis/Field.php
Author: smola
Created: 2012-01-27 09:29:57+00:00
State: open

I am using the following code to analyze some URLs (getting the text value after passing the whole analysis chain:

(`$solr->client` is my Solarium client instance)

```php
$query = $solr->client->createAnalysisField();
$query->setFieldType('urls');
$query->setFieldValue($website);
$results = $solr->client->analyze($query);
foreach ($results as $result) {
foreach ($result as $item) {
foreach ($item->getIndexAnalysis() as $classes) {
foreach ($classes as $class) {
$an = $class->getText();
}
}
}
}
```

And I am getting this warning:
```
PHP Warning: Invalid argument supplied for foreach() in
.../Solarium/Client/ResponseParser/Analysis/Field.php on line 114
```

I am not sure yet about what input produces the warning and what not. It's probably related to the fact that some values return no tokens after the analysis.