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 issues reported by phpstan #53

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/bundle/ApiLoader/BoostFactorProviderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Ibexa\Bundle\Solr\ApiLoader;

use Ibexa\Bundle\Core\ApiLoader\RepositoryConfigurationProvider;
use Ibexa\Solr\FieldMapper\BoostFactorProvider;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

Expand Down Expand Up @@ -48,6 +49,10 @@ public function __construct(

public function buildService()
{
if ($this->container === null) {
return new BoostFactorProvider();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not having a container set at this point indicates an error. LogicException should be preferred in my opinion.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 4de3f25


$repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig();

$connection = $this->defaultConnection;
Expand Down
5 changes: 5 additions & 0 deletions src/bundle/ApiLoader/IndexingDepthProviderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Ibexa\Bundle\Solr\ApiLoader;

use Ibexa\Bundle\Core\ApiLoader\RepositoryConfigurationProvider;
use Ibexa\Solr\FieldMapper\IndexingDepthProvider;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

Expand Down Expand Up @@ -43,6 +44,10 @@ public function __construct(

public function buildService()
{
if ($this->container === null) {
return new IndexingDepthProvider();
}

$repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig();

$connection = $this->defaultConnection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null)

foreach ($criterion->value as $identifier) {
try {
$validIds[] = $contentTypeHandler->loadByIdentifier($identifier)->id;
$validIds[] = $contentTypeHandler->loadByIdentifier((string) $identifier)->id;
} catch (NotFoundException $e) {
// Filter out non-existing content types, but track for code below
$invalidIdentifiers[] = $identifier;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Query/Content/CriterionVisitor/Ancestor.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null)
{
$idSet = [];
foreach ($criterion->value as $value) {
foreach (explode('/', trim($value, '/')) as $id) {
foreach (explode('/', trim((string)$value, '/')) as $id) {
$idSet[$id] = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Query/Location/CriterionVisitor/Ancestor.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null)
{
$idSet = [];
foreach ($criterion->value as $value) {
foreach (explode('/', trim($value, '/')) as $id) {
foreach (explode('/', trim((string)$value, '/')) as $id) {
$idSet[$id] = true;
}
}
Expand Down