Skip to content

Releases: inpsyde/modularity

1.6.0

03 Feb 12:59
dd2ac0d
Compare
Choose a tag to compare

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


Props to @gmazzap @widoz @tyrann0us @nullbytes @Chrico

1.5.1

09 Mar 14:00
3bbff61
Compare
Choose a tag to compare

Make sure "name" is generated for LibraryProperties. See also #18 .


Props @gmazzap

1.5.0 - Allow overrides

26 Jan 12:57
c2fbaf2
Compare
Choose a tag to compare

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()

07 Dec 09:04
7cf2a56
Compare
Choose a tag to compare

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() and Package::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

08 Jul 14:31
6a0283d
Compare
Choose a tag to compare

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 into docs/ folder and with linking.
  • Add "authors" and update "description" in composer.json
  • Remove deprecated "allowCoercionFromStringToClassConst" attribute from Psalm configuration.

1.2.0

31 May 11:42
628b328
Compare
Choose a tag to compare

New Features

Improve module status reporting

The internal handling of module status reporting was improved. Additionally, the following improvements were implemented:

  1. If Properties::isDebug() is true, then all service IDs are logged to the state entries.
  2. 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

Props: @gmazzap , @pablok34 , @Chrico

1.1.0

21 May 08:36
e7de7c1
Compare
Choose a tag to compare

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.

1.0.0

10 May 13:59
Compare
Choose a tag to compare

The first release of inpsyde/modularity.

Props: @bueltge @pablok34 @Chrico @Biont