Skip to content

Commit 7dd0ef9

Browse files
Merge pull request #566 from weDevsOfficial/patch-illuminate
PHP v8+ support -(ongoing)
2 parents 6adcdfc + 5239d9a commit 7dd0ef9

File tree

12 files changed

+204
-10
lines changed

12 files changed

+204
-10
lines changed

.distignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ views/assets/css/Single Task Page.json
4747
views/assets/vendor/wp-hooks/wp-hooks.js
4848
/zipfile
4949
wp-project-manager.zip
50+
/composer-scripts
5051
/phpcs-xml
5152
api-schema.json
5253

changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
== Changelog ==
22

3+
= v3.0.1 – Dec 24, 2025 =
4+
**Added:** PHP version 8.2+ support.
5+
36
= v3.0.0 – Dec 18, 2025 =
47
**Improved:** Aligned plugin description with WordPress.org directory standards.
58
**Improved:** internal consistency across metadata, versioning, and documentation.
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
<?php
2+
3+
/**
4+
* This script patches PHP 8+ compatibility issues in Illuminate Container and Eloquent classes.
5+
*
6+
* It fixes:
7+
* 1. PSR-11 ContainerInterface compatibility (has() and get() methods)
8+
* 2. ArrayAccess interface compatibility (offsetExists, offsetGet, offsetSet, offsetUnset)
9+
* 3. Nullable parameter declarations
10+
* 4. Return type declarations for PHP 8+
11+
*/
12+
13+
function patchContainerPSR11($file) {
14+
if (!file_exists($file)) {
15+
echo "❌ File not found: $file\n";
16+
return;
17+
}
18+
19+
$content = file_get_contents($file);
20+
$originalContent = $content;
21+
22+
// Fix has() method - PSR-11 requires: has(string $id): bool
23+
$content = preg_replace(
24+
'/public function has\(\$id\)(\s*\{)/s',
25+
'public function has(string $id): bool$1',
26+
$content
27+
);
28+
29+
// Fix get() method - PSR-11 requires: get(string $id)
30+
$content = preg_replace(
31+
'/public function get\(\$id\)(\s*\{)/s',
32+
'public function get(string $id)$1',
33+
$content
34+
);
35+
36+
// Fix offsetExists - ArrayAccess requires: offsetExists($key): bool
37+
$content = preg_replace(
38+
'/public function offsetExists\(\$key\)(\s*\{)/s',
39+
'public function offsetExists($key): bool$1',
40+
$content
41+
);
42+
43+
// Fix offsetGet - ArrayAccess requires: offsetGet($key): mixed
44+
$content = preg_replace(
45+
'/public function offsetGet\(\$key\)(\s*\{)/s',
46+
'public function offsetGet($key): mixed$1',
47+
$content
48+
);
49+
50+
// Fix offsetSet - ArrayAccess requires: offsetSet($key, $value): void
51+
$content = preg_replace(
52+
'/public function offsetSet\(\$key, \$value\)(\s*\{)/s',
53+
'public function offsetSet($key, $value): void$1',
54+
$content
55+
);
56+
57+
// Fix offsetUnset - ArrayAccess requires: offsetUnset($key): void
58+
$content = preg_replace(
59+
'/public function offsetUnset\(\$key\)(\s*\{)/s',
60+
'public function offsetUnset($key): void$1',
61+
$content
62+
);
63+
64+
// Fix nullable parameters - PHP 8.1+ requires explicit nullable type
65+
$content = preg_replace(
66+
'/public function resolving\(\$abstract, Closure \$callback = null\)/s',
67+
'public function resolving($abstract, ?Closure $callback = null)',
68+
$content
69+
);
70+
71+
$content = preg_replace(
72+
'/public function afterResolving\(\$abstract, Closure \$callback = null\)/s',
73+
'public function afterResolving($abstract, ?Closure $callback = null)',
74+
$content
75+
);
76+
77+
$content = preg_replace(
78+
'/public static function setInstance\(ContainerContract \$container = null\)/s',
79+
'public static function setInstance(?ContainerContract $container = null)',
80+
$content
81+
);
82+
83+
if ($content !== $originalContent) {
84+
file_put_contents($file, $content);
85+
echo "✅ Patched Container: PSR-11 and ArrayAccess compatibility\n";
86+
} else {
87+
echo "⚠️ Container already patched or no changes needed\n";
88+
}
89+
}
90+
91+
function patchReturnType($file, $method) {
92+
if (!file_exists($file)) {
93+
echo "❌ File not found: $file\n";
94+
return;
95+
}
96+
97+
$content = file_get_contents($file);
98+
99+
// Check if method is already patched with the attribute
100+
$alreadyPatched = preg_match(
101+
'/#[ \t]*\\\\?ReturnTypeWillChange[ \t]*\n[ \t]*public function[ \t]+' . preg_quote($method) . '\s*\(/',
102+
$content
103+
);
104+
105+
// Alternatively, scan just before the method for attribute presence
106+
if (! $alreadyPatched) {
107+
// Match the method declaration with optional preceding attributes
108+
$methodPattern = '/((?:\s*#\[.*?\]\s*)*)\s*(public function[ \t]+' . preg_quote($method) . '\s*\([^)]*\))/';
109+
110+
$patched = preg_replace_callback($methodPattern, function($matches) use ($method) {
111+
$attributes = $matches[1];
112+
$signature = $matches[2];
113+
114+
// Avoid duplicating ReturnTypeWillChange
115+
if (stripos($attributes, 'ReturnTypeWillChange') !== false) {
116+
echo "⚠️ Already patched: $method\n";
117+
return $matches[0];
118+
}
119+
120+
echo "✅ Patched: $method\n";
121+
return "#[\\ReturnTypeWillChange]\n " . $signature;
122+
}, $content, 1, $count);
123+
124+
if ($count > 0) {
125+
file_put_contents($file, $patched);
126+
} else {
127+
echo "❌ Could not patch: $method\n";
128+
}
129+
} else {
130+
echo "⚠️ Already patched: $method\n";
131+
}
132+
}
133+
134+
135+
// Patch Container class for PSR-11 and ArrayAccess compatibility
136+
echo "=== Patching Illuminate Container ===\n";
137+
$targetContainerFile = __DIR__ . '/../vendor/illuminate/container/Container.php';
138+
patchContainerPSR11($targetContainerFile);
139+
140+
// Patch Model and Collection classes
141+
echo "\n=== Patching Eloquent Model and Collection ===\n";
142+
$targetModelFile = __DIR__ . '/../vendor/illuminate/database/Eloquent/Model.php';
143+
$targetCollectionFile = __DIR__ . '/../vendor/illuminate/support/Collection.php';
144+
145+
$methods = ['offsetExists', 'offsetGet', 'offsetSet', 'offsetUnset', 'jsonSerialize', 'count', 'getIterator'];
146+
147+
foreach ($methods as $method) {
148+
patchReturnType($targetModelFile, $method);
149+
patchReturnType($targetCollectionFile, $method);
150+
}
151+
152+
// Patch Illuminate Pagination classes
153+
echo "\n=== Patching Illuminate Pagination ===\n";
154+
$targetAbstractPaginatorFile = __DIR__ . '/../vendor/illuminate/pagination/AbstractPaginator.php';
155+
$targetPaginatorFile = __DIR__ . '/../vendor/illuminate/pagination/Paginator.php';
156+
$targetLengthAwarePaginatorFile = __DIR__ . '/../vendor/illuminate/pagination/LengthAwarePaginator.php';
157+
158+
foreach ($methods as $method) {
159+
patchReturnType($targetAbstractPaginatorFile, $method);
160+
patchReturnType($targetPaginatorFile, $method);
161+
patchReturnType($targetLengthAwarePaginatorFile, $method);
162+
}
163+
164+
// Patch League Fractal ParamBag
165+
echo "\n=== Patching League Fractal ParamBag ===\n";
166+
$targetParamBagFile = __DIR__ . '/../vendor/league/fractal/src/ParamBag.php';
167+
$fractalMethods = ['offsetExists', 'offsetGet', 'offsetSet', 'offsetUnset', 'getIterator'];
168+
169+
foreach ($fractalMethods as $method) {
170+
patchReturnType($targetParamBagFile, $method);
171+
}
172+
173+
echo "\n✅ All patches applied successfully!\n";

