upgraded to phpunit 8 (#1155)
This commit is contained in:
@@ -138,7 +138,6 @@ class ActivityController extends BaseApiController
|
||||
*/
|
||||
public function getAction($id)
|
||||
{
|
||||
/** @var Activity $data */
|
||||
$data = $this->repository->find($id);
|
||||
|
||||
if (null === $data) {
|
||||
|
||||
@@ -117,7 +117,6 @@ class CustomerController extends BaseApiController
|
||||
*/
|
||||
public function getAction($id)
|
||||
{
|
||||
/** @var Customer $data */
|
||||
$data = $this->repository->find($id);
|
||||
|
||||
if (null === $data) {
|
||||
|
||||
@@ -122,7 +122,6 @@ class ProjectController extends BaseApiController
|
||||
*/
|
||||
public function getAction($id)
|
||||
{
|
||||
/** @var Project $data */
|
||||
$data = $this->repository->find($id);
|
||||
|
||||
if (null === $data) {
|
||||
|
||||
@@ -81,7 +81,6 @@ class TeamController extends BaseApiController
|
||||
*/
|
||||
public function getAction($id)
|
||||
{
|
||||
/** @var Team $data */
|
||||
$data = $this->repository->find($id);
|
||||
|
||||
if (null === $data) {
|
||||
|
||||
@@ -247,7 +247,6 @@ class TimesheetController extends BaseApiController
|
||||
*/
|
||||
public function getAction($id)
|
||||
{
|
||||
/** @var Timesheet $data */
|
||||
$data = $this->repository->find($id);
|
||||
|
||||
if (null === $data) {
|
||||
@@ -545,7 +544,6 @@ class TimesheetController extends BaseApiController
|
||||
*/
|
||||
public function stopAction($id)
|
||||
{
|
||||
/** @var Timesheet $timesheet */
|
||||
$timesheet = $this->repository->find($id);
|
||||
|
||||
if (null === $timesheet) {
|
||||
@@ -590,7 +588,6 @@ class TimesheetController extends BaseApiController
|
||||
*/
|
||||
public function restartAction($id, ParamFetcherInterface $paramFetcher, ValidatorInterface $validator)
|
||||
{
|
||||
/** @var Timesheet $timesheet */
|
||||
$timesheet = $this->repository->find($id);
|
||||
|
||||
if (null === $timesheet) {
|
||||
@@ -678,7 +675,6 @@ class TimesheetController extends BaseApiController
|
||||
*/
|
||||
public function exportAction($id)
|
||||
{
|
||||
/** @var Timesheet $timesheet */
|
||||
$timesheet = $this->repository->find($id);
|
||||
|
||||
if (null === $timesheet) {
|
||||
|
||||
@@ -40,7 +40,6 @@ class CustomerFixtures extends Fixture
|
||||
public const MAX_PROJECTS_PER_CUSTOMER = 25;
|
||||
public const MIN_ACTIVITIES_PER_PROJECT = 0;
|
||||
public const MAX_ACTIVITIES_PER_PROJECT = 25;
|
||||
public const INDICATE_HIDDEN = false;
|
||||
|
||||
/**
|
||||
* @param ObjectManager $manager
|
||||
@@ -94,7 +93,7 @@ class CustomerFixtures extends Fixture
|
||||
$entry = new Customer();
|
||||
$entry
|
||||
->setCurrency($faker->currencyCode)
|
||||
->setName($faker->company . (self::INDICATE_HIDDEN && !$visible ? ' (x)' : ''))
|
||||
->setName($faker->company)
|
||||
->setAddress($faker->address)
|
||||
->setComment($faker->text)
|
||||
->setNumber('C-' . $faker->ean8)
|
||||
@@ -125,7 +124,7 @@ class CustomerFixtures extends Fixture
|
||||
$entry = new Project();
|
||||
|
||||
$entry
|
||||
->setName($faker->catchPhrase . (self::INDICATE_HIDDEN && !$visible ? ' (x)' : ''))
|
||||
->setName($faker->catchPhrase)
|
||||
->setComment($faker->text)
|
||||
->setCustomer($customer)
|
||||
->setOrderNumber('P-' . $faker->ean8)
|
||||
@@ -153,7 +152,7 @@ class CustomerFixtures extends Fixture
|
||||
{
|
||||
$entry = new Activity();
|
||||
$entry
|
||||
->setName($faker->bs . (self::INDICATE_HIDDEN && !$visible ? ' (x)' : ''))
|
||||
->setName($faker->bs)
|
||||
->setProject($project)
|
||||
->setComment($faker->text)
|
||||
->setVisible($visible)
|
||||
|
||||
@@ -43,7 +43,7 @@ class DoctrineCompilerPass implements CompilerPassInterface
|
||||
$engine = getenv('DATABASE_ENGINE');
|
||||
}
|
||||
|
||||
if (null === $engine) {
|
||||
if (false === $engine) {
|
||||
throw new \Exception(
|
||||
'Could not detect database engine. Please set the environment config DATABASE_ENGINE ' .
|
||||
'to one of: "' . implode(', ', $this->allowedEngines) . '" in your .env file, e.g. DATABASE_ENGINE=sqlite'
|
||||
|
||||
@@ -16,7 +16,7 @@ use Doctrine\DBAL\Types\DateTimeType;
|
||||
class UTCDateTimeType extends DateTimeType
|
||||
{
|
||||
/**
|
||||
* @var \DateTimeZone
|
||||
* @var \DateTimeZone|null
|
||||
*/
|
||||
private static $utc;
|
||||
|
||||
|
||||
@@ -21,24 +21,17 @@ final class PrepareUserEvent extends Event
|
||||
* @deprecated since 1.4, will be removed with 2.0
|
||||
*/
|
||||
public const PREPARE = PrepareUserEvent::class;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
protected $user;
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getUser()
|
||||
public function getUser(): User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ class TimezoneSubscriber implements EventSubscriberInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
/* @var $user User */
|
||||
$user = $this->storage->getToken()->getUser();
|
||||
|
||||
if (null === $user) {
|
||||
|
||||
@@ -151,10 +151,6 @@ class UserPreferenceSubscriber implements EventSubscriberInterface
|
||||
*/
|
||||
public function loadUserPreferences(PrepareUserEvent $event)
|
||||
{
|
||||
if (!$this->canHandleEvent($event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$user = $event->getUser();
|
||||
|
||||
$prefs = [];
|
||||
@@ -182,17 +178,4 @@ class UserPreferenceSubscriber implements EventSubscriberInterface
|
||||
|
||||
$user->setPreferences(array_values($prefs));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PrepareUserEvent $event
|
||||
* @return bool
|
||||
*/
|
||||
protected function canHandleEvent(PrepareUserEvent $event): bool
|
||||
{
|
||||
if (null === ($user = $event->getUser())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ($user instanceof User);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class DurationStringToSecondsTransformer implements DataTransformerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $formatToInt
|
||||
* @param string|null $formatToInt
|
||||
* @return int|null
|
||||
*/
|
||||
public function reverseTransform($formatToInt)
|
||||
|
||||
@@ -11,49 +11,35 @@ namespace App\Form\Model;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class DateRange
|
||||
final class DateRange
|
||||
{
|
||||
/**
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $begin;
|
||||
private $begin;
|
||||
/**
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $end;
|
||||
private $end;
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getBegin(): ?DateTime
|
||||
{
|
||||
return $this->begin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTime $begin
|
||||
* @return DateRange
|
||||
*/
|
||||
public function setBegin(DateTime $begin)
|
||||
public function setBegin(DateTime $begin): DateRange
|
||||
{
|
||||
$this->begin = $begin;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getEnd(): ?DateTime
|
||||
{
|
||||
return $this->end;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTime $end
|
||||
* @return DateRange
|
||||
*/
|
||||
public function setEnd(DateTime $end)
|
||||
public function setEnd(DateTime $end): DateRange
|
||||
{
|
||||
$this->end = $end;
|
||||
|
||||
|
||||
@@ -295,7 +295,7 @@ class TimesheetEditForm extends AbstractType
|
||||
$builder->addEventListener(
|
||||
FormEvents::POST_SET_DATA,
|
||||
function (FormEvent $event) {
|
||||
/** @var Timesheet $data */
|
||||
/** @var Timesheet|null $data */
|
||||
$data = $event->getData();
|
||||
if (null === $data || null === $data->getEnd()) {
|
||||
$event->getForm()->get('duration')->setData(null);
|
||||
|
||||
@@ -69,8 +69,8 @@ abstract class AbstractCalculator
|
||||
public function getTax(): float
|
||||
{
|
||||
$vat = $this->getVat();
|
||||
if (0 === $vat) {
|
||||
return 0;
|
||||
if (0.00 === $vat) {
|
||||
return 0.00;
|
||||
}
|
||||
|
||||
$percent = $vat / 100.00;
|
||||
|
||||
@@ -144,10 +144,6 @@ class TimesheetQuery extends ActivityQuery
|
||||
*/
|
||||
public function setState($state)
|
||||
{
|
||||
if (!is_int($state) && $state !== (int) $state) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$state = (int) $state;
|
||||
if (in_array($state, [self::STATE_ALL, self::STATE_RUNNING, self::STATE_STOPPED], true)) {
|
||||
$this->state = $state;
|
||||
@@ -170,10 +166,6 @@ class TimesheetQuery extends ActivityQuery
|
||||
*/
|
||||
public function setExported($exported)
|
||||
{
|
||||
if (!is_int($exported) && $exported !== (int) $exported) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$exported = (int) $exported;
|
||||
if (in_array($exported, [self::STATE_ALL, self::STATE_EXPORTED, self::STATE_NOT_EXPORTED], true)) {
|
||||
$this->exported = $exported;
|
||||
@@ -182,10 +174,7 @@ class TimesheetQuery extends ActivityQuery
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getBegin()
|
||||
public function getBegin(): ?\DateTime
|
||||
{
|
||||
return $this->dateRange->getBegin();
|
||||
}
|
||||
@@ -201,10 +190,7 @@ class TimesheetQuery extends ActivityQuery
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getEnd()
|
||||
public function getEnd(): ?\DateTime
|
||||
{
|
||||
return $this->dateRange->getEnd();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class UserQuery extends VisibilityQuery
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $role;
|
||||
private $role;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -37,12 +37,12 @@ class UserQuery extends VisibilityQuery
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $role
|
||||
* @param string|null $role
|
||||
* @return UserQuery
|
||||
*/
|
||||
public function setRole($role)
|
||||
{
|
||||
if (false !== strpos($role, 'ROLE_') || null === $role) {
|
||||
if (null === $role || false !== strpos($role, 'ROLE_')) {
|
||||
$this->role = $role;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,10 +43,6 @@ class VisibilityQuery extends BaseQuery
|
||||
*/
|
||||
public function setVisibility($visibility)
|
||||
{
|
||||
if (!is_int($visibility) && $visibility != (int) $visibility) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$visibility = (int) $visibility;
|
||||
if (in_array($visibility, self::ALLOWED_VISIBILITY_STATES, true)) {
|
||||
$this->visibility = $visibility;
|
||||
|
||||
@@ -24,7 +24,7 @@ class Duration
|
||||
/**
|
||||
* Transforms seconds into a duration string.
|
||||
*
|
||||
* @param int $seconds
|
||||
* @param int|null $seconds
|
||||
* @param string $format
|
||||
* @return string|null
|
||||
*/
|
||||
|
||||
@@ -46,7 +46,7 @@ class TimesheetValidator extends ConstraintValidator
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TimesheetEntity $value
|
||||
* @param TimesheetEntity|mixed $value
|
||||
* @param Constraint $constraint
|
||||
*/
|
||||
public function validate($value, Constraint $constraint)
|
||||
|
||||
Reference in New Issue
Block a user