Skip to content

Commit

Permalink
Replace deprecated code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Nikolaev committed Dec 4, 2019
1 parent 70e4456 commit c72c1f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
12 changes: 6 additions & 6 deletions Mapping/AnnotationDriver/UpdatedAtDriver.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
<?php declare(strict_types=1);
/**
* @author Igor Nikolaev <igor.sv.n@gmail.com>
* @copyright Copyright (c) 2016, Darvin Studio
* @copyright Copyright (c) 2016-2019, Darvin Studio
* @link https://www.darvin-studio.ru
*
* For the full copyright and license information, please view the LICENSE
Expand All @@ -12,7 +12,7 @@

use Darvin\Utils\Mapping\Annotation\UpdatedAt;
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;

/**
* Updated at annotation driver
Expand All @@ -22,7 +22,7 @@ class UpdatedAtDriver extends AbstractDriver
/**
* {@inheritdoc}
*/
public function readMetadata(ClassMetadata $doctrineMeta, array &$meta)
public function readMetadata(ClassMetadata $doctrineMeta, array &$meta): void
{
if (!isset($meta['updated_at'])) {
$meta['updatedAt'] = null;
Expand All @@ -48,12 +48,12 @@ public function readMetadata(ClassMetadata $doctrineMeta, array &$meta)

$fieldType = $doctrineMeta->getTypeOfField($property->getName());

if (Type::DATETIME !== $fieldType) {
if (Types::DATETIME_MUTABLE !== $fieldType) {
throw $this->createPropertyAnnotationInvalidException(
UpdatedAt::class,
$doctrineMeta->getName(),
$property->getName(),
sprintf('field must be of type "%s", "%s" provided', Type::DATETIME, $fieldType)
sprintf('field must be of type "%s", "%s" provided', Types::DATETIME_MUTABLE, $fieldType)
);
}

Expand Down
12 changes: 7 additions & 5 deletions Twig/Extension/PriceExtension.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
<?php declare(strict_types=1);
/**
* @author Igor Nikolaev <igor.sv.n@gmail.com>
* @copyright Copyright (c) 2018, Darvin Studio
* @copyright Copyright (c) 2018-2019, Darvin Studio
* @link https://www.darvin-studio.ru
*
* For the full copyright and license information, please view the LICENSE
Expand All @@ -11,11 +11,13 @@
namespace Darvin\Utils\Twig\Extension;

use Darvin\Utils\Price\PriceFormatterInterface;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;

/**
* Price Twig extension
*/
class PriceExtension extends \Twig_Extension
class PriceExtension extends AbstractExtension
{
/**
* @var \Darvin\Utils\Price\PriceFormatterInterface
Expand All @@ -33,10 +35,10 @@ public function __construct(PriceFormatterInterface $priceFormatter)
/**
* {@inheritdoc}
*/
public function getFilters()
public function getFilters(): array
{
return [
new \Twig_SimpleFilter('format_price', [$this->priceFormatter, 'format'], [
new TwigFilter('format_price', [$this->priceFormatter, 'format'], [
'is_safe' => ['html'],
]),
];
Expand Down

0 comments on commit c72c1f9

Please sign in to comment.