Skip to content

Commit

Permalink
composer.json // make use of worpdress-stubs for pslam.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrico committed Dec 16, 2022
1 parent eb504ef commit b17fb12
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 49 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/php-qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ jobs:
uses: inpsyde/reusable-workflows/.github/workflows/coding-standards-php.yml@main
with:
PHPCS_ARGS: '--report=summary'
PHP_VERSION: '8.0'
static-code-analysis-php:
needs: lint-php
uses: inpsyde/reusable-workflows/.github/workflows/static-analysis-php.yml@main
with:
PHP_VERSION: '8.0'
tests-unit-php:
needs: [ coding-standards-analysis-php, static-code-analysis-php ]
runs-on: ubuntu-latest
Expand Down
25 changes: 0 additions & 25 deletions .psalm/autoloader.php

This file was deleted.

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"mikey179/vfsstream": "^1.6.8",
"inpsyde/php-coding-standards": "^1",
"vimeo/psalm": "@stable",
"roots/wordpress": "@stable"
"php-stubs/wordpress-stubs": ">=6.0@stable",
"johnpbloch/wordpress-core": ">=6.0"
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 5 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0"?>
<psalm
autoloader="./.psalm/autoloader.php"
useDocblockPropertyTypes="true"
usePhpDocMethodsWithoutMagicCall="true"
strictBinaryOperands="true"
Expand All @@ -18,9 +17,14 @@
</ignoreFiles>
</projectFiles>

<stubs>
<file name="vendor/php-stubs/wordpress-stubs/wordpress-stubs.php" />
</stubs>

<issueHandlers>
<MixedAssignment errorLevel="suppress" />
<RedundantCastGivenDocblockType errorLevel="suppress" />
<DeprecatedClass errorLevel="suppress" />
<UndefinedConstant errorLevel="suppress" />
</issueHandlers>
</psalm>
2 changes: 1 addition & 1 deletion src/Handler/ScriptHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function register(Asset $asset): bool
}

$translation = $asset->translation();
if ($translation['domain'] !== '') {
if ($translation['domain'] !== '' && $translation['path']) {
wp_set_script_translations($handle, $translation['domain'], $translation['path']);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Script.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ protected function resolveDependencyExtractionPlugin(): bool

$this->withDependencies(...$dependencies);
if (!$this->version && $version) {
$this->withVersion((string) $version);
$this->withVersion($version);
}

return true;
Expand Down
39 changes: 19 additions & 20 deletions tests/phpunit/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Assets package.
*
* (c) Inpsyde GmbH
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

$libraryPath = dirname(__DIR__, 2);
$vendorPath = "{$libraryPath}/vendor";
if (!realpath($vendorPath)) {
$testsDir = str_replace('\\', '/', __DIR__);
$libDir = dirname($testsDir);
$vendorDir = "{$libDir}/vendor";
$autoload = "{$vendorDir}/autoload.php";

if (!is_file($autoload)) {
die('Please install via Composer before running tests.');
}

putenv('LIBRARY_PATH=' . $libraryPath);
putenv('TESTS_DIR=' . $testsDir);
putenv('LIB_DIR=' . $libDir);
putenv('VENDOR_DIR=' . $vendorDir);

error_reporting(E_ALL); // phpcs:ignore

require_once "{$libDir}/vendor/antecedent/patchwork/Patchwork.php";

if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
define('PHPUNIT_COMPOSER_INSTALL', "{$vendorPath}/autoload.php");
define('PHPUNIT_COMPOSER_INSTALL', $autoload);
require_once $autoload;
}

defined('ABSPATH') or define('ABSPATH', "{$vendorPath}/wordpress/wordpress/");

require_once "{$vendorPath}/antecedent/patchwork/Patchwork.php";
require_once "{$vendorPath}/autoload.php";

unset($libraryPath, $vendorPath);
defined('ABSPATH') or define('ABSPATH', "{$vendorDir}/johnpbloch/wordpress-core/");
require_once "{$vendorDir}/johnpbloch/wordpress-core/wp-includes/class-wp-error.php";

unset($testsDir, $libDir, $vendorDir, $autoload);

0 comments on commit b17fb12

Please sign in to comment.