composer.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
"WeDevs\\PM\\": "src/"
3838
}
3939
},
40+
"scripts": {
41+
"post-install-cmd": [
42+
"php composer-scripts/patch-deprecations.php"
43+
],
44+
"post-update-cmd": [
45+
"php composer-scripts/patch-deprecations.php"
46+
]
47+
},
4048
"require-dev": {
4149
"fzaninotto/faker": "^1.8",
4250
"squizlabs/php_codesniffer": "^3.5.8",

cpm.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Description: WordPress Project Management plugin. Manage your projects and tasks, get things done.
66
* Author: weDevs
77
* Author URI: https://wedevs.com
8-
* Version: 3.0.0
8+
* Version: 3.0.1
99
* Text Domain: wedevs-project-manager
1010
* Domain Path: /languages
1111
* License: GPL2
@@ -16,7 +16,7 @@
1616
exit;
1717
}
1818
// Define version directly to avoid early translation loading from get_plugin_data()
19-
define('PM_VERSION', '3.0.0');
19+
define('PM_VERSION', '3.0.1');
2020

2121
require __DIR__.'/bootstrap/loaders.php';
2222
require __DIR__.'/libs/configurations.php';

libs/functions.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,12 +661,20 @@ function wedevs_pm_tb_prefix() {
661661
* @return string
662662
*/
663663
function wedevs_pm_get_content( $content ) {
664+
if (empty($content)) {
665+
return $content;
666+
}
667+
664668
$content = apply_filters( 'wedevs_pm_get_content', $content );
665669

666670
return $content;
667671
}
668672

669673
function wedevs_pm_filter_content_url( $content ) {
674+
if (empty($content)) {
675+
return $content;
676+
}
677+
670678
$content = apply_filters( 'wedevs_pm_get_content_url', $content );
671679

672680
return $content;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pmapi",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"description": "Front-end package manager for project manager",
55
"main": "index.js",
66
"directories": {

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Tags: project management, project manager, kanban board, task manager, gantt cha
66
Requires at least: 6.2
77
Tested up to: 6.9
88
Requires PHP: 7.4
9-
Stable tag: 3.0.0
9+
Stable tag: 3.0.1
1010
License: GPLv2 or later
1111
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1212

@@ -215,6 +215,9 @@ A. Found any bugs? Please create an [issue](https://github.com/tareq1988/wp-proj
215215

216216
== Changelog ==
217217

218+
= v3.0.1 – Dec 24, 2025 =
219+
**Added:** PHP version 8.2+ support.
220+
218221
= v3.0.0 – Dec 18, 2025 =
219222
**Improved:** Aligned plugin description with WordPress.org directory standards.
220223
**Improved:** internal consistency across metadata, versioning, and documentation.

src/Comment/Helper/Comment.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class Comment {
1919
private $found_rows;
2020
private $tb_comment;
2121
private $is_single_query = false;
22-
2322
public static function getInstance() {
2423
return new self();
2524
}

src/Project/Helper/Project.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Project {
1111
private $tb_list;
1212
private $tb_task;
1313
private $tb_projectuser;
14+
private $tb_project_user;
1415
private $tb_task_user;
1516
private $tb_categories;
1617
private $tb_category_project;
@@ -24,7 +25,6 @@ class Project {
2425
private $projects;
2526
private $project_ids;
2627
private $is_single_query = false;
27-
private $tb_project_user;
2828
private $found_rows;
2929

3030

0 commit comments

Comments
 (0)