Skip to content

Commit

Permalink
Preparing for PHP 8.2 (diablomedia#231
Browse files Browse the repository at this point in the history
* Preparing for PHP 8.2

* final deps
  • Loading branch information
jaydiablo authored Apr 19, 2023
1 parent dac2e64 commit d9c3592
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 69 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.4', '8.0', '8.1']
php-versions: ['7.4', '8.0', '8.1', '8.2']
composer-args: ['', '--prefer-lowest']
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@2.19.1
uses: shivammathur/setup-php@2.24.0
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring
Expand All @@ -30,7 +30,7 @@ jobs:
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
with:
Expand All @@ -52,5 +52,4 @@ jobs:
uses: codecov/codecov-action@v3
with:
files: ./clover.xml
fail_ci_if_error: true
verbose: true
22 changes: 22 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Dependabot auto-merge
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
32 changes: 0 additions & 32 deletions .github/workflows/merge-me.yml

This file was deleted.

11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"homepage": "http://framework.zend.com/",
"license": "BSD-3-Clause",
"require": {
"php": "^7.4 || ~8.0.0 || ~8.1.0",
"php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0",
"diablomedia/zendframework1-exception": "^1.0.0",
"diablomedia/zendframework1-config": "^1.0.0 || ^2.0.0",
"diablomedia/zendframework1-loader": "^1.0.0",
Expand All @@ -33,8 +33,8 @@
},
"require-dev": {
"phpunit/phpunit": "^9.5.10",
"phpstan/phpstan": "1.4.3",
"friendsofphp/php-cs-fixer": "3.6.0",
"phpstan/phpstan": "1.10.13",
"friendsofphp/php-cs-fixer": "3.16.0",
"maglnet/composer-require-checker": "^3.0.0",
"phpro/grumphp-shim": "^1.5.0"
},
Expand All @@ -54,5 +54,10 @@
},
"suggest": {
"ext-xml": "Many of the translation adapters require this extension"
},
"config": {
"allow-plugins": {
"phpro/grumphp-shim": true
}
}
}
10 changes: 0 additions & 10 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,12 @@ parameters:
- '#PHPDoc tag @param references unknown parameter: \$content#'
- '#PHPDoc tag @param references unknown parameter: \$locale#'
- '#PHPDoc tag @param references unknown parameter: \$args#'
-
message: '#Offset .+ does not exist on array{.+}\.#'
path: ./src/Zend/Translate/Adapter.php
-
message: '#Offset string on array{} in isset\(\) does not exist\.#'
path: ./src/Zend/Translate/Adapter/Array.php
-
message: '#Offset string on array{} in isset\(\) does not exist\.#'
path: ./src/Zend/Translate/Adapter/Ini.php
-
message: '#Offset .+ on array{.+} in empty\(\) does not exist\.#'
path: ./src/Zend/Translate/Adapter.php
# Defensive coding, argument can be multiple types
-
message: '#Result of \|\| is always true\.#'
Expand Down Expand Up @@ -66,7 +60,3 @@ parameters:
-
message: '#Method Zend_Translate_Adapter_XmlTm::_contentElement\(\) is unused\.#'
path: ./src/Zend/Translate/Adapter/XmlTm.php
# This isn't true, there is an empty check on this property in the class
-
message: '#Property Zend_Translate_Adapter_Tmx::\$_useId is never read, only written\.#'
path: ./src/Zend/Translate/Adapter/Tmx.php
14 changes: 7 additions & 7 deletions tests/Zend/Translate/Adapter/ArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function testCreate()
set_error_handler(array($this, 'errorHandlerIgnore'));
$adapter = new Zend_Translate_Adapter_Array(array());
restore_error_handler();
$this->assertTrue($adapter instanceof Zend_Translate_Adapter_Array);
$this->assertInstanceOf(Zend_Translate_Adapter_Array::class, $adapter);

try {
$adapter = new Zend_Translate_Adapter_Array('hastofail', 'en');
Expand Down Expand Up @@ -216,7 +216,7 @@ public function testOptionLocaleFilename()
public function testLoadArrayFile()
{
$adapter = new Zend_Translate_Adapter_Array(dirname(__FILE__) . '/_files/translation_en.php');
$this->assertTrue($adapter instanceof Zend_Translate_Adapter_Array);
$this->assertInstanceOf(Zend_Translate_Adapter_Array::class, $adapter);
}

public function testDisablingNotices()
Expand All @@ -226,13 +226,13 @@ public function testDisablingNotices()
$this->assertTrue($this->_errorOccurred);
restore_error_handler();
$this->_errorOccurred = false;
$this->assertTrue($adapter instanceof Zend_Translate_Adapter_Array);
$this->assertInstanceOf(Zend_Translate_Adapter_Array::class, $adapter);

set_error_handler(array($this, 'errorHandlerIgnore'));
$adapter = new Zend_Translate_Adapter_Array(array(), 'en', array('disableNotices' => true));
$this->assertFalse($this->_errorOccurred);
restore_error_handler();
$this->assertTrue($adapter instanceof Zend_Translate_Adapter_Array);
$this->assertInstanceOf(Zend_Translate_Adapter_Array::class, $adapter);
}

