cs: Enable more risky rules.

This commit is contained in:
Pol Dellaiera 2021-11-30 12:09:24 +01:00
parent 6ce511889f
commit 579c349e28
No known key found for this signature in database
GPG Key ID: D476DFE9C67467CA
22 changed files with 29 additions and 15 deletions

View File

@ -31,7 +31,7 @@ $riskyRules = [
// 'comment_to_phpdoc' => false, // 'comment_to_phpdoc' => false,
// 'no_unset_on_property' => false, // 'no_unset_on_property' => false,
'strict_param' => false, 'strict_param' => false,
'native_constant_invocation' => false, // 'native_constant_invocation' => false,
'php_unit_test_annotation' => false, 'php_unit_test_annotation' => false,
'php_unit_no_expectation_annotation' => false, 'php_unit_no_expectation_annotation' => false,
'declare_strict_types' => false, 'declare_strict_types' => false,
@ -46,8 +46,8 @@ $riskyRules = [
// 'array_push' => false, // 'array_push' => false,
'ereg_to_preg' => false, 'ereg_to_preg' => false,
'error_suppression' => false, 'error_suppression' => false,
'fopen_flag_order' => false, // 'fopen_flag_order' => false,
'fopen_flags' => false, // 'fopen_flags' => false,
// 'logical_operators' => false, // 'logical_operators' => false,
// 'modernize_types_casting' => false, // 'modernize_types_casting' => false,
// 'no_homoglyph_names' => false, // 'no_homoglyph_names' => false,

View File

@ -18,7 +18,7 @@ use Symfony\Component\HttpFoundation\Request;
// Feel free to remove this, extend it, or make something more sophisticated. // Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP']) if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR']) || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || PHP_SAPI === 'cli-server') || !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || \PHP_SAPI === 'cli-server')
) { ) {
header('HTTP/1.0 403 Forbidden'); header('HTTP/1.0 403 Forbidden');

View File

@ -15,6 +15,7 @@ use Chill\CustomFieldsBundle\Entity\CustomField;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\DataTransformerInterface;
use function array_key_exists; use function array_key_exists;
use const JSON_THROW_ON_ERROR;
class JsonCustomFieldToArrayTransformer implements DataTransformerInterface class JsonCustomFieldToArrayTransformer implements DataTransformerInterface
{ {

View File

@ -18,7 +18,7 @@ use Symfony\Component\HttpFoundation\Request;
// Feel free to remove this, extend it, or make something more sophisticated. // Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP']) if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR']) || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || PHP_SAPI === 'cli-server') || !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || \PHP_SAPI === 'cli-server')
) { ) {
header('HTTP/1.0 403 Forbidden'); header('HTTP/1.0 403 Forbidden');

View File

@ -47,7 +47,7 @@ class DocGeneratorController extends AbstractController
unlink($tmpfname); unlink($tmpfname);
$fileContent = fopen($tmpfname2, 'r'); // the generated file content $fileContent = fopen($tmpfname2, 'rb'); // the generated file content
$response = new Response(fread($fileContent, filesize($tmpfname2))); $response = new Response(fread($fileContent, filesize($tmpfname2)));
$disposition = HeaderUtils::makeDisposition( $disposition = HeaderUtils::makeDisposition(

View File

@ -76,7 +76,7 @@ class DocGeneratorTemplateController extends AbstractController
unlink($tmpfname); unlink($tmpfname);
$fileContent = fopen($tmpfname2, 'r'); // the generated file content $fileContent = fopen($tmpfname2, 'rb'); // the generated file content
$genDocName = 'doc_' . sprintf('%010d', mt_rand()) . '.docx'; $genDocName = 'doc_' . sprintf('%010d', mt_rand()) . '.docx';

View File

@ -21,6 +21,7 @@ use function array_keys;
use function array_search; use function array_search;
use function count; use function count;
use function in_array; use function in_array;
use const ARRAY_FILTER_USE_BOTH;
class CRUDRoutesLoader extends Loader class CRUDRoutesLoader extends Loader
{ {

View File

@ -196,7 +196,7 @@ class LoadPostalCodesCommand extends Command
. 'have the right to read it.'); . 'have the right to read it.');
} }
$resource = fopen($filename, 'r'); $resource = fopen($filename, 'rb');
if (false == $resource) { if (false == $resource) {
throw new RuntimeException("The file '{$filename}' could not be opened."); throw new RuntimeException("The file '{$filename}' could not be opened.");

View File

@ -228,7 +228,7 @@ class CSVFormatter implements FormatterInterface
$content = []; $content = [];
// create a file pointer connected to the output stream // create a file pointer connected to the output stream
$output = fopen('php://output', 'w'); $output = fopen('php://output', 'wb');
//title //title
fputcsv($output, [$this->translator->trans($this->export->getTitle())]); fputcsv($output, [$this->translator->trans($this->export->getTitle())]);

View File

@ -115,7 +115,7 @@ class CSVListFormatter implements FormatterInterface
$this->exportData = $exportData; $this->exportData = $exportData;
$this->formatterData = $formatterData; $this->formatterData = $formatterData;
$output = fopen('php://output', 'w'); $output = fopen('php://output', 'wb');
$this->prepareHeaders($output); $this->prepareHeaders($output);

View File

@ -110,7 +110,7 @@ class CSVPivotedListFormatter implements FormatterInterface
$this->exportData = $exportData; $this->exportData = $exportData;
$this->formatterData = $formatterData; $this->formatterData = $formatterData;
$output = fopen('php://output', 'w'); $output = fopen('php://output', 'wb');
$i = 1; $i = 1;
$lines = []; $lines = [];

View File

@ -204,7 +204,7 @@ class SpreadSheetFormatter implements FormatterInterface
$this->tempfile = tempnam(sys_get_temp_dir(), ''); $this->tempfile = tempnam(sys_get_temp_dir(), '');
$this->generateContent(); $this->generateContent();
$f = fopen($this->tempfile, 'r'); $f = fopen($this->tempfile, 'rb');
$response->setContent(stream_get_contents($f)); $response->setContent(stream_get_contents($f));
fclose($f); fclose($f);

View File

@ -199,7 +199,7 @@ class SpreadsheetListFormatter implements FormatterInterface
$tempfile = tempnam(sys_get_temp_dir(), ''); $tempfile = tempnam(sys_get_temp_dir(), '');
$writer->save($tempfile); $writer->save($tempfile);
$f = fopen($tempfile, 'r'); $f = fopen($tempfile, 'rb');
$response->setContent(stream_get_contents($f)); $response->setContent(stream_get_contents($f));
fclose($f); fclose($f);

View File

@ -17,6 +17,8 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use const SORT_FLAG_CASE;
use const SORT_STRING;
/** /**
* Extends choice to allow adding select2 library on widget. * Extends choice to allow adding select2 library on widget.

View File

@ -17,6 +17,8 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use const SORT_FLAG_CASE;
use const SORT_STRING;
/** /**
* Extends choice to allow adding select2 library on widget for languages (multiple). * Extends choice to allow adding select2 library on widget for languages (multiple).

View File

@ -15,6 +15,7 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter; use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use function get_class; use function get_class;
use function in_array; use function in_array;
use const E_USER_DEPRECATED;
/** /**
* Voter for Chill software. * Voter for Chill software.

View File

@ -22,6 +22,7 @@ use function array_unique;
use function array_values; use function array_values;
use function count; use function count;
use function ksort; use function ksort;
use const PHP_INT_MAX;
/** /**
* Utilities to compare date periods. * Utilities to compare date periods.

View File

@ -44,6 +44,8 @@ use function get_class;
use function in_array; use function in_array;
use function is_array; use function is_array;
use function json_decode; use function json_decode;
use const JSON_PRETTY_PRINT;
use const LC_TIME;
final class ImportPeopleFromCSVCommand extends Command final class ImportPeopleFromCSVCommand extends Command
{ {
@ -771,7 +773,7 @@ final class ImportPeopleFromCSVCommand extends Command
. 'have the right to read it.'); . 'have the right to read it.');
} }
$resource = fopen($filename, 'r'); $resource = fopen($filename, 'rb');
if (false == $resource) { if (false == $resource) {
throw new RuntimeException("The file '{$filename}' could not be opened."); throw new RuntimeException("The file '{$filename}' could not be opened.");

View File

@ -41,6 +41,7 @@ use Symfony\Component\Validator\GroupSequenceProviderInterface;
use UnexpectedValueException; use UnexpectedValueException;
use function count; use function count;
use function in_array; use function in_array;
use const SORT_REGULAR;
/** /**
* AccompanyingPeriod Class. * AccompanyingPeriod Class.

View File

@ -13,6 +13,7 @@ namespace Chill\PersonBundle\EventListener;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\PersonAltName; use Chill\PersonBundle\Entity\PersonAltName;
use const MB_CASE_TITLE;
class PersonEventListener class PersonEventListener
{ {

View File

@ -17,6 +17,8 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use const SORT_FLAG_CASE;
use const SORT_STRING;
/** /**
* A type to select the marital status. * A type to select the marital status.

View File

@ -18,7 +18,7 @@ use Symfony\Component\HttpFoundation\Request;
// Feel free to remove this, extend it, or make something more sophisticated. // Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP']) if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR']) || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || PHP_SAPI === 'cli-server') || !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || \PHP_SAPI === 'cli-server')
) { ) {
header('HTTP/1.0 403 Forbidden'); header('HTTP/1.0 403 Forbidden');