Code improvements (#1649)

* use global namespace for faster lookups
* phpstan level 5
This commit is contained in:
Kevin Papst
2020-04-19 14:37:14 +02:00
committed by GitHub
parent 7b25e9acaf
commit 0f3fa8fdbe
183 changed files with 604 additions and 574 deletions

View File

@@ -52,7 +52,7 @@ class SelectWithApiDataExtension extends AbstractTypeExtension
$apiData = $options['api_data'];
if (!is_array($apiData)) {
if (!\is_array($apiData)) {
throw new \InvalidArgumentException('Option "api_data" must be an array for form "' . $form->getName() . '"');
}

View File

@@ -78,7 +78,7 @@ trait FormTrait
'group_by' => null,
'query_builder' => function (ProjectRepository $repo) use ($builder, $project, $customer, $isNew) {
// is there a better wa to prevent starting a record with a hidden project ?
if ($isNew && !empty($project) && (is_int($project) || is_string($project))) {
if ($isNew && !empty($project) && (\is_int($project) || \is_string($project))) {
/** @var Project $project */
$project = $repo->find($project);
if (null !== $project) {

View File

@@ -44,7 +44,7 @@ class RoleType extends AbstractType
$builder->get('name')->addViewTransformer(
new CallbackTransformer(
function ($roleName) {
if (is_string($roleName)) {
if (\is_string($roleName)) {
$roleName = str_replace(' ', '_', $roleName);
$roleName = str_replace('-', '_', $roleName);
$roleName = strtoupper($roleName);

View File

@@ -188,7 +188,7 @@ abstract class AbstractToolbarForm extends AbstractType
$name = $multiCustomer ? 'customers' : 'customer';
if (isset($data[$name]) && !empty($data[$name])) {
if (is_array($data[$name])) {
if (\is_array($data[$name])) {
$query->setCustomers($data[$name]);
} else {
$query->addCustomer($data[$name]);
@@ -197,7 +197,7 @@ abstract class AbstractToolbarForm extends AbstractType
$name = $multiProject ? 'projects' : 'project';
if (isset($data[$name]) && !empty($data[$name])) {
if (is_array($data[$name])) {
if (\is_array($data[$name])) {
$query->setProjects($data[$name]);
} else {
$query->addProject($data[$name]);
@@ -249,7 +249,7 @@ abstract class AbstractToolbarForm extends AbstractType
if (isset($data[$name]) && !empty($data[$name])) {
// we need to pre-fetch the activities to see if they are global, see ActivityFormTypeQuery::isGlobalsOnly()
$activities = $data[$name];
if (!is_array($activities)) {
if (!\is_array($activities)) {
$activities = [$activities];
}
foreach ($activities as $activity) {

View File

@@ -59,7 +59,7 @@ class CustomerType extends AbstractType
$resolver->setDefault('api_data', function (Options $options) {
if (false !== $options['project_enabled']) {
$name = is_string($options['project_enabled']) ? $options['project_enabled'] : 'customer';
$name = \is_string($options['project_enabled']) ? $options['project_enabled'] : 'customer';
$routeParams = [$name => '%' . $name . '%', 'visible' => $options['project_visibility']];
$emptyRouteParams = ['visible' => $options['project_visibility']];

View File

@@ -167,7 +167,7 @@ class DateRangeType extends AbstractType
$values = explode($separator, $dates);
if (count($values) !== 2) {
if (\count($values) !== 2) {
throw new TransformationFailedException('Invalid date range given');
}

View File

@@ -73,7 +73,7 @@ class InvoiceRendererType extends AbstractType
$parts = explode('.', $renderer);
if (count($parts) > 2) {
if (\count($parts) > 2) {
array_pop($parts);
}

View File

@@ -29,7 +29,7 @@ class LanguageType extends AbstractType
*/
public function __construct($locales)
{
if (!is_array($locales)) {
if (!\is_array($locales)) {
$locales = explode('|', $locales);
}

View File

@@ -85,7 +85,7 @@ class ProjectType extends AbstractType
$resolver->setDefault('api_data', function (Options $options) {
if (false !== $options['activity_enabled']) {
$name = is_string($options['activity_enabled']) ? $options['activity_enabled'] : 'project';
$name = \is_string($options['activity_enabled']) ? $options['activity_enabled'] : 'project';
return [
'select' => $options['activity_select'],