public function testGettingAllMessageIds()
Expand Down Expand Up @@ -274,12 +274,12 @@ public function testCaching()

$adapter = new Zend_Translate_Adapter_Array(dirname(__FILE__) . '/_files/translation_en.php', 'en');
$cache = Zend_Translate_Adapter_Array::getCache();
$this->assertTrue($cache instanceof Zend_Cache_Core);
$this->assertInstanceOf(Zend_Cache_Core::class, $cache);
unset($adapter);

$adapter = new Zend_Translate_Adapter_Array(dirname(__FILE__) . '/_files/translation_en.php', 'en');
$cache = Zend_Translate_Adapter_Array::getCache();
$this->assertTrue($cache instanceof Zend_Cache_Core);
$this->assertInstanceOf(Zend_Cache_Core::class, $cache);

Zend_Translate_Adapter_Array::removeCache();
$this->assertFalse(Zend_Translate_Adapter_Array::hasCache());
Expand Down Expand Up @@ -307,7 +307,7 @@ public function testLoadingFilesIntoCacheAfterwards()

$adapter = new Zend_Translate_Adapter_Array(dirname(__FILE__) . '/_files/translation_en.php', 'en');
$cache = Zend_Translate_Adapter_Array::getCache();
$this->assertTrue($cache instanceof Zend_Cache_Core);
$this->assertInstanceOf(Zend_Cache_Core::class, $cache);

