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

Fix release #19

Merged
merged 5 commits into from
Nov 3, 2023
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
12 changes: 6 additions & 6 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@ jobs:
matrix:
include:
# Lowest Deps
- php: 8.0
symfony: 5.4.*
- php: 8.1
symfony: 6.2.*
coverage: 'none'
composer-flags: '--prefer-stable --prefer-lowest'
can-fail: false
# LTS with latest stable PHP
- php: latest
symfony: 5.4.*
symfony: 6.3.*
coverage: 'none'
composer-flags: '--prefer-stable'
can-fail: false
# Active release
- php: latest
symfony: 6.2.*
symfony: 6.3.*
coverage: pcov
composer-flags: '--prefer-stable'
can-fail: false
# Development release
- php: nightly
symfony: 6.3.*@dev
symfony: 7.0.*@dev
coverage: 'none'
composer-flags: ''
can-fail: true
Expand All @@ -61,7 +61,7 @@ jobs:
fail-fast: true

- name: Set Composer stability
if: matrix.symfony == '6.3.*@dev'
if: matrix.symfony == '7.0.*@dev'
run: "composer config minimum-stability dev"

- name: Get composer cache directory
Expand Down
27 changes: 13 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,29 @@
}
],
"require": {
"php": ">=7.4",
"php": ">=8.0",
"ext-mbstring": "*",
"doctrine/annotations": "^1.10 || ^2.0",
"doctrine/doctrine-bundle": "^2.7",
"doctrine/doctrine-bundle": "^2.7.1",
"doctrine/orm": "^2.14",
"paragonie/ciphersweet": "^3.0 || ^4.0",
"symfony/config": "^5.4 || ^6.0",
"symfony/console": "^5.4 || ^6.0",
"symfony/dependency-injection": "^5.4 || ^6.0",
"symfony/config": "^5.4 || ^6.2",
"symfony/console": "^5.4 || ^6.2",
"symfony/dependency-injection": "^5.4 || ^6.2",
"symfony/deprecation-contracts": "^2.5 || ^3.2",
"symfony/framework-bundle": "^5.4 || ^6.0",
"symfony/http-kernel": "^5.4 || ^6.0",
"symfony/process": "^5.4 || ^6.0",
"symfony/property-access": "^5.4 || ^6.0",
"symfony/property-info": "^5.4 || ^6.0",
"symfony/framework-bundle": "^5.4 || ^6.2",
"symfony/http-kernel": "^5.4 || ^6.2",
"symfony/process": "^5.4 || ^6.2",
"symfony/property-access": "^5.4 || ^6.2",
"symfony/property-info": "^5.4 || ^6.2",
"symfony/service-contracts": "^2.2 || ^3.2"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"sensio/framework-extra-bundle": "^6.2.2",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/doctrine-bridge": "^5.4 || ^6.0",
"symfony/browser-kit": "^5.4 || ^6.2",
"symfony/doctrine-bridge": "^6.2",
"symfony/phpunit-bridge": "^6.2.3",
"symfony/yaml": "^5.4 || ^6.0"
"symfony/yaml": "^5.4 || ^6.2"
},
"suggest": {
"phpdocumentor/reflection-docblock": "To use the PHPDoc"
Expand Down
5 changes: 3 additions & 2 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
service('encryption.indexes_generator'),
service('property_accessor')
])
->alias(IndexableFieldsService::class, 'encryption.indexable_field')

// Property
->set('encryption.property_hydrator', PropertyHydratorService::class)
Expand All @@ -98,7 +99,7 @@

