use local version of listmonk-php

This commit is contained in:
2025-08-06 10:23:34 +02:00
parent e67912a107
commit cf1610dfa1
23 changed files with 155 additions and 1450 deletions

View File

@@ -26,12 +26,23 @@ use Composer\Semver\VersionParser;
*/
class InstalledVersions
{
/**
* @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to
* @internal
*/
private static $selfDir = null;
/**
* @var mixed[]|null
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
*/
private static $installed;
/**
* @var bool
*/
private static $installedIsLocalDir;
/**
* @var bool|null
*/
@@ -309,6 +320,24 @@ class InstalledVersions
{
self::$installed = $data;
self::$installedByVendor = array();
// when using reload, we disable the duplicate protection to ensure that self::$installed data is
// always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
// so we have to assume it does not, and that may result in duplicate data being returned when listing
// all installed packages for example
self::$installedIsLocalDir = false;
}
/**
* @return string
*/
private static function getSelfDir()
{
if (self::$selfDir === null) {
self::$selfDir = strtr(__DIR__, '\\', '/');
}
return self::$selfDir;
}
/**
@@ -322,19 +351,27 @@ class InstalledVersions
}
$installed = array();
$copiedLocalDir = false;
if (self::$canGetVendors) {
$selfDir = self::getSelfDir();
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
$vendorDir = strtr($vendorDir, '\\', '/');
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require $vendorDir.'/composer/installed.php';
$installed[] = self::$installedByVendor[$vendorDir] = $required;
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $installed[count($installed) - 1];
self::$installedByVendor[$vendorDir] = $required;
$installed[] = $required;
if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
self::$installed = $required;
self::$installedIsLocalDir = true;
}
}
if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
$copiedLocalDir = true;
}
}
}
@@ -350,7 +387,7 @@ class InstalledVersions
}
}
if (self::$installed !== array()) {
if (self::$installed !== array() && !$copiedLocalDir) {
$installed[] = self::$installed;
}

View File

@@ -2,23 +2,16 @@
"packages": [
{
"name": "adnanhussainturki/listmonk-php",
"version": "0.1",
"version_normalized": "0.1.0.0",
"source": {
"type": "git",
"url": "https://github.com/AdnanHussainTurki/listmonk-php.git",
"reference": "0d43700377dfe5eac43f4f6751e83b42e85b5400"
},
"version": "dev-main",
"version_normalized": "dev-main",
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/AdnanHussainTurki/listmonk-php/zipball/0d43700377dfe5eac43f4f6751e83b42e85b5400",
"reference": "0d43700377dfe5eac43f4f6751e83b42e85b5400",
"shasum": ""
"type": "path",
"url": "/home/magdev/workspaces/php/listmonk-php",
"reference": "13ece3885c574ccab39cdbe711ff0cfda408b561"
},
"require": {
"guzzlehttp/guzzle": "^7.8"
},
"time": "2023-11-12T00:45:46+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@@ -26,7 +19,6 @@
"AdnanHussainTurki\\ListMonk\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@@ -37,9 +29,9 @@
}
],
"description": "Package aims to ease up the API calls to a listmonk API from PHP based application",
"support": {
"issues": "https://github.com/AdnanHussainTurki/listmonk-php/issues",
"source": "https://github.com/AdnanHussainTurki/listmonk-php/tree/0.1"
"transport-options": {
"symlink": true,
"relative": false
},
"install-path": "../adnanhussainturki/listmonk-php"
},

View File

@@ -11,9 +11,9 @@
),
'versions' => array(
'adnanhussainturki/listmonk-php' => array(
'pretty_version' => '0.1',
'version' => '0.1.0.0',
'reference' => '0d43700377dfe5eac43f4f6751e83b42e85b5400',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '13ece3885c574ccab39cdbe711ff0cfda408b561',
'type' => 'library',
'install_path' => __DIR__ . '/../adnanhussainturki/listmonk-php',
'aliases' => array(),

View File

@@ -19,8 +19,7 @@ if ($issues) {
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
}
}
trigger_error(
'Composer detected issues in your platform: ' . implode(' ', $issues),
E_USER_ERROR
throw new \RuntimeException(
'Composer detected issues in your platform: ' . implode(' ', $issues)
);
}