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

Add more phpdoc #1127

Merged
merged 1 commit into from
Oct 2, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Admin/FieldDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

use Sonata\AdminBundle\Admin\BaseFieldDescription;

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
Copy link
Member

Choose a reason for hiding this comment

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

IMO we should ensure that all final we want to add is not extended anywhere in any of the sonata bundles. We have some cases where we marked something final for Next major and it cant happen because is extended somewhere else. Have you check all of them?

Copy link
Member Author

Choose a reason for hiding this comment

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

AFAIK we do not extend any class from the doctrine specific admin bundles.

*/
class FieldDescription extends BaseFieldDescription
{
public function __construct()
Expand Down Expand Up @@ -52,9 +55,6 @@ public function getTargetEntity()
return $this->getTargetModel();
}

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.20.
*/
public function getTargetModel(): ?string
{
if ($this->associationMapping) {
Expand Down
3 changes: 3 additions & 0 deletions src/Builder/DatagridBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\FormFactoryInterface;

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
*/
class DatagridBuilder implements DatagridBuilderInterface
{
/**
Expand Down
5 changes: 5 additions & 0 deletions src/Builder/FormContractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\FormFactoryInterface;

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
*/
class FormContractor implements FormContractorInterface
{
/**
Expand Down Expand Up @@ -195,6 +198,8 @@ private function hasAssociation(FieldDescriptionInterface $fieldDescription): bo

/**
* @param string[] $classes
*
* @phpstan-param class-string[] $classes
*/
private function isAnyInstanceOf(?string $type, array $classes): bool
{
Expand Down
3 changes: 3 additions & 0 deletions src/Builder/ListBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
use Sonata\AdminBundle\Guesser\TypeGuesserInterface;
use Sonata\DoctrineORMAdminBundle\Guesser\TypeGuesser;

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
*/
class ListBuilder implements ListBuilderInterface
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Builder/ShowBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
use Sonata\AdminBundle\Guesser\TypeGuesserInterface;
use Sonata\DoctrineORMAdminBundle\Guesser\TypeGuesser;

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
*/
class ShowBuilder implements ShowBuilderInterface
{
/**
Expand Down
5 changes: 5 additions & 0 deletions src/Datagrid/Pager.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* Doctrine pager class.
*
* @author Jonathan H. Wage <[email protected]>
*
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
*/
class Pager extends BasePager
{
Expand All @@ -36,6 +38,9 @@ class Pager extends BasePager
*/
protected $queryBuilder = null;

/**
* @return int
*/
public function computeNbResult()
{
$countQuery = clone $this->getQuery();
Expand Down
4 changes: 2 additions & 2 deletions src/Datagrid/ProxyQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ class ProxyQuery implements ProxyQueryInterface
protected $queryBuilder;

/**
* @var string
* @var string|null
*/
protected $sortBy;

/**
* @var mixed
* @var string|null
*/
protected $sortOrder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
*
* @author Thomas Rabaix <[email protected]>
*/
class AddAuditEntityCompilerPass implements CompilerPassInterface
Expand Down
2 changes: 2 additions & 0 deletions src/DependencyInjection/Compiler/AddGuesserCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
use Symfony\Component\DependencyInjection\Reference;

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
*
* @author Thomas Rabaix <[email protected]>
*/
class AddGuesserCompilerPass implements CompilerPassInterface
Expand Down
4 changes: 4 additions & 0 deletions src/DependencyInjection/Compiler/AddTemplatesCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
use Symfony\Component\DependencyInjection\Definition;

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
*
* @author Thomas Rabaix <[email protected]>
*/
class AddTemplatesCompilerPass implements CompilerPassInterface
Expand Down Expand Up @@ -55,6 +57,8 @@ public function process(ContainerBuilder $container)
/**
* @param string $name
* @param mixed $value
*
* @return void
*/
public function mergeMethodCall(Definition $definition, $name, $value)
{
Expand Down
2 changes: 2 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
*
* This class contains the configuration information for the bundle.
*
* This information is solely responsible for how the different configuration
Expand Down
2 changes: 2 additions & 0 deletions src/DependencyInjection/SonataDoctrineORMAdminExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
*
* @author Thomas Rabaix <[email protected]>
* @author Michael Williams <[email protected]>
*/
Expand Down
3 changes: 3 additions & 0 deletions src/Filter/BooleanFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use Sonata\Form\Type\BooleanType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
*/
class BooleanFilter extends Filter
{
public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
Expand Down
10 changes: 9 additions & 1 deletion src/Filter/CallbackFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
*/
class CallbackFilter extends Filter
{
public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
Expand Down Expand Up @@ -50,7 +53,12 @@ public function getRenderSettings()
]];
}

protected function association(ProxyQueryInterface $queryBuilder, $data)
/**
* @param mixed[] $value
*
* @return array
*/
protected function association(ProxyQueryInterface $queryBuilder, $value)
{
$alias = $queryBuilder->entityJoin($this->getParentAssociationMappings());

Expand Down
3 changes: 3 additions & 0 deletions src/Filter/ChoiceFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use Sonata\AdminBundle\Form\Type\Filter\DefaultType;
use Sonata\AdminBundle\Form\Type\Operator\EqualOperatorType;

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
*/
class ChoiceFilter extends Filter
{
public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
Expand Down
3 changes: 3 additions & 0 deletions src/Filter/ClassFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use Sonata\AdminBundle\Form\Type\Operator\EqualOperatorType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
*/
class ClassFilter extends Filter
{
public const CHOICES = [
Expand Down
3 changes: 3 additions & 0 deletions src/Filter/DateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

use Symfony\Component\Form\Extension\Core\Type\DateType;

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
*/
class DateFilter extends AbstractDateFilter
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Filter/DateRangeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

use Sonata\Form\Type\DateRangeType;

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
*/
class DateRangeFilter extends AbstractDateFilter
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Filter/DateTimeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

use Symfony\Component\Form\Extension\Core\Type\DateTimeType;

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
*/
class DateTimeFilter extends AbstractDateFilter
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Filter/DateTimeRangeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

use Sonata\Form\Type\DateTimeRangeType;

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
*/
class DateTimeRangeFilter extends AbstractDateFilter
{
/**
Expand Down
5 changes: 5 additions & 0 deletions src/Filter/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public function isActive()
return $this->active;
}

/**
* @param mixed[] $value
*
* @return string[]
*/
protected function association(ProxyQueryInterface $queryBuilder, $value)
{
$alias = $queryBuilder->entityJoin($this->getParentAssociationMappings());
Expand Down
50 changes: 30 additions & 20 deletions src/Filter/ModelAutocompleteFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,25 @@
use Sonata\AdminBundle\Form\Type\ModelAutocompleteType;
use Sonata\AdminBundle\Form\Type\Operator\EqualOperatorType;

/**
* @final since sonata-project/doctrine-orm-admin-bundle 3.x
*/
class ModelAutocompleteFilter extends Filter
{
public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $value)
{
if (!$data || !\is_array($data) || !\array_key_exists('value', $data)) {
if (!$value || !\is_array($value) || !\array_key_exists('value', $value)) {
return;
}

if ($data['value'] instanceof Collection) {
$data['value'] = $data['value']->toArray();
if ($value['value'] instanceof Collection) {
$value['value'] = $value['value']->toArray();
}

if (\is_array($data['value'])) {
$this->handleMultiple($queryBuilder, $alias, $data);
if (\is_array($value['value'])) {
$this->handleMultiple($queryBuilder, $alias, $value);
} else {
$this->handleModel($queryBuilder, $alias, $data);
$this->handleModel($queryBuilder, $alias, $value);
}
}

Expand Down Expand Up @@ -67,52 +70,59 @@ public function getRenderSettings()
*
* @param ProxyQueryInterface|QueryBuilder $queryBuilder
* @param string $alias
* @param mixed $data
* @param mixed[] $value
*
* @return mixed
* @return void
*/
protected function handleMultiple(ProxyQueryInterface $queryBuilder, $alias, $data)
protected function handleMultiple(ProxyQueryInterface $queryBuilder, $alias, $value)
{
if (0 === \count($data['value'])) {
if (0 === \count($value['value'])) {
return;
}

$parameterName = $this->getNewParameterName($queryBuilder);

if (isset($data['type']) && EqualOperatorType::TYPE_NOT_EQUAL === $data['type']) {
if (isset($value['type']) && EqualOperatorType::TYPE_NOT_EQUAL === $value['type']) {
$this->applyWhere($queryBuilder, $queryBuilder->expr()->notIn($alias, ':'.$parameterName));
} else {
$this->applyWhere($queryBuilder, $queryBuilder->expr()->in($alias, ':'.$parameterName));
}

$queryBuilder->setParameter($parameterName, $data['value']);
$queryBuilder->setParameter($parameterName, $value['value']);
}

/**
* @param ProxyQueryInterface|QueryBuilder $queryBuilder
* @param string $alias
* @param mixed $data
* @param mixed[] $value
*
* @return mixed
* @return void
*/
protected function handleModel(ProxyQueryInterface $queryBuilder, $alias, $data)
protected function handleModel(ProxyQueryInterface $queryBuilder, $alias, $value)
{
if (empty($data['value'])) {
if (empty($value['value'])) {
return;
}

$parameterName = $this->getNewParameterName($queryBuilder);

if (isset($data['type']) && EqualOperatorType::TYPE_NOT_EQUAL === $data['type']) {
if (isset($value['type']) && EqualOperatorType::TYPE_NOT_EQUAL === $value['type']) {
$this->applyWhere($queryBuilder, sprintf('%s != :%s', $alias, $parameterName));
} else {
$this->applyWhere($queryBuilder, sprintf('%s = :%s', $alias, $parameterName));
}

$queryBuilder->setParameter($parameterName, $data['value']);
$queryBuilder->setParameter($parameterName, $value['value']);
}

protected function association(ProxyQueryInterface $queryBuilder, $data)
/**
* @param mixed[] $value
*
* @return array
*
* @phpstan-return array{string, bool}
*/
protected function association(ProxyQueryInterface $queryBuilder, $value)
{
$associationMappings = $this->getParentAssociationMappings();
$associationMappings[] = $this->getAssociationMapping();
Expand Down
Loading