From ec2877a2cad3a3d05795c3562fe19484568abaac Mon Sep 17 00:00:00 2001 From: Bacluc Date: Fri, 8 Mar 2024 20:15:48 +0100 Subject: [PATCH 1/3] build: Add development container to docker-compose.yaml (#62) --- .dockerignore | 1 + Dockerfile | 24 ++++++++++++++++++++++++ docker-compose.yaml | 13 +++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..1d085ca --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +** diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8e233fb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# renovate: datasource=docker depName=php +ARG PHP_VERSION=8.3.2 + +# renovate: datasource=docker depName=alpine +ARG ALPINE_VERSION=3.18 + +FROM php:${PHP_VERSION}-alpine${ALPINE_VERSION} + +# php extensions installer: https://github.com/mlocati/docker-php-extension-installer +COPY --from=mlocati/php-extension-installer --link /usr/bin/install-php-extensions /usr/local/bin/ + +RUN set -eux; \ + install-php-extensions pdo_mysql mongodb + +# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser +ENV PATH="${PATH}:/root/.composer/vendor/bin" +ENV COMPOSER_HOME=/tmp/composer +ENV COMPOSER_CACHE_DIR=/tmp/composer/cache +RUN mkdir -p /tmp/composer/cache +RUN chmod ugo+w /tmp/composer/cache + +COPY --from=composer /usr/bin/composer /usr/bin/composer + +CMD ["php"] diff --git a/docker-compose.yaml b/docker-compose.yaml index 9d1e16e..322ff85 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,6 +2,19 @@ version: '3.1' # To keep in sync with .gitHub/workflows/tests.yaml services: + php: + build: . + volumes: + - .:/app + - ./.cache/composer:/tmp/composer/cache:delegated + working_dir: /app + environment: + - DATABASE_URL=mysql://root:password@mysql/hautelook_alice_bundle + profiles: + - php + user: ${USER_ID:-1000} + network_mode: host + mysql: image: mysql:8.0 platform: linux/amd64 From e3265759a0a7a9b6905c3de2965cb5502ecaca82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= <5175937+theofidry@users.noreply.github.com> Date: Fri, 8 Mar 2024 20:26:47 +0100 Subject: [PATCH 2/3] style: Fix CS (#65) --- bin/console | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/console b/bin/console index d37a941..af9b900 100755 --- a/bin/console +++ b/bin/console @@ -10,6 +10,8 @@ * file that was distributed with this source code. */ +declare(strict_types=1); + // Debug only set_time_limit(0); From aab39b3f6abafbeb331f29ff255a43bba536571d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= <5175937+theofidry@users.noreply.github.com> Date: Fri, 8 Mar 2024 20:47:26 +0100 Subject: [PATCH 3/3] refactor: Update the signatures of the doctrine related classes (#66) Preparatory step for #63. --------- Co-authored-by: Nicolas Olive --- .../Functional/TestBundle/Entity/Product.php | 2 +- .../FakeDoctrineManagerRegistry.php | 26 +++-- .../ObjectMapper/FakeEntityManager.php | 98 ++++++++++--------- 3 files changed, 66 insertions(+), 60 deletions(-) diff --git a/fixtures/Functional/TestBundle/Entity/Product.php b/fixtures/Functional/TestBundle/Entity/Product.php index 5730de9..edba7dd 100644 --- a/fixtures/Functional/TestBundle/Entity/Product.php +++ b/fixtures/Functional/TestBundle/Entity/Product.php @@ -26,7 +26,7 @@ class Product #[ORM\Column(type: 'string', length: 100)] protected $name; - #[ORM\Column(type: 'decimal', scale: 2)] + #[ORM\Column(type: 'decimal', precision: 10, scale: 2)] protected $price; #[ORM\Column(type: 'text')] diff --git a/fixtures/Persistence/FakeDoctrineManagerRegistry.php b/fixtures/Persistence/FakeDoctrineManagerRegistry.php index 3c80240..bd8bf51 100644 --- a/fixtures/Persistence/FakeDoctrineManagerRegistry.php +++ b/fixtures/Persistence/FakeDoctrineManagerRegistry.php @@ -14,6 +14,7 @@ namespace Hautelook\AliceBundle\Persistence; use Doctrine\Persistence\ManagerRegistry; +use Doctrine\Persistence\ObjectManager; use function func_get_args; use Hautelook\AliceBundle\NotCallableTrait; @@ -26,57 +27,52 @@ public function getDefaultConnectionName(): string $this->__call(__METHOD__, func_get_args()); } - public function getConnection($name = null) + public function getConnection(?string $name = null): object { $this->__call(__METHOD__, func_get_args()); } - public function getConnections() + public function getConnections(): array { $this->__call(__METHOD__, func_get_args()); } - public function getConnectionNames() + public function getConnectionNames(): array { $this->__call(__METHOD__, func_get_args()); } - public function getDefaultManagerName() + public function getDefaultManagerName(): string { $this->__call(__METHOD__, func_get_args()); } - public function getManager($name = null) + public function getManager(?string $name = null): ObjectManager { $this->__call(__METHOD__, func_get_args()); } - public function getManagers() + public function getManagers(): array { $this->__call(__METHOD__, func_get_args()); } - public function resetManager($name = null) + public function resetManager(?string $name = null): ObjectManager { $this->__call(__METHOD__, func_get_args()); } - public function getAliasNamespace($alias) + public function getManagerNames(): array { $this->__call(__METHOD__, func_get_args()); } - public function getManagerNames() + public function getRepository(string $persistentObject, ?string $persistentManagerName = null) { $this->__call(__METHOD__, func_get_args()); } - public function getRepository($persistentObject, $persistentManagerName = null) - { - $this->__call(__METHOD__, func_get_args()); - } - - public function getManagerForClass($class) + public function getManagerForClass(string $class): ?ObjectManager { $this->__call(__METHOD__, func_get_args()); } diff --git a/fixtures/Persistence/ObjectMapper/FakeEntityManager.php b/fixtures/Persistence/ObjectMapper/FakeEntityManager.php index 72fbce1..eec44f8 100644 --- a/fixtures/Persistence/ObjectMapper/FakeEntityManager.php +++ b/fixtures/Persistence/ObjectMapper/FakeEntityManager.php @@ -13,8 +13,23 @@ namespace Hautelook\AliceBundle\Persistence\ObjectMapper; +use Doctrine\Common\EventManager; +use Doctrine\DBAL\Connection; +use Doctrine\ORM\Cache; +use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\EntityRepository; +use Doctrine\ORM\Internal\Hydration\AbstractHydrator; +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\NativeQuery; +use Doctrine\ORM\Proxy\ProxyFactory; +use Doctrine\ORM\Query; +use Doctrine\ORM\Query\Expr; +use Doctrine\ORM\Query\FilterCollection; use Doctrine\ORM\Query\ResultSetMapping; +use Doctrine\ORM\QueryBuilder; +use Doctrine\ORM\UnitOfWork; +use Doctrine\Persistence\ObjectRepository; use function func_get_args; use Hautelook\AliceBundle\NotCallableTrait; @@ -22,202 +37,197 @@ class FakeEntityManager implements EntityManagerInterface { use NotCallableTrait; - public function getCache() + public function getCache(): ?Cache { $this->__call(__METHOD__, func_get_args()); } - public function getConnection() + public function getConnection(): Connection { $this->__call(__METHOD__, func_get_args()); } - public function getExpressionBuilder() + public function getExpressionBuilder(): Expr { $this->__call(__METHOD__, func_get_args()); } - public function beginTransaction() + public function beginTransaction(): void { $this->__call(__METHOD__, func_get_args()); } - public function transactional($func) + public function transactional($func): mixed { $this->__call(__METHOD__, func_get_args()); } - public function commit() + public function commit(): void { $this->__call(__METHOD__, func_get_args()); } - public function rollback() + public function rollback(): void { $this->__call(__METHOD__, func_get_args()); } - public function createQuery($dql = '') + public function createQuery($dql = ''): Query { $this->__call(__METHOD__, func_get_args()); } - public function createNamedQuery($name) + public function createNamedQuery($name): Query { $this->__call(__METHOD__, func_get_args()); } - public function createNativeQuery($sql, ResultSetMapping $rsm) + public function createNativeQuery($sql, ResultSetMapping $rsm): NativeQuery { $this->__call(__METHOD__, func_get_args()); } - public function createNamedNativeQuery($name) + public function createNamedNativeQuery($name): NativeQuery { $this->__call(__METHOD__, func_get_args()); } - public function createQueryBuilder() + public function createQueryBuilder(): QueryBuilder { $this->__call(__METHOD__, func_get_args()); } - public function getReference($entityName, $id) + public function getReference($entityName, $id): ?object { $this->__call(__METHOD__, func_get_args()); } - public function getPartialReference($entityName, $identifier) + public function getPartialReference($entityName, $identifier): ?object { $this->__call(__METHOD__, func_get_args()); } - public function close() + public function close(): void { $this->__call(__METHOD__, func_get_args()); } - public function copy($entity, $deep = false) + public function copy($entity, $deep = false): object { $this->__call(__METHOD__, func_get_args()); } - public function lock($entity, $lockMode, $lockVersion = null) + public function lock($entity, $lockMode, $lockVersion = null): void { $this->__call(__METHOD__, func_get_args()); } - public function getEventManager() + public function getEventManager(): EventManager { $this->__call(__METHOD__, func_get_args()); } - public function getConfiguration() + public function getConfiguration(): Configuration { $this->__call(__METHOD__, func_get_args()); } - public function isOpen() + public function isOpen(): bool { $this->__call(__METHOD__, func_get_args()); } - public function getUnitOfWork() + public function getUnitOfWork(): UnitOfWork { $this->__call(__METHOD__, func_get_args()); } - public function getHydrator($hydrationMode) + public function getHydrator($hydrationMode): AbstractHydrator { $this->__call(__METHOD__, func_get_args()); } - public function newHydrator($hydrationMode) + public function newHydrator($hydrationMode): AbstractHydrator { $this->__call(__METHOD__, func_get_args()); } - public function getProxyFactory() + public function getProxyFactory(): ProxyFactory { $this->__call(__METHOD__, func_get_args()); } - public function getFilters() + public function getFilters(): FilterCollection { $this->__call(__METHOD__, func_get_args()); } - public function isFiltersStateClean() + public function isFiltersStateClean(): bool { $this->__call(__METHOD__, func_get_args()); } - public function hasFilters() + public function hasFilters(): bool { $this->__call(__METHOD__, func_get_args()); } - public function find($className, $id) + public function find(string $className, $id): ?object { $this->__call(__METHOD__, func_get_args()); } - public function persist($object) + public function persist(object $object): void { $this->__call(__METHOD__, func_get_args()); } - public function remove($object) + public function remove(object $object): void { $this->__call(__METHOD__, func_get_args()); } - public function merge($object) + public function clear($objectName = null): void { $this->__call(__METHOD__, func_get_args()); } - public function clear($objectName = null) + public function detach(object $object): void { $this->__call(__METHOD__, func_get_args()); } - public function detach($object) + public function refresh(object $object): void { $this->__call(__METHOD__, func_get_args()); } - public function refresh($object) + public function flush(): void { $this->__call(__METHOD__, func_get_args()); } - public function flush() + public function getRepository($className): EntityRepository { $this->__call(__METHOD__, func_get_args()); } - public function getRepository($className) + public function getMetadataFactory(): ObjectRepository { $this->__call(__METHOD__, func_get_args()); } - public function getMetadataFactory() + public function initializeObject(object $obj): void { $this->__call(__METHOD__, func_get_args()); } - public function initializeObject($obj) + public function contains(object $object): bool { $this->__call(__METHOD__, func_get_args()); } - public function contains($object) - { - $this->__call(__METHOD__, func_get_args()); - } - - public function getClassMetadata($className) + public function getClassMetadata($className): ClassMetadata { $this->__call(__METHOD__, func_get_args()); }