Skip to content
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
11 changes: 11 additions & 0 deletions .changelog/consistent-skill-sources.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
category: changed
type: patch
---

Synchronize the bundled local skill automatically and trust Fast Forward Composer
skill donors through `fast-forward/*`.
Resolve Changelog contributor skills from stable `0.4.x` releases without a
redundant skill allowlist.
Load the project autoloader for PHPDoc checks when DevTools is installed as a
dependency.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
/docs/ export-ignore
/README*.md export-ignore
/skills.json export-ignore
/.php-cs-fixer.dist.php export-ignore
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ composer.lock
/docker_tag
/output.log
/.agents/
/.dev-tools/
38 changes: 38 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

/**
* This file is part of php-fast-forward/container.
*
* This source file is subject to the license bundled
* with this source code in the file LICENSE.
*
* @copyright Copyright (c) 2025-2026 Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
* @license https://opensource.org/licenses/MIT MIT License
*
* @see https://github.com/php-fast-forward/container
* @see https://github.com/php-fast-forward
* @see https://datatracker.ietf.org/doc/html/rfc2119
*/

use FastForward\DevTools\Path\WorkingProjectPathResolver;
use PhpCsFixer\Config;
use PhpCsFixer\Finder;

require __DIR__ . '/vendor/autoload.php';

return (new Config())
->setRiskyAllowed(false)
->setFinder(Finder::create()->in(__DIR__)->exclude(WorkingProjectPathResolver::TOOLING_EXCLUDED_DIRECTORIES))
->setRules([
'phpdoc_indent' => true,
'phpdoc_order' => ['order' => ['param', 'return', 'throws']],
'phpdoc_separation' => true,
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_scalar' => true,
'phpdoc_types' => true,
'phpdoc_to_comment' => false,
'phpdoc_add_missing_param_annotation' => true,
]);
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
"allow-plugins": {
"ergebnis/composer-normalize": true,
"fast-forward/dev-tools": true,
"llm/skills": true,
"phpdocumentor/shim": true,
"phpro/grumphp": true,
"phpro/grumphp-shim": true,
"pyrech/composer-changelogs": true,
"llm/skills": true
"pyrech/composer-changelogs": true
},
"platform": {
"php": "8.3.0"
Expand Down
2 changes: 0 additions & 2 deletions examples/06-factory-helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ public function __construct(

/**
* @param DeploymentStage $stage
*
* @return self
*/
public static function fromStage(DeploymentStage $stage): self
{
Expand Down
2 changes: 1 addition & 1 deletion examples/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @see https://datatracker.ietf.org/doc/html/rfc2119
*/

require dirname(__DIR__) . '/vendor/autoload.php';
require __DIR__ . '/../vendor/autoload.php';

/**
* Prints a standard title for CLI examples.
Expand Down
13 changes: 7 additions & 6 deletions skills.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/roxblnfk/skills/master/resources/skills.schema.json",
"$schema": "https://raw.githubusercontent.com/roxblnfk/skills/1.15.0/resources/skills.schema.json",
"target": ".agents/skills",
"aliases": [],
"discovery": false,
Expand All @@ -8,19 +8,20 @@
"dependencies": {
"composer": {
"trusted": [
"fast-forward/config"
"fast-forward/*"
],
"trusted-replace": true
}
},
"sources": [
{
"from": "dir",
"path": "resources/skills"
},
{
"from": "github",
"package": "php-fast-forward/changelog",
"ref": "^0.3.0",
"skills": [
"fast-forward-changelog"
]
"ref": "^0.4.0"
}
]
}
4 changes: 1 addition & 3 deletions src/AggregateContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ public function append(PsrContainerInterface $container): void
{
$this->containers[] = $container;

if (! isset($this->resolved[$container::class])) {
$this->resolved[$container::class] = $container;
}
$this->resolved[$container::class] ??= $container;
}

/**
Expand Down
35 changes: 30 additions & 5 deletions tests/Factory/CallableFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,45 +99,71 @@ public function invokeWillThrowRuntimeExceptionIfParameterIsNotAClass(): void

$factory($container);
}

/**
* Rejects union parameter types that the callable factory cannot resolve.
*
* @return void
*/
#[Test]
public function unionParameterReceivesInvalidTypeDiagnostic(): void
{
$factory = new CallableFactory(static fn(ContainerInterface|FactoryInterface $dependency) => $dependency);
$factory = new CallableFactory(static fn(ContainerInterface|FactoryInterface $dependency): ContainerInterface|FactoryInterface => $dependency);
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Parameter "dependency" is not a valid type.');
$factory($this->prophesize(ContainerInterface::class)->reveal());
}

/**
* Rejects intersection parameter types with the expected diagnostic.
*
* @return void
*/
#[Test]
public function intersectionParameterReceivesInvalidTypeDiagnostic(): void
{
$factory = new CallableFactory(static fn(ContainerInterface&FactoryInterface $dependency) => $dependency);
$factory = new CallableFactory(static fn(ContainerInterface&FactoryInterface $dependency): ContainerInterface&FactoryInterface => $dependency);
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Parameter "dependency" is not a valid type.');
$factory($this->prophesize(ContainerInterface::class)->reveal());
}

/**
* Resolves a nullable named dependency from the container.
*
* @return void
*/
#[Test]
public function nullableNamedParameterStillResolvesDependency(): void
{
$container = $this->prophesize(ContainerInterface::class);
$dependency = $this->prophesize(FactoryInterface::class)->reveal();
$container->get(FactoryInterface::class)->willReturn($dependency);
$factory = new CallableFactory(static fn(?FactoryInterface $dependency) => $dependency);
$factory = new CallableFactory(static fn(?FactoryInterface $dependency): ?FactoryInterface => $dependency);
self::assertSame($dependency, $factory($container->reveal()));
}

/**
* Rejects a disjunctive normal form parameter type.
*
* @return void
*/
#[Test]
public function dnfParameterReceivesInvalidTypeDiagnostic(): void
{
$factory = new CallableFactory(
static fn((ContainerInterface&FactoryInterface)|ServiceProviderInterface $dependency) => $dependency
static fn((ContainerInterface&FactoryInterface)|ServiceProviderInterface $dependency): (ContainerInterface&FactoryInterface)|ServiceProviderInterface => $dependency
);
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Parameter "dependency" is not a valid type.');
$factory($this->prophesize(ContainerInterface::class)->reveal());
}

/**
* Rejects parameters without a named dependency type.
*
* @return void
*/
#[Test]
public function untypedParameterReceivesInvalidTypeDiagnostic(): void
{
Expand All @@ -146,5 +172,4 @@ public function untypedParameterReceivesInvalidTypeDiagnostic(): void
$this->expectExceptionMessage('Parameter "dependency" is not a valid type.');
$factory($this->prophesize(ContainerInterface::class)->reveal());
}

}
Loading