diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml index 69671cfb..745251be 100644 --- a/.docker/docker-compose.yml +++ b/.docker/docker-compose.yml @@ -1,4 +1,3 @@ -version: '3.8' services: wordpress: diff --git a/.gitignore b/.gitignore index babb946f..b871314e 100644 --- a/.gitignore +++ b/.gitignore @@ -47,4 +47,5 @@ package-lock.json c3.php **/*.local.php /.idea/ -*.bak \ No newline at end of file +*.bak +/.sisyphus/* \ No newline at end of file diff --git a/Makefile b/Makefile index 0a5d663f..3cb3372d 100644 --- a/Makefile +++ b/Makefile @@ -44,6 +44,10 @@ down: ### Stop the containers inside the ./docker folder @$(DOCKER_DIR) docker-compose down --remove-orphans --volumes @echo "Containers stopped" +.PHONY: restart +restart: down up ### Restart the containers inside the ./docker folder + @echo "Containers restarted" + # Composer commands .PHONY: composer/install @@ -164,6 +168,11 @@ metrics: up ### Run the composer/metrics @echo "Running the psalm" @$(DOCKER_DIR) ./composer metrics +.PHPHONY: ssh +ssh: ### Run bash in the php74 container + @echo "Running bash in the php74 container" + @$(DOCKER_DIR) ./ssh + # Generate commands .PHONY: generate diff --git a/comments.php b/comments.php index 2014d31c..4027ac17 100644 --- a/comments.php +++ b/comments.php @@ -13,8 +13,6 @@ use Auryn\Injector; use ItalyStrap\Config\ConfigInterface; -use ItalyStrap\Event\EventDispatcher; -use ItalyStrap\Event\EventDispatcherInterface; use ItalyStrap\Event\ListenerRegisterInterface; use function _n; use function do_blocks; diff --git a/composer.json b/composer.json index 01261e7c..179e4270 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,8 @@ "homepage": "https://github.com/ItalyStrap/italystrap/graphs/contributors" } ], - "minimum-stability": "stable", + "minimum-stability": "dev", + "prefer-stable": true, "repositories": [ { "type": "package", @@ -28,11 +29,15 @@ "url": "https://github.com/WordPress/WordPress/archive/master.zip" } } + }, + { + "type": "vcs", + "url": "https://github.com/ItalyStrap/empress" } ], "require": { "php" : ">=7.4", - "italystrap/empress": "dev-modularized", + "italystrap/empress": "dev-modularized as 2.0.x-dev", "italystrap/event": "dev-master", "italystrap/config": "^2.0", "italystrap/helpers": "^1.0", @@ -40,14 +45,13 @@ "italystrap/view": "^1.0", "italystrap/finder": "dev-master", "italystrap/asset": "dev-master", - "rdlowrey/auryn": "^1.4", "overclokk/minimum-requirements": "dev-master", "cmb2/cmb2": "2.6.0", "yiisoft/json": "^1.0", "symfony/polyfill-php80": "^1.0" }, "require-dev": { - "lucatume/wp-browser": "^3.0.0", + "lucatume/wp-browser": "<3.5", "lucatume/function-mocker-le": "^1.0.0", "lucatume/function-mocker": "^1.3", "codeception/c3": "2.*", @@ -146,39 +150,39 @@ "@php vendor/bin/phpcbf -p" ], "psalm": [ - "@php vendor//bin//psalm --no-cache" + "@php vendor/bin/psalm --no-cache" ], "analyze": [ - "@php vendor//bin//phpstan analyze --level=max && vendor//bin//psalm" + "@php vendor/bin/phpstan analyze --level=max && vendor//bin//psalm" ], "infection": [ - "@php vendor//bin//infection --threads=8" + "@php vendor/bin/infection --threads=8" ], "unit": [ - "@php vendor//bin//codecept run unit", + "@php vendor/bin/codecept run unit", "@clean" ], "unit:cov": [ - "@php vendor//bin//codecept run unit --coverage", + "@php vendor/bin/codecept run unit --coverage", "@clean" ], "unit:debug": [ - "@php vendor//bin//codecept run unit --debug", + "@php vendor/bin/codecept run unit --debug", "@clean" ], "integration": [ - "@php vendor//bin//codecept run integration", + "@php vendor/bin/codecept run integration", "@clean" ], "integration:debug": [ - "@php vendor//bin//codecept run integration --debug", + "@php vendor/bin/codecept run integration --debug", "@clean" ], "functional": [ - "@php vendor//bin//codecept run functional" + "@php vendor/bin/codecept run functional" ], "bench": [ - "@php vendor//bin//phpbench run --report=performance" + "@php vendor/bin/phpbench run --report=performance" ], "metrics": [ "@php vendor//bin//phpmetrics --report-html='./tests/_output/report' ./src", diff --git a/config/autoload/dependencies.global.php b/config/autoload/dependencies.global.php index a579d1c5..f139315f 100644 --- a/config/autoload/dependencies.global.php +++ b/config/autoload/dependencies.global.php @@ -4,7 +4,6 @@ namespace ItalyStrap; -use Auryn\Injector; use ItalyStrap\Config\Config; use ItalyStrap\Config\ConfigInterface; use ItalyStrap\Customizer\CustomizerAssetsSubscriber; diff --git a/config/dependencies.config.php b/config/dependencies.config.php index b7108baf..a88b9ad0 100644 --- a/config/dependencies.config.php +++ b/config/dependencies.config.php @@ -2,12 +2,12 @@ declare(strict_types=1); +use Auryn\Injector; use ItalyStrap\Asset\Module as AssetModule; use ItalyStrap\Config\ConfigFactory; use ItalyStrap\Config\ConfigInterface; use ItalyStrap\Config\ConfigProviderExtension; use ItalyStrap\Config\ConfigThemeModsProvider; -use ItalyStrap\Empress\Injector; use ItalyStrap\Empress\PhpFileProvider; use ItalyStrap\Empress\ProvidersCacheInterface; use ItalyStrap\Empress\ProvidersCollection; @@ -18,9 +18,11 @@ use ItalyStrap\UI\Module as UIModule; return static function (Injector $injector): ConfigInterface { + $config = (new ConfigFactory())->make(); $collection = new ProvidersCollection( $injector, - ConfigFactory::make(), + $config, + null, [ // First we load Modules from packages EventModule::class, @@ -34,9 +36,9 @@ '/config/autoload/{{,*.}global,{,*.}local}.php', $injector->execute(ExperimentalThemeFileFinderFactory::class) ), - // ProvidersCacheInterface::CACHE_PATH => get_template_directory() . '/config/cache/config-cache.php', + // ProvidersCacheInterface::CACHE_PATH => get_template_directory() . '/config/cache/config-cache.php', fn(): array => [ - // ProvidersCacheInterface::CACHE_PATH => get_template_directory() . '/config/cache/config-cache.php', + // ProvidersCacheInterface::CACHE_PATH => get_template_directory() . '/config/cache/config-cache.php', ProvidersCacheInterface::ENABLE_CACHE => true, ], /** This must run after all */ @@ -51,5 +53,5 @@ $collection->build(); - return $collection->collection(); + return $config; }; diff --git a/functions/factory.php b/functions/factory.php index bba07f21..fd783cca 100644 --- a/functions/factory.php +++ b/functions/factory.php @@ -9,14 +9,8 @@ namespace ItalyStrap\Factory; use Auryn\ConfigException; -use Auryn\InjectionException; use Auryn\Injector as AurynInjector; -use Exception; -use ItalyStrap\Config\ConfigInterface; use ItalyStrap\Debug\Injector as DebugInjector; -use ItalyStrap\Empress\Injector as EmpressInjector; -use ItalyStrap\Config\Config; -use ItalyStrap\View\View; use function ItalyStrap\Core\is_debug; @@ -35,8 +29,7 @@ function injector(): AurynInjector $injector = apply_filters('italystrap_injector', false); if (!$injector) { - $injector = new EmpressInjector(); - $injector->alias(AurynInjector::class, EmpressInjector::class); + $injector = new AurynInjector(); $injector->share($injector); add_filter('italystrap_injector', function () use ($injector) { return $injector; diff --git a/parts/comments.html b/parts/comments.html index a0b2ba2c..8f8df7e3 100644 --- a/parts/comments.html +++ b/parts/comments.html @@ -1,49 +1 @@ - -
</body>', 'italystrap'),
'italystrap_before_header' => \__('Before the header', 'italystrap'),
diff --git a/src/Experimental/ExperimentalHookComponentsDeprecationSubscriber.php b/src/Experimental/ExperimentalHookComponentsDeprecationSubscriber.php
index ddfa5625..879c03fa 100644
--- a/src/Experimental/ExperimentalHookComponentsDeprecationSubscriber.php
+++ b/src/Experimental/ExperimentalHookComponentsDeprecationSubscriber.php
@@ -209,12 +209,12 @@ public function onFooterAfter(FooterAfter $event)
$this->appendContent(['italystrap_after_footer'], FooterAfter::class, $event);
}
- private function appendContent(array $eventName, string $replacement, object $event): void
+ private function appendContent(array $eventsName, string $replacement, object $event): void
{
ob_start();
- foreach ($eventName as $name) {
- $this->globalDispatcher->trigger($name);
- $this->deprecatedEventName($name, $replacement);
+ foreach ($eventsName as $eventName) {
+// $this->globalDispatcher->trigger($eventName);
+// $this->deprecatedEventName($eventName, $replacement);
}
$event->appendContent((string)ob_get_clean());
}
@@ -228,13 +228,13 @@ private function deprecatedEventName(string $eventName, string $replacement): vo
return;
}
- _deprecated_hook(
- $eventName,
- '4.0.0',
- sprintf(
- 'Use %s instead',
- $replacement
- )
- );
+// _deprecated_hook(
+// $eventName,
+// '4.0.0',
+// sprintf(
+// 'Use %s instead',
+// $replacement
+// )
+// );
}
}
diff --git a/src/Navigation/Domain/NavMenu.php b/src/Navigation/Domain/NavMenu.php
index 59f57eff..0ad643b9 100644
--- a/src/Navigation/Domain/NavMenu.php
+++ b/src/Navigation/Domain/NavMenu.php
@@ -34,7 +34,7 @@ class NavMenu implements NavMenuInterface
public function __construct(
Walker_Nav_Menu $walker,
- callable $fallback_cb = null
+ ?callable $fallback_cb = null
) {
$this->walker = $walker;
$this->fallback_cb = $fallback_cb ?? 'wp_page_menu';
diff --git a/src/Navigation/Infrastructure/BootstrapNavMenu.php b/src/Navigation/Infrastructure/BootstrapNavMenu.php
index 48025a0c..82af877d 100644
--- a/src/Navigation/Infrastructure/BootstrapNavMenu.php
+++ b/src/Navigation/Infrastructure/BootstrapNavMenu.php
@@ -34,7 +34,7 @@
*/
class BootstrapNavMenu extends Walker_Nav_Menu {
- public function __construct( ListenerRegisterInterface $listenerRegister = null ) {
+ public function __construct( ?ListenerRegisterInterface $listenerRegister = null ) {
$this->listenerRegister = $listenerRegister ?? new GlobalOrderedListenerProvider();
}
diff --git a/src/Navigation/Module.php b/src/Navigation/Module.php
index 1d2e35fe..583afc38 100644
--- a/src/Navigation/Module.php
+++ b/src/Navigation/Module.php
@@ -4,9 +4,9 @@
namespace ItalyStrap\Navigation;
+use Auryn\Injector;
use ItalyStrap\Config\ConfigProviderExtension;
use ItalyStrap\Empress\AurynConfig;
-use ItalyStrap\Empress\Injector;
use ItalyStrap\Event\SubscribersConfigExtension;
use ItalyStrap\Navigation\Admin\ItemCustomFieldsSubscriber;
use ItalyStrap\Navigation\Application\NavMenusSubscriber;
@@ -50,7 +50,10 @@ public function __invoke(): iterable
],
NavMenuPrimary::class => [
- '+fallback' => static fn(string $named_param, Injector $injector): callable => $injector->make(NavMenuFallback::class),
+ '+fallback' => static fn(
+ string $named_param,
+ Injector $injector
+ ): callable => $injector->make(NavMenuFallback::class),
],
],
diff --git a/src/Navigation/UI/Components/LinkPages.php b/src/Navigation/UI/Components/LinkPages.php
index 0eec0012..aa669449 100644
--- a/src/Navigation/UI/Components/LinkPages.php
+++ b/src/Navigation/UI/Components/LinkPages.php
@@ -4,7 +4,7 @@
namespace ItalyStrap\Navigation\UI\Components;
-use ItalyStrap\Event\EventDispatcherInterface;
+use ItalyStrap\Event\GlobalDispatcherInterface as EventDispatcherInterface;
use function wp_link_pages;
@@ -14,7 +14,7 @@
*/
class LinkPages
{
- private \ItalyStrap\Event\EventDispatcherInterface $dispatcher;
+ private EventDispatcherInterface $dispatcher;
/**
* LinkPages constructor.
diff --git a/src/Navigation/UI/Components/MainNavigation.php b/src/Navigation/UI/Components/MainNavigation.php
index b1fe1021..4e4be820 100644
--- a/src/Navigation/UI/Components/MainNavigation.php
+++ b/src/Navigation/UI/Components/MainNavigation.php
@@ -6,7 +6,7 @@
use ItalyStrap\Components\SubscribedEventsAware;
use ItalyStrap\Config\ConfigInterface;
-use ItalyStrap\Event\EventDispatcherInterface;
+use ItalyStrap\Event\GlobalDispatcherInterface as EventDispatcherInterface;
use ItalyStrap\Event\SubscriberInterface;
use ItalyStrap\UI\Components\ComponentInterface;
use ItalyStrap\View\ViewInterface;
diff --git a/src/Navigation/UI/Components/MiscNavigation.php b/src/Navigation/UI/Components/MiscNavigation.php
index 12880a16..3d8ac495 100644
--- a/src/Navigation/UI/Components/MiscNavigation.php
+++ b/src/Navigation/UI/Components/MiscNavigation.php
@@ -6,7 +6,7 @@
use ItalyStrap\Components\SubscribedEventsAware;
use ItalyStrap\Config\ConfigInterface;
-use ItalyStrap\Event\EventDispatcherInterface;
+use ItalyStrap\Event\GlobalDispatcherInterface as EventDispatcherInterface;
use ItalyStrap\Event\SubscriberInterface;
use ItalyStrap\UI\Components\ComponentInterface;
use ItalyStrap\View\ViewInterface;
diff --git a/src/Navigation/UI/Components/NavMenuPrimary.php b/src/Navigation/UI/Components/NavMenuPrimary.php
index e18d9b3c..f75c3940 100644
--- a/src/Navigation/UI/Components/NavMenuPrimary.php
+++ b/src/Navigation/UI/Components/NavMenuPrimary.php
@@ -34,7 +34,7 @@ public function __construct(
ViewInterface $view,
NavMenuInterface $menu,
NavMenuLocationInterface $location,
- callable $fallback = null
+ ?callable $fallback = null
) {
$this->config = $config;
$this->view = $view;
diff --git a/src/Navigation/UI/Components/NavMenuToggleButton.php b/src/Navigation/UI/Components/NavMenuToggleButton.php
index 629bb8a9..7768ec2b 100644
--- a/src/Navigation/UI/Components/NavMenuToggleButton.php
+++ b/src/Navigation/UI/Components/NavMenuToggleButton.php
@@ -6,11 +6,12 @@
use ItalyStrap\Components\SubscribedEventsAware;
use ItalyStrap\Config\ConfigInterface;
-use ItalyStrap\Event\EventDispatcherInterface;
+use ItalyStrap\Event\GlobalDispatcherInterface as EventDispatcherInterface;
+use ItalyStrap\Event\SubscriberInterface;
use ItalyStrap\UI\Components\ComponentInterface;
use ItalyStrap\View\ViewInterface;
-class NavMenuToggleButton implements ComponentInterface, \ItalyStrap\Event\SubscriberInterface
+class NavMenuToggleButton implements ComponentInterface, SubscriberInterface
{
use SubscribedEventsAware;
diff --git a/src/Navigation/UI/Components/Navbar.php b/src/Navigation/UI/Components/Navbar.php
index 1b99f669..d479c89c 100644
--- a/src/Navigation/UI/Components/Navbar.php
+++ b/src/Navigation/UI/Components/Navbar.php
@@ -55,6 +55,8 @@ class Navbar
*/
private $fallback_cb;
+ private NavMenu $menu;
+
/**
* Init the constructor
*
@@ -244,9 +246,14 @@ public function get_navbar_brand( array $attr = [] ) {// phpcs:ignore
return apply_filters('italystrap_navbar_brand_none', '', $this->navbar_id);
}
+ /**
+ * @TODO Find out why HOME_URL in local is empty
+ */
+ $homeUrl = $this->config->get('HOME_URL');
+
$default = [
'class' => 'navbar-brand',
- 'href' => esc_url($this->config->get('HOME_URL')),
+ 'href' => $homeUrl ? esc_url($homeUrl) : '',
'title' => sprintf(
'%s - %s',
\get_option('blogname'),
diff --git a/src/Navigation/UI/Components/Pagination.php b/src/Navigation/UI/Components/Pagination.php
index 4d4f332c..c947e885 100644
--- a/src/Navigation/UI/Components/Pagination.php
+++ b/src/Navigation/UI/Components/Pagination.php
@@ -8,13 +8,14 @@
use ItalyStrap\Config\ConfigInterface;
use ItalyStrap\Event\SubscriberInterface;
use ItalyStrap\UI\Components\ComponentInterface;
+use ItalyStrap\UI\Components\Posts\Events\PostsContentAfter;
use ItalyStrap\View\ViewInterface;
class Pagination implements SubscriberInterface, ComponentInterface
{
use SubscribedEventsAware;
- public const EVENT_NAME = 'italystrap_after_loop';
+ public const EVENT_NAME = PostsContentAfter::class;
public const EVENT_PRIORITY = 10;
public const TEMPLATE_NAME = 'navigation/pagination';
diff --git a/src/Theme/Application/ConfigWpSubscriber.php b/src/Theme/Application/ConfigWpSubscriber.php
index 7acee5b0..f7ecae81 100644
--- a/src/Theme/Application/ConfigWpSubscriber.php
+++ b/src/Theme/Application/ConfigWpSubscriber.php
@@ -34,12 +34,12 @@ public function __invoke(): void
$id = $this->query->get_queried_object_id();
if (is_singular()) {
- $this->config->add(
+ $this->config->set(
ConfigLayoutProvider::POST_CONTENT_TEMPLATE,
(array) get_post_meta($id, '_italystrap_template_settings', true)
);
} else {
- $this->config->add(
+ $this->config->set(
ConfigLayoutProvider::POST_CONTENT_TEMPLATE,
explode(
',',
@@ -54,14 +54,14 @@ public function __invoke(): void
* If in page settings are set then override the global settings for the layout.
*/
if ($page_layout = (string) get_post_meta($id, '_italystrap_layout_settings', true)) {
- $this->config->add(ConfigLayoutProvider::SITE_LAYOUT, $page_layout);
+ $this->config->set(ConfigLayoutProvider::SITE_LAYOUT, $page_layout);
}
/**
* If in page settings are set then override the global settings for the layout.
*/
if ($container_width = (string) get_post_meta($id, '_italystrap_width_settings', true)) {
- $this->config->add(ConfigLayoutProvider::CONTAINER_WIDTH, $container_width);
+ $this->config->set(ConfigLayoutProvider::CONTAINER_WIDTH, $container_width);
}
$array = [
diff --git a/src/Theme/Application/SidebarsSubscriber.php b/src/Theme/Application/SidebarsSubscriber.php
index 656d0ada..082e7afb 100644
--- a/src/Theme/Application/SidebarsSubscriber.php
+++ b/src/Theme/Application/SidebarsSubscriber.php
@@ -6,15 +6,11 @@
use ItalyStrap\Config\ConfigInterface as Config;
use ItalyStrap\Event\SubscriberInterface;
-use ItalyStrap\HTML\Tag;
use function array_filter;
use function array_merge;
use function register_sidebar;
-/**
- * There are a standard sidebar and 4 footer dynamic sidebars
- */
final class SidebarsSubscriber implements SubscriberInterface
{
public const NAME = 'name';
@@ -26,13 +22,6 @@ final class SidebarsSubscriber implements SubscriberInterface
public const BEFORE_TITLE = 'before_title';
public const AFTER_TITLE = 'after_title';
- private Tag $tag;
-
- /**
- * @var arrayText
-