From 5611b1732163cce1060ee50b7439a2a4824140c7 Mon Sep 17 00:00:00 2001 From: Quentin Schuler Date: Wed, 8 Jul 2026 12:02:47 +0200 Subject: [PATCH] Discover providers from the project itself. --- src/Manifests/ContainerMixinManifest.php | 7 ++++--- src/Manifests/PackageManifest.php | 13 +++++++++++-- tests/Support/composer.json | 3 +++ 3 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 tests/Support/composer.json diff --git a/src/Manifests/ContainerMixinManifest.php b/src/Manifests/ContainerMixinManifest.php index afb6f13..33b876e 100644 --- a/src/Manifests/ContainerMixinManifest.php +++ b/src/Manifests/ContainerMixinManifest.php @@ -120,8 +120,8 @@ public function build(array $extensionMethods, array $extensions) $tags[] = new Method( $methodName, - returnType: $reflectionMethod->hasReturnType() ? (new TypeResolver())->resolve($reflectionMethod->getReturnType()) : new Mixed_(), parameters: $parameters, + returnType: $reflectionMethod->hasReturnType() ? (new TypeResolver())->resolve($reflectionMethod->getReturnType()) : new Mixed_(), ); } @@ -142,8 +142,9 @@ public function build(array $extensionMethods, array $extensions) public function shouldRecompile(): bool { return !is_file($this->containerMixinPath) || - // We check here if the manifest has been generated before changing the installed.json composer file - filemtime($this->containerMixinPath) <= filemtime($this->vendorPath.'/composer/installed.json'); + // We check here if the manifest has been generated before changing the installed.json composer file or the project composer.json + filemtime($this->containerMixinPath) <= filemtime($this->vendorPath.'/composer/installed.json') || + filemtime($this->containerMixinPath) <= filemtime($this->basePath.'/composer.json'); } /** diff --git a/src/Manifests/PackageManifest.php b/src/Manifests/PackageManifest.php index 53e964b..c81c1ca 100644 --- a/src/Manifests/PackageManifest.php +++ b/src/Manifests/PackageManifest.php @@ -120,6 +120,14 @@ public function build() } } + if (is_file($path = $this->basePath.'/composer.json')) { + $package = json_decode(file_get_contents($path), true); + + if (isset($package['extra']['faker'])) { + $packagesToProvide[$package['name'] ?? 'root'] = $package['extra']['faker']; + } + } + $this->write( $packagesToProvide ); @@ -133,8 +141,9 @@ public function build() public function shouldRecompile(): bool { return !is_file($this->manifestPath) || - // We check here if the manifest has been generated before changing the installed.json composer file - filemtime($this->manifestPath) <= filemtime($this->vendorPath.'/composer/installed.json'); + // We check here if the manifest has been generated before changing the installed.json composer file or the project composer.json + filemtime($this->manifestPath) <= filemtime($this->vendorPath.'/composer/installed.json') || + filemtime($this->manifestPath) <= filemtime($this->basePath.'/composer.json'); } /** diff --git a/tests/Support/composer.json b/tests/Support/composer.json new file mode 100644 index 0000000..b593485 --- /dev/null +++ b/tests/Support/composer.json @@ -0,0 +1,3 @@ +{ + "name": "xefi/faker-php-tests-support" +}