Skip to content

Commit f95f4c9

Browse files
committed
Remove the optional support for ancient PHP versions.
1 parent 643206f commit f95f4c9

File tree

2 files changed

+4
-43
lines changed

2 files changed

+4
-43
lines changed

package.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,6 @@
5151
"type": "boolean",
5252
"default": true,
5353
"description": "Add type declarations (also known as type hints) to autocompleted callback functions"
54-
},
55-
"vscode-wordpress-hooks.typeDeclarations.olderPhpVersionSupport": {
56-
"type": "string",
57-
"description": "PHP 7.2 or higher is required to support the full set of type declaration features. If you need to support an older version of PHP, select it here and only the types available in that version of PHP will be used",
58-
"default": "None",
59-
"enum": [
60-
"None",
61-
"7.1",
62-
"7.0",
63-
"5.6"
64-
]
6554
}
6655
}
6756
}

src/extension.ts

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ interface tagType {
114114
function getTagType(
115115
tag: Tag,
116116
): tagType | null {
117-
const typeDeclarationsSupport = getMinPHPVersion();
118-
119117
// https://www.php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration
120118
const allowedTypes: { [key: string]: number } = {
121119
self: 5.0,
@@ -134,11 +132,6 @@ function getTagType(
134132
nullable: false,
135133
};
136134

137-
// Type declarations disabled? Bail.
138-
if (!typeDeclarationsSupport) {
139-
return null;
140-
}
141-
142135
// No type info? Bail.
143136
if (!tag.types) {
144137
return null;
@@ -147,7 +140,7 @@ function getTagType(
147140
const types = [...tag.types];
148141

149142
// Handle nullable type.
150-
if (types.length === 2 && typeDeclarationsSupport >= 7.1) {
143+
if (types.length === 2) {
151144
if (types[0] === 'null') {
152145
types.splice(0, 1);
153146
typeData.nullable = true;
@@ -195,7 +188,7 @@ function getTagType(
195188
}
196189

197190
// Check the allowed types, ignoring unknown types such as class and interface names.
198-
if (allowedTypes[type] && (allowedTypes[type] > typeDeclarationsSupport)) {
191+
if (allowedTypes[type]) {
199192
return null;
200193
}
201194

@@ -207,29 +200,9 @@ function getTagType(
207200
function getReturnType(
208201
tag: Tag,
209202
) : tagType | null {
210-
// Return type declarations require PHP 7 or higher.
211-
if (getMinPHPVersion() < 7) {
212-
return null;
213-
}
214-
215203
return getTagType(tag);
216204
}
217205

218-
function getMinPHPVersion() : number {
219-
const typeDeclarationsEnabled: boolean = vscode.workspace.getConfiguration(extensionName).get('typeDeclarations.enable') ?? true;
220-
const typeDeclarationsSupportSetting: string = vscode.workspace.getConfiguration(extensionName).get('typeDeclarations.olderPhpVersionSupport') ?? '';
221-
222-
if (!typeDeclarationsEnabled) {
223-
return 0;
224-
}
225-
226-
if (!typeDeclarationsSupportSetting || typeDeclarationsSupportSetting === 'None') {
227-
return 999;
228-
}
229-
230-
return parseFloat(typeDeclarationsSupportSetting);
231-
}
232-
233206
interface contextualPosition {
234207
symbol: vscode.DocumentSymbol | null;
235208
inNamespace: boolean;
@@ -380,9 +353,8 @@ export function activate(
380353
docblockLines.push(` * @return ${params[0].types?.join('|') || ''} ${params[0].content}`);
381354
} else {
382355
const actionArgsString = snippetArgsString ? ` ${snippetArgsString} ` : '';
383-
returnTypeString = (getMinPHPVersion() >= 7.1) ? ' : void' : '';
384-
snippetCallback = `(${actionArgsString})${returnTypeString} {\n\t\${1}\n}`;
385-
documentationCallback = `(${docArgsString})${returnTypeString} {\n}`;
356+
snippetCallback = `(${actionArgsString}) : void {\n\t\${1}\n}`;
357+
documentationCallback = `(${docArgsString}) : void {\n}`;
386358
}
387359

388360
docblockLines.push(' */');

0 commit comments

Comments
 (0)