Skip to content

Commit

Permalink
Merge pull request #455 from neilime/feat/remove-suppoort-for-php-7.4
Browse files Browse the repository at this point in the history
feat: remove support for php 7.4
  • Loading branch information
neilime authored Dec 6, 2022
2 parents 2dffd2a + dff18a0 commit b24d41b
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ version: 2
updates:
- package-ecosystem: composer
open-pull-requests-limit: 20
versioning-strategy: increase
versioning-strategy: widen
directory: "/"
schedule:
interval: weekly
day: friday
- package-ecosystem: npm
open-pull-requests-limit: 20
versioning-strategy: increase
versioning-strategy: widen
directory: "/website"
schedule:
interval: weekly
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
strategy:
matrix:
include:
- php-versions: "7.4"
- php-versions: "8.0"
- php-versions: "8.1"
stable: true
Expand All @@ -27,7 +26,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: none, json, dom, tokenizer, xml, xmlwriter, simplexml, iconv, mbstring, intl, sodium
extensions: none, curl, json, dom, tokenizer, xml, xmlwriter, simplexml, iconv, mbstring, intl, sodium
coverage: pcov

- name: ♻️ Get composer cache directory
Expand All @@ -42,7 +41,7 @@ jobs:
restore-keys: ${{ runner.os }}-composer-

- name: ⚙️ Install dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: 👕 Lint
run: composer cs
Expand All @@ -61,7 +60,7 @@ jobs:
- name: 🧪 Test
run: composer test:ci

- name: 📊 Upload coverage results to Coveralls
- name: 📊 Upload coverage results to Codecov
if: matrix.stable
uses: codecov/codecov-action@v3
with:
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ build-php: ## Build PHP image for given version
@DOCKER_BUILDKIT=1 docker build -t "twbs-helper-php:$(filter-out $@,$(MAKECMDGOALS))" --build-arg "VERSION=$(filter-out $@,$(MAKECMDGOALS))" .

install:
rm -f composer.lock
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) composer install --no-progress --prefer-dist --optimize-autoloader)
rm -f composer.lock

shell:
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) bash)
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"twitter/bootstrap": "Twitter bootstrap assets"
},
"require": {
"php": "^7.4 || ~8.0.0 || ~8.1.0",
"php": "~8.0.0 || ~8.1.0",
"laminas/laminas-escaper": "^2.12",
"laminas/laminas-form": "^3.4",
"laminas/laminas-i18n": "^2.17",
Expand All @@ -43,11 +43,11 @@
"laminas/laminas-mvc": "^3.3",
"mikey179/vfsstream": "^1.6",
"pcov/clobber": "^2.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/extension-installer": "^1.2",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan-phpunit": "^1.2",
"phpunit/phpunit": "^9.5.26",
"slam/phpstan-laminas-framework": "^0.12",
"slam/phpstan-laminas-framework": "^1.3",
"spatie/phpunit-snapshot-assertions": "^4.2",
"squizlabs/php_codesniffer": "^3.7"
},
Expand Down
4 changes: 2 additions & 2 deletions src/Documentation/Test/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class Config
public static $TITLE_SEPARATOR = ' / ';

/**
* @var string
* @var string|null
*/
public $title;
public $title = null;