$adapter->addTranslation(dirname(__FILE__) . '/_files/translation_en.php', 'ru', array('reload' => true));
$test = $adapter->getMessages('all');
Expand Down
4 changes: 3 additions & 1 deletion tests/Zend/Translate/Adapter/CsvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
*/
class Zend_Translate_Adapter_CsvTest extends PHPUnit\Framework\TestCase
{
protected $_errorOccurred;

public function setUp(): void
{
if (Zend_Translate_Adapter_Csv::hasCache()) {
Expand All @@ -41,7 +43,7 @@ public function setUp(): void
public function testCreate()
{
$adapter = new Zend_Translate_Adapter_Csv(dirname(__FILE__) . '/_files/translation_en.csv');
$this->assertTrue($adapter instanceof Zend_Translate_Adapter_Csv);
$this->assertInstanceOf(Zend_Translate_Adapter_Csv::class, $adapter);

try {
$adapter = new Zend_Translate_Adapter_Csv(dirname(__FILE__) . '/_files/nofile.csv', 'en');
Expand Down
4 changes: 3 additions & 1 deletion tests/Zend/Translate/Adapter/GettextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
*/
class Zend_Translate_Adapter_GettextTest extends PHPUnit\Framework\TestCase
{
protected $_errorOccurred;

/**
* Runs the test methods of this class.
*
Expand All @@ -53,7 +55,7 @@ public function setUp(): void
public function testCreate()
{
$adapter = new Zend_Translate_Adapter_Gettext(dirname(__FILE__) . '/_files/translation_en.mo');
$this->assertTrue($adapter instanceof Zend_Translate_Adapter_Gettext);
$this->assertInstanceOf(Zend_Translate_Adapter_Gettext::class, $adapter);

try {
$adapter = new Zend_Translate_Adapter_Gettext(dirname(__FILE__) . '/_files/nofile.mo', 'en');
Expand Down
4 changes: 3 additions & 1 deletion tests/Zend/Translate/Adapter/IniTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
*/
class Zend_Translate_Adapter_IniTest extends PHPUnit\Framework\TestCase
{
protected $_errorOccurred;

public function testCreate()
{
$adapter = new Zend_Translate_Adapter_Ini(dirname(__FILE__) . '/_files/translation_en.ini');
$this->assertTrue($adapter instanceof Zend_Translate_Adapter_Ini);
$this->assertInstanceOf(Zend_Translate_Adapter_Ini::class, $adapter);

try {
$adapter = new Zend_Translate_Adapter_Ini(dirname(__FILE__) . '/_files/nofile.ini', 'en');
Expand Down
4 changes: 3 additions & 1 deletion tests/Zend/Translate/Adapter/QtTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
*/
class Zend_Translate_Adapter_QtTest extends PHPUnit\Framework\TestCase
{
protected $_errorOccurred;

public function testCreate()
{
$adapter = new Zend_Translate_Adapter_Qt(dirname(__FILE__) . '/_files/translation_en.ts');
$this->assertTrue($adapter instanceof Zend_Translate_Adapter_Qt);
$this->assertInstanceOf(Zend_Translate_Adapter_Qt::class, $adapter);

try {
$adapter = new Zend_Translate_Adapter_Qt(dirname(__FILE__) . '/_files/nofile.ts', 'en');
Expand Down
4 changes: 3 additions & 1 deletion tests/Zend/Translate/Adapter/TbxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
*/
class Zend_Translate_Adapter_TbxTest extends PHPUnit\Framework\TestCase
{
protected $_errorOccurred;

public function testCreate()
{
$adapter = new Zend_Translate_Adapter_Tbx(dirname(__FILE__) . '/_files/translation_en.tbx', 'en');
$this->assertTrue($adapter instanceof Zend_Translate_Adapter_Tbx);
$this->assertInstanceOf(Zend_Translate_Adapter_Tbx::class, $adapter);

try {
$adapter = new Zend_Translate_Adapter_Tbx(dirname(__FILE__) . '/_files/nofile.tbx', 'en');
Expand Down
4 changes: 3 additions & 1 deletion tests/Zend/Translate/Adapter/TmxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
*/
class Zend_Translate_Adapter_TmxTest extends PHPUnit\Framework\TestCase
{
protected $_errorOccurred;

public function testCreate()
{
$adapter = new Zend_Translate_Adapter_Tmx(dirname(__FILE__) . '/_files/translation_en.tmx', 'en');
$this->assertTrue($adapter instanceof Zend_Translate_Adapter_Tmx);
$this->assertInstanceOf(Zend_Translate_Adapter_Tmx::class, $adapter);

try {
$adapter = new Zend_Translate_Adapter_Tmx(dirname(__FILE__) . '/_files/nofile.tmx', 'en');
Expand Down
4 changes: 3 additions & 1 deletion tests/Zend/Translate/Adapter/XliffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
*/
class Zend_Translate_Adapter_XliffTest extends PHPUnit\Framework\TestCase
{
protected $_errorOccurred;

public function testCreate()
{
$adapter = new Zend_Translate_Adapter_Xliff(dirname(__FILE__) . '/_files/translation_en.xliff', 'en');
$this->assertTrue($adapter instanceof Zend_Translate_Adapter_Xliff);
$this->assertInstanceOf(Zend_Translate_Adapter_Xliff::class, $adapter);

try {
$adapter = new Zend_Translate_Adapter_Xliff(dirname(__FILE__) . '/_files/nofile.xliff', 'en');
Expand Down
4 changes: 3 additions & 1 deletion tests/Zend/Translate/Adapter/XmlTmTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
*/
class Zend_Translate_Adapter_XmlTmTest extends PHPUnit\Framework\TestCase
{
protected $_errorOccurred;

public function testCreate()
{
$adapter = new Zend_Translate_Adapter_XmlTm(dirname(__FILE__) . '/_files/translation_en.xmltm');
$this->assertTrue($adapter instanceof Zend_Translate_Adapter_XmlTm);
$this->assertInstanceOf(Zend_Translate_Adapter_XmlTm::class, $adapter);

try {
$adapter = new Zend_Translate_Adapter_XmlTm(dirname(__FILE__) . '/_files/nofile.xmltm', 'en');
Expand Down
12 changes: 7 additions & 5 deletions tests/Zend/TranslateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
*/
class Zend_TranslateTest extends PHPUnit\Framework\TestCase
{
protected $_errorOccured;

public function setUp(): void
{
if (Zend_Translate::hasCache()) {
Expand All @@ -45,7 +47,7 @@ public function setUp(): void
public function testCreate()
{
$lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array('1' => '1'));
$this->assertTrue($lang instanceof Zend_Translate);
$this->assertInstanceOf(Zend_Translate::class, $lang);
}

public function testLocaleInitialization()
Expand Down Expand Up @@ -224,14 +226,14 @@ public function testTestingCacheHandling()
Zend_Translate::setCache($cache);

$cache = Zend_Translate::getCache();
$this->assertTrue($cache instanceof Zend_Cache_Core);
$this->assertInstanceOf(Zend_Cache_Core::class, $cache);
$this->assertTrue(Zend_Translate::hasCache());

$lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array('msg1' => 'Message 1 (en)'), 'en');
$adapter = $lang->getAdapter();
$this->assertTrue($adapter instanceof Zend_Translate_Adapter_Array);
$this->assertInstanceOf(Zend_Translate_Adapter_Array::class, $adapter);
$adaptercache = $adapter->getCache();
$this->assertTrue($adaptercache instanceof Zend_Cache_Core);
$this->assertInstanceOf(Zend_Cache_Core::class, $adaptercache);

Zend_Translate::clearCache();
$this->assertTrue(Zend_Translate::hasCache());
Expand Down Expand Up @@ -846,7 +848,7 @@ public function testSetCacheThroughOptions()
));

$return = Zend_Translate::getCache();
$this->assertTrue($return instanceof Zend_Cache_Core);
$this->assertInstanceOf(Zend_Cache_Core::class, $return);
$this->assertTrue(Zend_Translate::hasCache());
}

Expand Down

0 comments on commit d9c3592

Please sign in to comment.