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
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Set default behavior to automatically normalize line endings to LF on all text files.
* text eol=lf

test export-ignore
nbproject export-ignore
.idea export-ignore
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [[*next-version*]] - YYYY-MM-DD
### Changed
- Aligned param names with those of PSR interfaces (#37).
- Added more generics (#38).

## [0.5.0-beta1] - 2026-03-23
### Changed
Expand Down
1 change: 0 additions & 1 deletion src/ClearableContainerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ interface ClearableContainerInterface extends PsrContainerInterface
/**
* Removes all members from this container.
*
* @psalm-suppress InvalidThrow In PSR-11, this interface does not extend `Throwable`.
* @throws ContainerExceptionInterface If problem removing.
*/
public function clear(): void;
Expand Down
25 changes: 25 additions & 0 deletions src/ContainerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,34 @@

/**
* Something that can retrieve and determine the existence of a value by key.
*
* @template K of string
* @template-covariant V of mixed
* @template-extends HasCapableInterface<K>
*/
interface ContainerInterface extends
HasCapableInterface,
BaseContainerInterface
{
/**
* Finds an entry of the container by its identifier and returns it.
*
* @param K $id Identifier of the entry to look for.
*
* @return V Entry.
*
* @psalm-suppress MoreSpecificImplementedParamType The point is to narrow it.
*/
#[\Override]
public function get(string $id): mixed;

/**
* @inheritDoc
*
* @param K $id Identifier of the entry to look for.
*
* @psalm-suppress MoreSpecificImplementedParamType The point is to narrow it.
*/
#[\Override]
public function has(string $id): bool;
}
6 changes: 3 additions & 3 deletions src/HasCapableInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@

/**
* Something that can determine the existence of a key.
*
* @template K of string
*/
interface HasCapableInterface
{
/**
* Determines whether this instance has the specified key.
*
* @param string $id The key to check for.
*
* @param K $id The key to check for.
* @return bool True if the key exists; false otherwise.
*
* @throws ContainerExceptionInterface If problem determining.
*
* @psalm-suppress PossiblyUnusedMethod
* @psalm-suppress InvalidThrow
*/
public function has(string $id): bool;
}
2 changes: 1 addition & 1 deletion src/HasItemCapableInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ interface HasItemCapableInterface
*
* @psalm-suppress PossiblyUnusedMethod
*/
public function hasItem($item): bool;
public function hasItem(mixed $item): bool;
}
1 change: 1 addition & 0 deletions src/MapInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @template TKey of string
* @template-covariant TValue of mixed
* @template-extends Traversable<TKey, TValue>
* @template-extends ContainerInterface<TKey, TValue>
*/
interface MapInterface extends
/* @since 0.2 */
Expand Down
14 changes: 8 additions & 6 deletions src/MutableContainerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
/**
* A container that can have mappings added and removed.
*
* @template K of string
* @template V of mixed
* @template-extends ContainerInterface<K, V>
*
* @psalm-suppress UnusedClass
*/
interface MutableContainerInterface extends ContainerInterface
Expand All @@ -19,24 +23,22 @@ interface MutableContainerInterface extends ContainerInterface
*
* @since [*next-version*]
*
* @param string $key The key to map the value to.
* @param mixed $value The value to map to the key.
* @param K $key The key to map the value to.
* @param V $value The value to map to the key.
*
* @throws ContainerExceptionInterface If problem mapping.
* @psalm-suppress InvalidThrow
*/
public function set(string $key, $value): void;
public function set(string $key, mixed $value): void;

/**
* Unmaps the value from the specified key.
*
* @since [*next-version*]
*
* @param string $key The key to unmap the value from.
* @param K $key The key to unmap the value from.
*
* @throws NotFoundExceptionInterface If key not found.
* @throws ContainerExceptionInterface If problem unmapping.
* @psalm-suppress InvalidThrow
*/
public function unset(string $key): void;
}
9 changes: 8 additions & 1 deletion src/WritableContainerFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ interface WritableContainerFactoryInterface extends ContainerFactoryInterface
/**
* @inheritDoc
*
* @return WritableContainerInterface The new container.
* @template K of string
* @template V of mixed
*
* @param array<K, V> $data The data for the container.
*
* @return WritableContainerInterface<K, V> The new container.
*
* @psalm-suppress MoreSpecificImplementedParamType PSR-11 does not declare generics, but should
*/
#[\Override]
public function createContainerFromArray(array $data): ContainerInterface;
Expand Down
11 changes: 8 additions & 3 deletions src/WritableContainerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

/**
* A container that can be written to.
*
* @template K of string
* @template V of mixed
*
* @template-extends ContainerInterface<K, V>
*/
interface WritableContainerInterface extends ContainerInterface
{
Expand All @@ -16,7 +21,7 @@ interface WritableContainerInterface extends ContainerInterface
*
* @since [*next-version*]
*
* @param array<string, mixed> $mappings A map of keys to values.
* @param array<K, V> $mappings A map of keys to values.
*
* @return static A new instance of this class with only the specified key-value mappings.
*
Expand All @@ -31,7 +36,7 @@ public function withMappings(array $mappings): WritableContainerInterface;
*
* @since [*next-version*]
*
* @param array<string, mixed> $mappings A map of keys to values.
* @param array<K, V> $mappings A map of keys to values.
*
* @return static A new instance of this class with the specified key-value mappings added to existing ones.
*
Expand All @@ -46,7 +51,7 @@ public function withAddedMappings(array $mappings): WritableContainerInterface;
*
* @since [*next-version*]
*
* @param array<string> $keys The keys to exclude.
* @param array<K> $keys The keys to exclude.
*
* @return static A new instance of this class which does not contain the specified keys.
*
Expand Down
9 changes: 8 additions & 1 deletion src/WritableMapFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ interface WritableMapFactoryInterface extends WritableContainerFactoryInterface,
/**
* @inheritDoc
*
* @return WritableMapInterface The new map.
* @template K of string
* @template V of mixed
*
* @param array<K, V> $data The data for the container.
*
* @return WritableMapInterface<K, V> The new container.
*
* @psalm-suppress MoreSpecificImplementedParamType PSR-11 does not declare generics, but should
*/
#[\Override]
public function createContainerFromArray(array $data): WritableMapInterface;
Expand Down
3 changes: 2 additions & 1 deletion src/WritableMapInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
* @since [*next-version*]
*
* @template TKey of string
* @template-covariant TValue of mixed
* @template TValue of mixed
* @template-extends MapInterface<TKey, TValue>
* @template-extends WritableContainerInterface<TKey, TValue>
*/
interface WritableMapInterface extends MapInterface, WritableContainerInterface
{
Expand Down
Loading