/**
* @var string
Expand Down
2 changes: 1 addition & 1 deletion src/Documentation/Test/SnapshotService.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public function getSnapshotPathFromTitle(string $title, $incrementor = 1): strin
$snapshotFile = $safePath . '__' . $incrementor . '.html';

return $this->testsDirectoryPath . DIRECTORY_SEPARATOR .
static::$SNAPSHOT_ROOT_DIRECTORY . DIRECTORY_SEPARATOR . $snapshotFile;
self::$SNAPSHOT_ROOT_DIRECTORY . DIRECTORY_SEPARATOR . $snapshotFile;
}
}
6 changes: 3 additions & 3 deletions src/TwbsHelper/View/Helper/DescriptionList.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function render(array $items, iterable $optionsAndAttributes = [], bool $
}

$attributes = $this->getView()->plugin('htmlattributes')
->__invoke($optionsAndAttributes ?? [])
->__invoke($optionsAndAttributes ?: [])
->merge(['class' => ['row']]);

return $this->renderContainer(
Expand Down Expand Up @@ -175,7 +175,7 @@ protected function renderListItemTerm(
unset($termOptionsAndAttributes['column']);

$attributes = $this->getView()->plugin('htmlattributes')
->__invoke($termOptionsAndAttributes ?? [])
->__invoke($termOptionsAndAttributes ?: [])
->merge([
'class' => $this->getView()->plugin('htmlClass')->plugin('column')->getClassesFromOption(
$columSize
Expand Down Expand Up @@ -211,7 +211,7 @@ protected function renderListItemDetail(
unset($detailOptionsAndAttributes['column']);

$attributes = $this->getView()->plugin('htmlattributes')
->__invoke($detailOptionsAndAttributes ?? [])
->__invoke($detailOptionsAndAttributes ?: [])
->merge([
'class' => $this->getView()->plugin('htmlClass')->plugin('column')->getClassesFromOption(
$columSize
Expand Down
12 changes: 6 additions & 6 deletions src/TwbsHelper/View/Helper/Dropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected function createDropdown($dropdown)
throw new \InvalidArgumentException(sprintf(
'Argument "$dropdown" expects %s, "%s" given',
'an instanceof \Laminas\Form\ElementInterface or an iterable',
is_object($dropdown) ? get_class($dropdown) : gettype($dropdown)
get_class($dropdown)
));
}
return $dropdown;
Expand Down Expand Up @@ -175,9 +175,9 @@ protected function renderToggle(\Laminas\Form\ElementInterface $dropdown): strin
$toogleElementAttributes = $toogleElement->getAttributes();
foreach (
[
'data-bs-toggle' => 'dropdown',
'data-bs-offset' => $dropdownOptions['offset'] ?? null,
'aria-expanded' => 'false',
'data-bs-toggle' => 'dropdown',
'data-bs-offset' => $dropdownOptions['offset'] ?? null,
'aria-expanded' => 'false',
] as $attributeName => $defaultValue
) {
if ($defaultValue !== null && !isset($toogleElementAttributes[$attributeName])) {
Expand Down Expand Up @@ -478,8 +478,8 @@ protected function renderItem(array $itemOptions, bool $escape): string

foreach (
[
'active' => ['aria-current' => 'true'],
'disabled' => ['tabindex' => '-1', 'aria-disabled' => 'true'],
'active' => ['aria-current' => 'true'],
'disabled' => ['tabindex' => '-1', 'aria-disabled' => 'true'],
] as $option => $optionAttributes
) {
if (empty($itemOptions[$option])) {
Expand Down
2 changes: 1 addition & 1 deletion src/TwbsHelper/View/Helper/GridColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ protected function prepareAttributes(iterable $optionsAndAttributes): iterable
);
}

$colOption = $optionsAndAttributes['column'] ?? $options['column'] ?? true;
$colOption = $optionsAndAttributes['column'] ?? true;
$attributes['class']->merge(
$this->getView()->plugin('htmlClass')->plugin('column')->getClassesFromOption($colOption)
);
Expand Down
3 changes: 2 additions & 1 deletion src/TwbsHelper/View/Helper/HtmlAttributes/HtmlClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ public function setHelperPluginManager($helperPluginManager)
}
$helperPluginManager = new $helperPluginManager(new \Laminas\ServiceManager\ServiceManager());
}

if (!$helperPluginManager instanceof \TwbsHelper\View\Helper\HtmlAttributes\HtmlClass\HelperPluginManager) {
throw new \InvalidArgumentException(sprintf(
'Helper helpers must extend %s; got type "%s" instead',
\TwbsHelper\View\Helper\HtmlAttributes\HtmlClass\HelperPluginManager::class,
(is_object($helperPluginManager) ? get_class($helperPluginManager) : gettype($helperPluginManager))
get_class($helperPluginManager)
));
}
$this->helperPluginManager = $helperPluginManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace TwbsHelper\View\Helper\HtmlAttributes\HtmlClass;

use Laminas\ServiceManager\ConfigInterface;

/**
* Plugin manager implementation for HTML class attribute helpers
*
Expand Down Expand Up @@ -31,8 +33,10 @@ class HelperPluginManager extends \Laminas\ServiceManager\AbstractPluginManager

/**
* Default factories
*
* @var array
*/
/** @phpstan-ignore-next-line */
protected $factories = [
\TwbsHelper\View\Helper\HtmlAttributes\HtmlClass\Helper\Align::class
=> \Laminas\ServiceManager\Factory\InvokableFactory::class,
Expand Down Expand Up @@ -63,6 +67,8 @@ class HelperPluginManager extends \Laminas\ServiceManager\AbstractPluginManager
* Sets the provided $parentLocator as the creation context for all
* factories; for $config, {@see \Laminas\ServiceManager\ServiceManager::configure()}
* for details on its accepted structure.
* @param null|ConfigInterface|\Psr\Container\ContainerInterface $configInstanceOrParentLocator
* @param array $config
*/
public function __construct($configInstanceOrParentLocator = null, array $config = [])
{
Expand All @@ -76,7 +82,7 @@ public function __construct($configInstanceOrParentLocator = null, array $config
*/
public function injectHtmlClassHelper($first, $second)
{
$helper = ($first instanceof \Interop\Container\ContainerInterface)
$helper = ($first instanceof \Psr\Container\ContainerInterface)
? $second
: $first;

Expand Down
16 changes: 8 additions & 8 deletions src/TwbsHelper/View/Helper/Navigation/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function ($matches) {

$content = $this->renderMenuItemsLink($content, $options);

return $content ?? '';
return $content ?: '';
}

protected function renderMenuItemsNav(string $content, iterable $options): string
Expand Down Expand Up @@ -214,13 +214,13 @@ protected function getMenuItemsNavClasses(iterable $options, bool $isRoot): iter
$classes = [];
foreach (
[
'tabs' => 'nav-tabs',
'pills' => 'nav-pills',
'fill' => 'nav-fill',
'justified' => 'nav-justified',
'centered' => 'justify-content-center',
'right_aligned' => 'justify-content-end',
'vertical' => 'flex-column',
'tabs' => 'nav-tabs',
'pills' => 'nav-pills',
'fill' => 'nav-fill',
'justified' => 'nav-justified',
'centered' => 'justify-content-center',
'right_aligned' => 'justify-content-end',
'vertical' => 'flex-column',
] as $option => $className
) {
if (!empty($options[$option])) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace TestSuite\TwbsHelper\View\Helper\HtmlAttributes;

class HtmlClassTest extends \TestSuite\TwbsHelper\AbstractViewHelperTestCase
{
/**
* @var \TwbsHelper\View\Helper\HtmlAttributes\HtmlClass
*/
protected $helper = 'htmlClass';

public function testSetHelperPluginManagerWithWrongClass()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(
'Helper helpers must extend TwbsHelper\View\Helper\HtmlAttributes\HtmlClass\HelperPluginManager; ' .
'got type "stdClass" instead'
);
$this->helper->setHelperPluginManager(\stdClass::class);
}
}
19 changes: 19 additions & 0 deletions tests/TestSuite/TwbsHelper/View/Helper/Navigation/MenuTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace TestSuite\TwbsHelper\View\Helper\Navigation;

class MenuTest extends \TestSuite\TwbsHelper\AbstractViewHelperTestCase
{
/**
* @var \TwbsHelper\View\Helper\Navigation\Menu
*/
protected $helper = 'menu';

public function testRenderMenuWithoutContainerReturnsEmptyContent()
{
$this->assertEquals(
'',
$this->helper->renderMenu()
);
}
}

0 comments on commit b24d41b

Please sign in to comment.