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

[ArticleBundle] Code improvement found by static code analysis #2468

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function getQuery()
{
$query = parent::getQuery();

if (!is_null($query)) {
if (!\is_null($query)) {
$query->setHint(
\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER,
'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function getOverviewPage()
$repository = $this->getOverviewPageRepository();
$pages = $repository->findActiveOverviewPages();

if (isset($pages) && count($pages) > 0) {
if (isset($pages) && \count($pages) > 0) {
return $pages[0];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function getQuery()
{
$query = parent::getQuery();

if (!is_null($query)) {
if (!\is_null($query)) {
$query->setHint(
\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER,
'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker'
Expand Down
2 changes: 1 addition & 1 deletion src/Kunstmaan/ArticleBundle/Entity/AbstractAuthor.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AbstractAuthor extends AbstractEntity
*/
public function __construct()
{
if (get_class($this) === AbstractAuthor::class) {
if (\get_class($this) === AbstractAuthor::class) {
@trigger_error(sprintf('Instantiating the "%s" class is deprecated in KunstmaanArticleBundle 5.1 and will be made abstract in KunstmaanArticleBundle 6.0. Extend your implementation from this class instead.', __CLASS__), E_USER_DEPRECATED);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Kunstmaan/ArticleBundle/Entity/AbstractCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AbstractCategory extends AbstractEntity implements Translatable
*/
public function __construct()
{
if (get_class($this) === AbstractCategory::class) {
if (\get_class($this) === AbstractCategory::class) {
@trigger_error(sprintf('Instantiating the "%s" class is deprecated in KunstmaanArticleBundle 5.1 and will be made abstract in KunstmaanArticleBundle 6.0. Extend your implementation from this class instead.', __CLASS__), E_USER_DEPRECATED);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Kunstmaan/ArticleBundle/Entity/AbstractTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AbstractTag extends AbstractEntity implements Translatable
*/
public function __construct()
{
if (get_class($this) === AbstractTag::class) {
if (\get_class($this) === AbstractTag::class) {
@trigger_error(sprintf('Instantiating the "%s" class is deprecated in KunstmaanArticleBundle 5.1 and will be made abstract in KunstmaanArticleBundle 6.0. Extend your implementation from this class instead.', __CLASS__), E_USER_DEPRECATED);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/Kunstmaan/ArticleBundle/Router/TagCategoryRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Kunstmaan\ArticleBundle\Router;

use Kunstmaan\NodeBundle\Router\SlugRouter;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Translation\TranslatorInterface;

Expand All @@ -14,7 +13,7 @@ class TagCategoryRouter extends SlugRouter
*/
public function getRouteCollection()
{
if (!is_null($this->routeCollection)) {
if (!\is_null($this->routeCollection)) {
return $this->routeCollection;
}
$this->routeCollection = new RouteCollection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function setUp()

$acl = $this->createMock(AclHelper::class);

$this->object = new AbstractArticleAuthorAdminListConfigurator($em, $acl, 'nl', 'admin');
$this->object = new AbstractArticleAuthorAdminListConfigurator($em, $acl, 'nl');
}

public function testGetters()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public function testGetUrls()
$this->assertEquals('KunstmaanNodeBundle_nodes_edit', $url['path']);
$this->assertCount(1, $url['params']);
$this->assertEquals(1314, $url['params']['id']);
$url = $this->object->getEditUrlFor($item);

$url = $this->object->getDeleteUrlFor($item);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testGettersAndSetters()
$entity = new ArticleOverViewPage();
$this->assertEquals('KunstmaanArticleBundle:AbstractArticleOverviewPage:service', $entity->getControllerAction());
$this->assertEquals('KunstmaanArticleBundle:AbstractArticleOverviewPage:view.html.twig', $entity->getDefaultView());
$this->assertTrue(is_array($entity->getPossibleChildTypes()));
$this->assertTrue(is_array($entity->getPagePartAdminConfigurations()));
$this->assertInternalType('array', $entity->getPossibleChildTypes());
$this->assertInternalType('array', $entity->getPagePartAdminConfigurations());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testGettersAndSetters()
$this->assertEquals('NASA', $entity->getTitle());
$this->assertInstanceOf(DateTime::class, $entity->getDate());
$this->assertEquals(AbstractArticlePageAdminType::class, $entity->getAdminType());
$this->assertTrue(is_array($entity->getPossibleChildTypes()));
$this->assertTrue(is_array($entity->getPagePartAdminConfigurations()));
$this->assertInternalType('array', $entity->getPossibleChildTypes());
$this->assertInternalType('array', $entity->getPagePartAdminConfigurations());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function testGettersAndSetters()
$this->assertEquals('main', $entity->getContext());
$this->assertEquals('', $entity->getWidgetTemplate());
$types = $entity->getPossiblePagePartTypes();
$this->assertTrue(is_array($types));
$this->assertInternalType('array', $types);
foreach ($types as $type) {
$this->assertArrayHasKey('name', $type);
$this->assertArrayHasKey('class', $type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function testGettersAndSetters()
$this->assertEquals('main', $entity->getContext());
$this->assertEquals('', $entity->getWidgetTemplate());
$types = $entity->getPossiblePagePartTypes();
$this->assertTrue(is_array($types));
$this->assertInternalType('array', $types);
foreach ($types as $type) {
$this->assertArrayHasKey('name', $type);
$this->assertArrayHasKey('class', $type);
Expand Down
4 changes: 2 additions & 2 deletions src/Kunstmaan/ArticleBundle/Twig/ArticleTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(EntityManagerInterface $em, RouterInterface $router)
$this->em = $em;
$this->router = $router;

if (func_num_args() > 2) {
if (\func_num_args() > 2) {
@trigger_error(sprintf('Passing the "request_stack" service as the third argument in "%s" is deprecated in KunstmaanArticleBundle 5.1 and will be removed in KunstmaanArticleBundle 6.0. Remove the "request_stack" argument from your service definition.', __METHOD__), E_USER_DEPRECATED);
}
}
Expand Down Expand Up @@ -190,7 +190,7 @@ protected function articleRouteExists($type, $locale)
$routeName = sprintf('_slug_%s_%s', $type, $locale);

try {
return !is_null($this->router->getRouteCollection()->get($routeName));
return !\is_null($this->router->getRouteCollection()->get($routeName));
} catch (\Exception $e) {
return false;
}
Expand Down