Releases: inpsyde/modularity
1.6.0
Upgrade php-fig/container
to ^1.1.0 || ^2
This release will drop the support for php-fig/container
in version 1.0.0
. The new minimum required version is ^1.1.0 || ^2
.
This will also add support for typehints on ContainerInterface::get(string $id)
and ContainerInterface::has(string $id): bool;
.
QoL
- Introduce usage of
inpsyde/reusable-workflows
. (30246f9) - Update
psalm.xml
to remove the deprecatedtotallyTyped
attribute. (9b5c157) - Unify "inpsyde.com" spelling. (fde75bc)
- Improve documentation examples. (65bc3f8)
- Improve naming of parameters in
Package::moduleProgress()
(7284b74)
Props to @gmazzap @widoz @tyrann0us @nullbytes @Chrico
1.5.1
1.5.0 - Allow overrides
With this release, Modules can now replace services that have already been registered by other Modules. The Exception that was previously thrown has now been removed.
More information on this change can be found in the pull request. There is also added documentation at /docs/Modules.md
1.4.0 - Package::connect()
It is now possible to connect Packages via Package::connect()
. Read more about the newest feature in our documentation: https://inpsyde.github.io/modularity/Package/#connecting-packages
Development
- Added
Package::connect()
- Added ACTION_PACKAGE_CONNECTED and ACTION_FAILED_CONNECTION actions
- Added
Package::connectedPackages()
andPackage::isPackageConnected()
utility methods - Added
PackageProxyContainer
class
Unit tests
- Added cases in PackageTest to test packages connection
- Require WP_Error from real WordPress in tests (no need to mock)
- Improve PHPUnit bootstrap: no need to require autoload when PHPUNIT_COMPOSER_INSTALL is defined
Psalm
- Remove custom autoloader and use PHP Stubs instead
- Update config for latest Psalm version
- Fix minor Psalm issues in LibraryProperties
Misc
Restricted accepted range of dev-dependencies
Docs
- Add documentation for package connection
- We can have a
<h1>
in every file, and
Special props to @gmazzap who did the main work 💪
1.3.0
PluginProperties - support for non-default plugin headers
With this release, support for non-default plugin headers has been added, which can be accessed via PluginProperties::get()
and PluginProperties::has()
(#13).
For example, given the following headers:
/**
* Author: Inpsyde GmbH
* Author URI: https://www.inpsyde.com
*
* WC requires at least: 2.2
* WC tested up to: 2.3
*/
You can access them as follows:
$properties = Inpsyde\Modularity\Properties\PluginProperties::new(__FILE__);
// Default header mapped internally to API
$properties->author(); // Inpsyde GmbH
$properties->get(Properties::PROP_AUTHOR); // works as well, same as above
// Default header mapped internally to API
$properties->authorUri(); // https://www.inpsyde.com
$properties->get(Properties::PROP_AUTHOR_URI); // works as well, same as above
// Custom Headers
$properties->get('WC requires at least'); // 2.2
$properties->get('WC tested up to'); // 2.3
General Improvements
- Add Codecov support to repository.
- Add badges to
README.md
and split documentation intodocs/
folder and with linking. - Add
"authors"
and update"description"
incomposer.json
- Remove deprecated
"allowCoercionFromStringToClassConst"
attribute from Psalm configuration.
1.2.0
New Features
Improve module status reporting
The internal handling of module status reporting was improved. Additionally, the following improvements were implemented:
- If
Properties::isDebug()
istrue
, then all service IDs are logged to the state entries. - A new constant
Package::MODULE_NOT_ADDED
was added for Modules that are not providing any Service, Factory, or Extension.
Allow setting base URL in LibraryProperties
Often when we create a library we don't know the base URL of the library because we don't know where it will be installed and WordPress doesn't support libraries natively. Therefore LibraryProperties::baseUrl()
returns null
by default.
In case a LibraryProperties
instance is created in a context where the base URL is known, it is possible to include it when creating the instance:
$url = 'https://example.com/wp-content/vendor/my/library';
$properties = Inpsyde\Modularity\Properties\LibraryProperties::new('path/to/composer.json', $url);
If the URL is known at a later time when an instance of LibraryProperties
already exists, the withBaseUrl()
method can be used:
$url = 'https://example.com/wp-content/vendor/my/library';
/** @var Inpsyde\Modularity\Properties\LibraryProperties $properties */
$properties->withBaseUrl($url);
Please note that withBaseUrl()
only works if a base URL is not already set, otherwise an exception will be thrown.
Improvements
Use static::
, not self::
For static method calls, if the class is not final, this is relevant.
Use class name as return type instead of self
If a class is not final
, an extending class cannot use the same self
return type as this is a fatal error. It would be possible in PHP 7.4+, but PHP 8 supports static
, which is better, and we can already use it in DocBlocks.
Fixes
- Fix wrong funtion name in
README.md
- Use mixed return type in
ReadOnlyContainer::get
- Remove unused
@psalm-suppress
- Fix object DocBlock for services
1.1.0
Improvements
ReadOnlyContainer
now allows support for mixed return values as Services from Modules and from 3rd party PSR Containers.
See also here: #4
<?php
declare(strict_types=1);
use Inpsyde\Modularity\Module\ServiceModule;
use Inpsyde\Modularity\Module\ModuleClassNameIdTrait;
use Psr\Container\ContainerInterface;
class ModuleWhichProvidesServices implements ServiceModule
{
use ModuleClassNameIdTrait;
public function services() : array
{
return [
ServiceOne::class => static function(ContainerInterface $container): ServiceOne {
return new ServiceOne($container->get('string-value'));
},
// NEW:
'string-value' => static function(): string {
return 'my-string';
},
'array-value' => static function(): array {
return ['foo', 'bar', 'baz'];
},
'int-value' => static function(): int {
return 7411;
}
];
}
}
Code quality
- ThemeProperties // removed inline DocBlock which is not needed.
- ReadOnlyContainer // remove inline DocBlock for resolved external Services.