->set('encryption.subscriber', DoctrineCiphersweetSubscriber::class)
->args([
service('annotation_reader'), // @deprecated
service('annotation_reader')->nullOnInvalid(), // @deprecated
service('encryption.encrypted_fields'),
service(EncryptorInterface::class),
service('encryption.indexable_field'),
Expand All @@ -108,7 +109,7 @@

->set('encryption.encrypted_fields', EncryptedFieldsService::class)
->args([
service('annotation_reader'), // @deprecated
service('annotation_reader')->nullOnInvalid(), // @deprecated
])
;
};
6 changes: 3 additions & 3 deletions src/Services/EncryptedFieldsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
class EncryptedFieldsService
{
/** @deprecated */
private Reader $annReader;
private ?Reader $annReader;

public function __construct(Reader $annReader)
public function __construct(?Reader $annReader)
{
$this->annReader = $annReader;
}
Expand All @@ -38,7 +38,7 @@ public function getEncryptedFields(ClassMetadata $meta): array
}

/** @var \ReflectionProperty $refProperty */
if ($this->annReader->getPropertyAnnotation($refProperty, EncryptedField::class)) {
if (null !== $this->annReader && $this->annReader->getPropertyAnnotation($refProperty, EncryptedField::class)) {
$refProperty->setAccessible(true);
$encryptedFields[] = $refProperty;

Expand Down
3 changes: 3 additions & 0 deletions src/Services/PropertyHydratorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface;
use Symfony\Component\PropertyInfo\Type;

/**
* @internal
*/
class PropertyHydratorService
{
private PropertyInfoExtractorInterface $propertyInfoExtractor;
Expand Down
9 changes: 6 additions & 3 deletions src/Subscribers/DoctrineCiphersweetSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@
use Doctrine\ORM\Events;
use Symfony\Contracts\Service\ResetInterface;

/**
* @internal
*/
class DoctrineCiphersweetSubscriber implements EventSubscriberInterface, ResetInterface
{
public const ENCRYPTED_ANN_NAME = EncryptedField::class;
public const INDEXABLE_ANN_NAME = IndexableField::class;

/** @deprecated */
private Reader $annReader;
private ?Reader $annReader;
private EncryptorInterface $encryptor;
private IndexableFieldsService $indexableFieldsService;
private PropertyHydratorService $propertyHydratorService;
Expand Down Expand Up @@ -74,7 +77,7 @@ class DoctrineCiphersweetSubscriber implements EventSubscriberInterface, ResetIn
private array $entitiesToEncrypt = [];

public function __construct(
Reader $annReader,
?Reader $annReader,
EncryptedFieldsService $encryptedFieldsService,
EncryptorInterface $encryptorClass,
IndexableFieldsService $indexableFieldsService,
Expand Down Expand Up @@ -327,7 +330,7 @@ private function buildContext(string $entityClassName, \ReflectionProperty $refP
}
}

if (null === $annotationConfig && null === $indexableAnnotationConfig) {
if (null === $annotationConfig && null === $indexableAnnotationConfig && null !== $this->annReader) {
$annotationConfig = $this->annReader->getPropertyAnnotation($refProperty, self::ENCRYPTED_ANN_NAME);
$indexableAnnotationConfig = $this->annReader->getPropertyAnnotation($refProperty, self::INDEXABLE_ANN_NAME);

Expand Down
1 change: 0 additions & 1 deletion tests/App/Controller/TestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Odandb\DoctrineCiphersweetEncryptionBundle\Tests\App\Controller;

use Doctrine\ORM\EntityManagerInterface;
use Odandb\DoctrineCiphersweetEncryptionBundle\Encryptors\EncryptorInterface;
use Odandb\DoctrineCiphersweetEncryptionBundle\Tests\App\Model\MyEntityAttribute;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Attribute\AsController;
Expand Down
8 changes: 0 additions & 8 deletions tests/App/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Odandb\DoctrineCiphersweetEncryptionBundle\OdandbDoctrineCiphersweetEncryptionBundle;
use Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
Expand All @@ -17,9 +16,6 @@ public function registerBundles(): iterable
{
yield new FrameworkBundle();
yield new DoctrineBundle();
if (self::VERSION_ID < 60200) {
yield new SensioFrameworkExtraBundle();
}
yield new OdandbDoctrineCiphersweetEncryptionBundle();
}

Expand All @@ -32,9 +28,5 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(__DIR__ . '/config.yaml');
$loader->load(__DIR__ . '/doctrine.yaml');

if (self::VERSION_ID < 60200) {
$loader->load(__DIR__ . '/deprecated.yaml');
}
}
}
4 changes: 4 additions & 0 deletions tests/App/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ imports:
- { resource: services.yaml }

framework:
annotations: false
secret: '123456789'
handle_all_throwables: true
http_method_override: false
router:
utf8: true
resource: '%kernel.project_dir%/routing.yaml'
strict_requirements: ~
test: true
php_errors:
log: true
profiler:
collect: false
cache:
Expand Down
3 changes: 0 additions & 3 deletions tests/App/deprecated.yaml

This file was deleted.