cs: Switch to a stricter way of coding - this might break in a lot of places.

This commit is contained in:
Pol Dellaiera
2021-11-30 13:33:18 +01:00
parent 28d2c42454
commit 47c5855a21
957 changed files with 9025 additions and 568 deletions

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle;
use Chill\ThirdPartyBundle\DependencyInjection\CompilerPass\ThirdPartyTypeCompilerPass;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Controller;
use Chill\MainBundle\CRUD\Controller\CRUDController;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\DataFixtures\ORM;
use Chill\MainBundle\DataFixtures\ORM\LoadCenters;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\DataFixtures\ORM;
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\DataFixtures\ORM;
use Chill\ThirdPartyBundle\Entity\ThirdPartyProfession;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\DependencyInjection;
use Chill\ThirdPartyBundle\Controller\ThirdPartyController;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\DependencyInjection\CompilerPass;
use Chill\ThirdPartyBundle\ThirdPartyType\ThirdPartyTypeManager;
@@ -34,7 +43,7 @@ class ThirdPartyTypeCompilerPass implements CompilerPassInterface
// check forr keys already in use :
$key = $taggedService->getClass()::getKey();
if (in_array($key, $usedKeys)) {
if (in_array($key, $usedKeys, true)) {
throw new LogicException(sprintf(
'Tag with key "%s" is already in used',
$key

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Entity;
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
@@ -302,7 +311,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
if (!in_array($type, $this->types ?? [])) {
if (!in_array($type, $this->types ?? [], true)) {
$this->types[] = $type;
}
@@ -573,8 +582,8 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
if (in_array($type, $this->types ?? [])) {
$this->types = array_filter($this->types, fn ($e) => !in_array($e, $this->types));
if (in_array($type, $this->types ?? [], true)) {
$this->types = array_filter($this->types, fn ($e) => !in_array($e, $this->types, true));
}
foreach ($this->children as $child) {
@@ -822,7 +831,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
}
foreach ($this->getCategories() as $t) {
if (!in_array(spl_object_hash($t), $categoriesHashes)) {
if (!in_array(spl_object_hash($t), $categoriesHashes, true)) {
$this->removeCategory($t);
}
}

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Entity;
use Chill\ThirdPartyBundle\Repository\ThirdPartyCategoryRepository;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Entity;
use Chill\ThirdPartyBundle\Repository\ThirdPartyProfessionRepository;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Form\ChoiceLoader;
use Chill\MainBundle\Entity\Center;
@@ -60,7 +69,7 @@ class ThirdPartyChoiceLoader implements ChoiceLoaderInterface
$party = $this->partyRepository->find($value);
if (false === in_array($this->center, $party->getCenters()->toArray())) {
if (false === in_array($this->center, $party->getCenters()->toArray(), true)) {
throw new RuntimeException("the party's center is not authorized");
}

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Form;
use Chill\MainBundle\Entity\Civility;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Form\Type;
use Chill\MainBundle\Search\SearchInterface;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Form\Type;
use Chill\MainBundle\Templating\TranslatableStringHelper;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Repository;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Repository;
use Chill\ThirdPartyBundle\Entity\ThirdParty;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Repository;
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Repository;
use Chill\ThirdPartyBundle\Entity\ThirdPartyProfession;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Repository;
use Chill\ThirdPartyBundle\Entity\ThirdParty;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Search;
use Chill\MainBundle\Search\SearchApiInterface;
@@ -115,6 +124,6 @@ class ThirdPartyApiSearch implements SearchApiInterface
public function supportsTypes(string $pattern, array $types, array $parameters): bool
{
return in_array('thirdparty', $types);
return in_array('thirdparty', $types, true);
}
}

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Search;
use Chill\MainBundle\Pagination\PaginatorFactory;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Security\Voter;
use Chill\MainBundle\Entity\User;
@@ -63,7 +72,7 @@ class ThirdPartyVoter extends AbstractChillVoter implements ProvideRoleHierarchy
protected function supports($attribute, $subject)
{
if ($subject instanceof ThirdParty) {
return in_array($attribute, $this->getRoles());
return in_array($attribute, $this->getRoles(), true);
}
if (null === $subject) {

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Templating\Entity;
use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -15,25 +24,25 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @internal
* @coversNothing
*/
class ThirdPartyControllerTest extends WebTestCase
final class ThirdPartyControllerTest extends WebTestCase
{
public function testIndex()
{
$client = static::createClient();
$client = self::createClient();
$crawler = $client->request('GET', '/index');
}
public function testNew()
{
$client = static::createClient();
$client = self::createClient();
$crawler = $client->request('GET', '/new');
}
public function testUpdate()
{
$client = static::createClient();
$client = self::createClient();
$crawler = $client->request('GET', '/update');
}

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdParty\Tests\Entity;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
@@ -17,7 +26,7 @@ use PHPUnit\Framework\TestCase;
* @internal
* @coversNothing
*/
class ThirdPartyTest extends TestCase
final class ThirdPartyTest extends TestCase
{
public function testAddingRemovingActivityTypes()
{

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\ThirdPartyType;
use function array_keys;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\ThirdPartyType;
/**