This is an automated email from the ASF dual-hosted git repository.
tmysik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 48c3e4f [NETBEANS-53] Improve constructor getter setter code
generation
new 2a2eb51 Merge pull request #1423 from junichi11/netbeans-53
48c3e4f is described below
commit 48c3e4ffe0f8601d6898b5cef65712b057a604bd
Author: Junichi Yamamoto <[email protected]>
AuthorDate: Tue Aug 13 21:21:23 2019 +0900
[NETBEANS-53] Improve constructor getter setter code generation
- Add types of properties to parameter and return types of constructor,
getter,or setter
- Add hasScalarAndReturnTypes(), hasNullableTypes(), and hasPropertyTypes()
methods to PhpVersion
---
php/php.api.phpmodule/manifest.mf | 2 +-
.../org/netbeans/modules/php/api/PhpVersion.java | 33 ++++++
php/php.editor/nbproject/project.properties | 2 +-
php/php.editor/nbproject/project.xml | 2 +-
.../modules/php/editor/codegen/CGSInfo.java | 78 ++++++++++---
.../modules/php/editor/model/impl/Type.java | 11 ++
.../testTypedPropertiesConstructor.php | 73 ++++++++++++
...hp.testTypedPropertiesConstructor_PHP56.codegen | 20 ++++
...hp.testTypedPropertiesConstructor_PHP70.codegen | 20 ++++
...hp.testTypedPropertiesConstructor_PHP71.codegen | 20 ++++
...hp.testTypedPropertiesConstructor_PHP74.codegen | 20 ++++
.../testTypedPropertiesGetter.php | 73 ++++++++++++
...ter.php.testTypedPropertiesGetter_PHP56.codegen | 72 ++++++++++++
...ter.php.testTypedPropertiesGetter_PHP70.codegen | 72 ++++++++++++
...ter.php.testTypedPropertiesGetter_PHP71.codegen | 72 ++++++++++++
...ter.php.testTypedPropertiesGetter_PHP74.codegen | 72 ++++++++++++
.../testTypedPropertiesSetter.php | 73 ++++++++++++
...ter.php.testTypedPropertiesSetter_PHP56.codegen | 72 ++++++++++++
...ter.php.testTypedPropertiesSetter_PHP70.codegen | 72 ++++++++++++
...ter.php.testTypedPropertiesSetter_PHP71.codegen | 72 ++++++++++++
...ter.php.testTypedPropertiesSetter_PHP74.codegen | 72 ++++++++++++
.../SelectedPropertyMethodsCreatorTest.java | 124 ++++++++++++++++-----
22 files changed, 1085 insertions(+), 42 deletions(-)
diff --git a/php/php.api.phpmodule/manifest.mf
b/php/php.api.phpmodule/manifest.mf
index 629ff1d..cd7b570 100644
--- a/php/php.api.phpmodule/manifest.mf
+++ b/php/php.api.phpmodule/manifest.mf
@@ -1,4 +1,4 @@
Manifest-Version: 1.0
OpenIDE-Module: org.netbeans.modules.php.api.phpmodule
OpenIDE-Module-Localizing-Bundle:
org/netbeans/modules/php/api/phpmodule/resources/Bundle.properties
-OpenIDE-Module-Specification-Version: 2.66
+OpenIDE-Module-Specification-Version: 2.67
diff --git
a/php/php.api.phpmodule/src/org/netbeans/modules/php/api/PhpVersion.java
b/php/php.api.phpmodule/src/org/netbeans/modules/php/api/PhpVersion.java
index d17ca32..ebcd426 100644
--- a/php/php.api.phpmodule/src/org/netbeans/modules/php/api/PhpVersion.java
+++ b/php/php.api.phpmodule/src/org/netbeans/modules/php/api/PhpVersion.java
@@ -136,6 +136,39 @@ public enum PhpVersion {
return namespaces;
}
+ /**
+ * Check whether this version supports scalar and return type declarations.
+ *
+ * @return {@code true} if this version scalar and return type
declarations,
+ * {@code false} otherwise
+ * @since 2.67
+ */
+ public boolean hasScalarAndReturnTypes() {
+ return this.compareTo(PhpVersion.PHP_70) >= 0;
+ }
+
+ /**
+ * Check whether this version supports nullable types.
+ *
+ * @return {@code true} if this version supports nullable types,
+ * {@code false} otherwise
+ * @since 2.67
+ */
+ public boolean hasNullableTypes() {
+ return this.compareTo(PhpVersion.PHP_71) >= 0;
+ }
+
+ /**
+ * Check whether this version supports typed properties.
+ *
+ * @return {@code true} if this version supports typed properties,
+ * {@code false} otherwise
+ * @since 2.67
+ */
+ public boolean hasPropertyTypes() {
+ return this.compareTo(PhpVersion.PHP_74) >= 0;
+ }
+
@Override
public String toString() {
return getDisplayName();
diff --git a/php/php.editor/nbproject/project.properties
b/php/php.editor/nbproject/project.properties
index 67ad487..6beb2a9 100644
--- a/php/php.editor/nbproject/project.properties
+++ b/php/php.editor/nbproject/project.properties
@@ -20,7 +20,7 @@ build.compiler=extJavac
nbjavac.ignore.missing.enclosing=**/CUP$ASTPHP5Parser$actions.class
javac.compilerargs=-J-Xmx512m
nbm.needs.restart=true
-spec.version.base=1.81.0
+spec.version.base=1.82.0
release.external/predefined_vars-1.0.zip=docs/predefined_vars.zip
sigtest.gen.fail.on.error=false
diff --git a/php/php.editor/nbproject/project.xml
b/php/php.editor/nbproject/project.xml
index dd804e8..e662367 100644
--- a/php/php.editor/nbproject/project.xml
+++ b/php/php.editor/nbproject/project.xml
@@ -304,7 +304,7 @@
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
- <specification-version>2.65</specification-version>
+ <specification-version>2.67</specification-version>
</run-dependency>
</dependency>
<dependency>
diff --git
a/php/php.editor/src/org/netbeans/modules/php/editor/codegen/CGSInfo.java
b/php/php.editor/src/org/netbeans/modules/php/editor/codegen/CGSInfo.java
index d189f36..e7eb35c 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/codegen/CGSInfo.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/codegen/CGSInfo.java
@@ -23,6 +23,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Locale;
import java.util.Set;
import javax.swing.text.JTextComponent;
import org.netbeans.modules.csl.spi.ParserResult;
@@ -33,6 +34,7 @@ import org.netbeans.modules.parsing.api.UserTask;
import org.netbeans.modules.parsing.spi.ParseException;
import org.netbeans.modules.php.api.PhpVersion;
import org.netbeans.modules.php.editor.CodeUtils;
+import org.netbeans.modules.php.editor.NavUtils;
import org.netbeans.modules.php.editor.api.ElementQuery.Index;
import org.netbeans.modules.php.editor.api.ElementQueryFactory;
import org.netbeans.modules.php.editor.api.NameKind;
@@ -46,11 +48,10 @@ import
org.netbeans.modules.php.editor.api.elements.TypeElement;
import org.netbeans.modules.php.editor.api.elements.TypeNameResolver;
import org.netbeans.modules.php.editor.codegen.CGSGenerator.GenWay;
import org.netbeans.modules.php.editor.elements.TypeNameResolverImpl;
+import org.netbeans.modules.php.editor.model.Model;
import org.netbeans.modules.php.editor.model.ModelUtils;
import org.netbeans.modules.php.editor.model.impl.Type;
import org.netbeans.modules.php.editor.model.impl.VariousUtils;
-import org.netbeans.modules.php.editor.NavUtils;
-import org.netbeans.modules.php.editor.model.Model;
import org.netbeans.modules.php.editor.parser.PHPParseResult;
import org.netbeans.modules.php.editor.parser.api.Utils;
import org.netbeans.modules.php.editor.parser.astnodes.ASTNode;
@@ -61,6 +62,7 @@ import
org.netbeans.modules.php.editor.parser.astnodes.Comment;
import org.netbeans.modules.php.editor.parser.astnodes.FieldsDeclaration;
import org.netbeans.modules.php.editor.parser.astnodes.Identifier;
import org.netbeans.modules.php.editor.parser.astnodes.MethodDeclaration;
+import org.netbeans.modules.php.editor.parser.astnodes.NullableType;
import org.netbeans.modules.php.editor.parser.astnodes.PHPDocBlock;
import org.netbeans.modules.php.editor.parser.astnodes.PHPDocTag;
import org.netbeans.modules.php.editor.parser.astnodes.PHPDocTypeNode;
@@ -75,6 +77,7 @@ import org.openide.filesystems.FileObject;
import org.openide.util.Exceptions;
/**
+ * Constructor Getter Setter Info.
*
* @author Petr Pisl
*/
@@ -90,6 +93,7 @@ public final class CGSInfo {
private final List<Property> possibleGettersSetters;
private final List<MethodProperty> possibleMethods;
private final JTextComponent textComp;
+ private final PhpVersion phpVersion;
/**
* how to generate getters and setters method name
*/
@@ -97,10 +101,9 @@ public final class CGSInfo {
private boolean generateDoc;
private boolean fluentSetter;
private boolean isPublicModifier;
- private PhpVersion phpVersion;
- private CGSInfo(JTextComponent textComp) {
+ private CGSInfo(JTextComponent textComp, PhpVersion phpVersion) {
properties = new ArrayList<>();
instanceProperties = new ArrayList<>();
possibleGetters = new ArrayList<>();
@@ -114,10 +117,21 @@ public final class CGSInfo {
fluentSetter = false;
isPublicModifier = false;
this.howToGenerate = CGSGenerator.GenWay.AS_JAVA;
+ this.phpVersion = phpVersion != null ? phpVersion :
PhpVersion.getDefault();
}
public static CGSInfo getCGSInfo(JTextComponent textComp) {
- CGSInfo info = new CGSInfo(textComp);
+ PhpVersion phpVersion = null;
+ FileObject file = NavUtils.getFile(textComp.getDocument());
+ if (file != null) {
+ phpVersion = CodeUtils.getPhpVersion(file);
+ }
+ return getCGSInfo(textComp, phpVersion);
+ }
+
+ // for unit tests
+ static CGSInfo getCGSInfo(JTextComponent textComp, PhpVersion phpVersion) {
+ CGSInfo info = new CGSInfo(textComp, phpVersion);
info.findPropertyInScope();
return info;
}
@@ -194,11 +208,6 @@ public final class CGSInfo {
return phpVersion;
}
- // for unit tests
- void setPhpVersion(PhpVersion phpVersion) {
- this.phpVersion = phpVersion;
- }
-
public TypeNameResolver createTypeNameResolver(MethodElement method) {
TypeNameResolver result;
if (method.getParameters().isEmpty()) {
@@ -222,7 +231,6 @@ public final class CGSInfo {
if (file == null) {
return;
}
- phpVersion = CodeUtils.getPhpVersion(file);
try {
ParserManager.parse(Collections.singleton(Source.create(textComp.getDocument())),
new UserTask() {
@@ -337,7 +345,8 @@ public final class CGSInfo {
Variable variable = singleFieldDeclaration.getName();
if (variable != null && variable.getName() instanceof
Identifier) {
String name = ((Identifier) variable.getName()).getName();
- Property property = new Property(name, node.getModifier(),
getPropertyType(singleFieldDeclaration));
+ String type = getPropertyType(node,
singleFieldDeclaration);
+ Property property = new Property(name, node.getModifier(),
type);
if
(!BodyDeclaration.Modifier.isStatic(node.getModifier())) {
getInstanceProperties().add(property);
}
@@ -346,6 +355,26 @@ public final class CGSInfo {
}
}
+ private String getPropertyType(FieldsDeclaration fieldsDeclaration,
SingleFieldDeclaration singleFieldDeclaration) {
+ String type = ""; // NOI18N
+ if (fieldsDeclaration.getFieldType() == null ||
!phpVersion.hasPropertyTypes()) {
+ type = getPropertyType(singleFieldDeclaration);
+ } else {
+ // PHP 7.4 or newer
+ QualifiedName qualifiedName =
QualifiedName.create(fieldsDeclaration.getFieldType());
+ if (qualifiedName != null) {
+ type = qualifiedName.toString();
+ if (fieldsDeclaration.getFieldType() instanceof
NullableType) {
+ type = CodeUtils.NULLABLE_TYPE_PREFIX + type;
+ }
+ }
+ assert !type.isEmpty() : "couldn't get the qualified name from
the field type(" + fieldsDeclaration.getFieldType() + ")"; // NOI18N
+ // if type is empty, check QualifiedName.create method (and
fix it if posiible)
+ // or get type name using another way
+ }
+ return type;
+ }
+
private String getPropertyType(final ASTNode node) {
String result = ""; //NOI18N
Comment comment = Utils.getCommentForNode(program, node);
@@ -369,10 +398,19 @@ public final class CGSInfo {
}
private String getFirstTypeFromTag(final PHPDocTypeTag typeTag) {
+ boolean canBeNull = canBeNull(typeTag);
String result = ""; //NOI18N
for (PHPDocTypeNode typeNode : typeTag.getTypes()) {
String type = typeNode.getValue();
- if (!Type.isPrimitive(type) &&
!VariousUtils.isSpecialClassName(type)) {
+ if (phpVersion.hasScalarAndReturnTypes()
+ && !VariousUtils.isSpecialClassName(type)
+ && !Type.isInvalidPropertyType(type)) {
+ result = typeNode.isArray() ? Type.ARRAY : type;
+ if (canBeNull && phpVersion.hasNullableTypes()) {
+ result = CodeUtils.NULLABLE_TYPE_PREFIX + result;
+ }
+ break;
+ } else if (!Type.isPrimitive(type) &&
!VariousUtils.isSpecialClassName(type)) {
result = typeNode.isArray() ? Type.ARRAY : type;
break;
}
@@ -380,6 +418,20 @@ public final class CGSInfo {
return result;
}
+ private boolean canBeNull(final PHPDocTypeTag typeTag) {
+ boolean canBeNull = false;
+ if (typeTag.getTypes().size() > 1) {
+ for (PHPDocTypeNode typeNode : typeTag.getTypes()) {
+ String type = typeNode.getValue().toLowerCase(new
Locale("en_US")); // NOI18N
+ if (type.equals(Type.NULL)) {
+ canBeNull = true;
+ break;
+ }
+ }
+ }
+ return canBeNull;
+ }
+
@Override
public void visit(MethodDeclaration node) {
String name = node.getFunction().getFunctionName().getName();
diff --git
a/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/Type.java
b/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/Type.java
index d5b06ec..c251da8 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/Type.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/Type.java
@@ -80,6 +80,17 @@ public final class Type {
}
/**
+ * Check whether propety type is invalid ({@code null}, {@code void}).
+ *
+ * @param typeName type name
+ * @return {@code true} if type is invalid, otherwise {@code false}
+ */
+ public static boolean isInvalidPropertyType(String typeName) {
+ return VOID.equals(typeName)
+ || NULL.equals(typeName);
+ }
+
+ /**
* Get valid types for the "editor". It means all the types
* that are valid to be used in source code (like "int" for PHP 7 etc.).
* <p>
diff --git
a/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesConstructor/testTypedPropertiesConstructor.php
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesConstructor/testTypedPropertiesConstructor.php
new file mode 100644
index 0000000..d2d4081
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesConstructor/testTypedPropertiesConstructor.php
@@ -0,0 +1,73 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+class Example
+{
+ /**
+ * @var array
+ */
+ private $instanceArray;
+ /**
+ * @var int
+ */
+ private $instanceInt;
+ /**
+ * @var string
+ */
+ private $instanceString;
+ /**
+ * @var bool
+ */
+ private $instanceBool;
+ /**
+ * @var null
+ */
+ private $instanceNull;
+ /**
+ * @var null|string
+ */
+ private $instanceNullable;
+ /**
+ * @var string[]|null
+ */
+ private $instanceArrayNullable;
+ /**
+ * @var Test53
+ */
+ private $instanceClass;
+ /**
+ * @var int
+ */
+ private static $staticInt;
+ /**
+ * @var int|null
+ */
+ private static $staticNullable;
+
+ // PHP7.4
+ private int $instanceInt74;
+ private string $instanceString74;
+ private bool $instanceBool74;
+ private ?string $instanceNullable74;
+ private static int $staticInt74;
+ private static string $staticString74;
+ private static bool $staticBool74;
+ private static ?string $staticNullable74;
+}
diff --git
a/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesConstructor/testTypedPropertiesConstructor.php.testTypedPropertiesConstructor_PHP56.codegen
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesConstructor/testTypedPropertiesConstructor.php.testTypedPropertiesConstructor_PHP56.codegen
new file mode 100644
index 0000000..a31cb51
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesConstructor/testTypedPropertiesConstructor.php.testTypedPropertiesConstructor_PHP56.codegen
@@ -0,0 +1,20 @@
+public function __construct($instanceArray, $instanceInt, $instanceString,
$instanceBool, $instanceNull, $instanceNullable, $instanceArrayNullable, Test53
$instanceClass, $staticInt, $staticNullable, $instanceInt74, $instanceString74,
$instanceBool74, $instanceNullable74, $staticInt74, $staticString74,
$staticBool74, $staticNullable74) {
+$$this->instanceArray = $instanceArray;
+$$this->instanceInt = $instanceInt;
+$$this->instanceString = $instanceString;
+$$this->instanceBool = $instanceBool;
+$$this->instanceNull = $instanceNull;
+$$this->instanceNullable = $instanceNullable;
+$$this->instanceArrayNullable = $instanceArrayNullable;
+$$this->instanceClass = $instanceClass;
+self::staticInt = $staticInt;
+self::staticNullable = $staticNullable;
+$$this->instanceInt74 = $instanceInt74;
+$$this->instanceString74 = $instanceString74;
+$$this->instanceBool74 = $instanceBool74;
+$$this->instanceNullable74 = $instanceNullable74;
+self::staticInt74 = $staticInt74;
+self::staticString74 = $staticString74;
+self::staticBool74 = $staticBool74;
+self::staticNullable74 = $staticNullable74;${cursor}
+}
diff --git
a/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesConstructor/testTypedPropertiesConstructor.php.testTypedPropertiesConstructor_PHP70.codegen
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesConstructor/testTypedPropertiesConstructor.php.testTypedPropertiesConstructor_PHP70.codegen
new file mode 100644
index 0000000..95c0db7
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesConstructor/testTypedPropertiesConstructor.php.testTypedPropertiesConstructor_PHP70.codegen
@@ -0,0 +1,20 @@
+public function __construct(array $instanceArray, int $instanceInt, string
$instanceString, bool $instanceBool, $instanceNull, string $instanceNullable,
array $instanceArrayNullable, Test53 $instanceClass, int $staticInt, int
$staticNullable, $instanceInt74, $instanceString74, $instanceBool74,
$instanceNullable74, $staticInt74, $staticString74, $staticBool74,
$staticNullable74) {
+$$this->instanceArray = $instanceArray;
+$$this->instanceInt = $instanceInt;
+$$this->instanceString = $instanceString;
+$$this->instanceBool = $instanceBool;
+$$this->instanceNull = $instanceNull;
+$$this->instanceNullable = $instanceNullable;
+$$this->instanceArrayNullable = $instanceArrayNullable;
+$$this->instanceClass = $instanceClass;
+self::staticInt = $staticInt;
+self::staticNullable = $staticNullable;
+$$this->instanceInt74 = $instanceInt74;
+$$this->instanceString74 = $instanceString74;
+$$this->instanceBool74 = $instanceBool74;
+$$this->instanceNullable74 = $instanceNullable74;
+self::staticInt74 = $staticInt74;
+self::staticString74 = $staticString74;
+self::staticBool74 = $staticBool74;
+self::staticNullable74 = $staticNullable74;${cursor}
+}
diff --git
a/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesConstructor/testTypedPropertiesConstructor.php.testTypedPropertiesConstructor_PHP71.codegen
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesConstructor/testTypedPropertiesConstructor.php.testTypedPropertiesConstructor_PHP71.codegen
new file mode 100644
index 0000000..e508f08
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesConstructor/testTypedPropertiesConstructor.php.testTypedPropertiesConstructor_PHP71.codegen
@@ -0,0 +1,20 @@
+public function __construct(array $instanceArray, int $instanceInt, string
$instanceString, bool $instanceBool, $instanceNull, ?string $instanceNullable,
?array $instanceArrayNullable, Test53 $instanceClass, int $staticInt, ?int
$staticNullable, $instanceInt74, $instanceString74, $instanceBool74,
$instanceNullable74, $staticInt74, $staticString74, $staticBool74,
$staticNullable74) {
+$$this->instanceArray = $instanceArray;
+$$this->instanceInt = $instanceInt;
+$$this->instanceString = $instanceString;
+$$this->instanceBool = $instanceBool;
+$$this->instanceNull = $instanceNull;
+$$this->instanceNullable = $instanceNullable;
+$$this->instanceArrayNullable = $instanceArrayNullable;
+$$this->instanceClass = $instanceClass;
+self::staticInt = $staticInt;
+self::staticNullable = $staticNullable;
+$$this->instanceInt74 = $instanceInt74;
+$$this->instanceString74 = $instanceString74;
+$$this->instanceBool74 = $instanceBool74;
+$$this->instanceNullable74 = $instanceNullable74;
+self::staticInt74 = $staticInt74;
+self::staticString74 = $staticString74;
+self::staticBool74 = $staticBool74;
+self::staticNullable74 = $staticNullable74;${cursor}
+}
diff --git
a/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesConstructor/testTypedPropertiesConstructor.php.testTypedPropertiesConstructor_PHP74.codegen
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesConstructor/testTypedPropertiesConstructor.php.testTypedPropertiesConstructor_PHP74.codegen
new file mode 100644
index 0000000..ad0c001
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesConstructor/testTypedPropertiesConstructor.php.testTypedPropertiesConstructor_PHP74.codegen
@@ -0,0 +1,20 @@
+public function __construct(array $instanceArray, int $instanceInt, string
$instanceString, bool $instanceBool, $instanceNull, ?string $instanceNullable,
?array $instanceArrayNullable, Test53 $instanceClass, int $staticInt, ?int
$staticNullable, int $instanceInt74, string $instanceString74, bool
$instanceBool74, ?string $instanceNullable74, int $staticInt74, string
$staticString74, bool $staticBool74, ?string $staticNullable74) {
+$$this->instanceArray = $instanceArray;
+$$this->instanceInt = $instanceInt;
+$$this->instanceString = $instanceString;
+$$this->instanceBool = $instanceBool;
+$$this->instanceNull = $instanceNull;
+$$this->instanceNullable = $instanceNullable;
+$$this->instanceArrayNullable = $instanceArrayNullable;
+$$this->instanceClass = $instanceClass;
+self::staticInt = $staticInt;
+self::staticNullable = $staticNullable;
+$$this->instanceInt74 = $instanceInt74;
+$$this->instanceString74 = $instanceString74;
+$$this->instanceBool74 = $instanceBool74;
+$$this->instanceNullable74 = $instanceNullable74;
+self::staticInt74 = $staticInt74;
+self::staticString74 = $staticString74;
+self::staticBool74 = $staticBool74;
+self::staticNullable74 = $staticNullable74;${cursor}
+}
diff --git
a/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesGetter/testTypedPropertiesGetter.php
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesGetter/testTypedPropertiesGetter.php
new file mode 100644
index 0000000..d2d4081
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesGetter/testTypedPropertiesGetter.php
@@ -0,0 +1,73 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+class Example
+{
+ /**
+ * @var array
+ */
+ private $instanceArray;
+ /**
+ * @var int
+ */
+ private $instanceInt;
+ /**
+ * @var string
+ */
+ private $instanceString;
+ /**
+ * @var bool
+ */
+ private $instanceBool;
+ /**
+ * @var null
+ */
+ private $instanceNull;
+ /**
+ * @var null|string
+ */
+ private $instanceNullable;
+ /**
+ * @var string[]|null
+ */
+ private $instanceArrayNullable;
+ /**
+ * @var Test53
+ */
+ private $instanceClass;
+ /**
+ * @var int
+ */
+ private static $staticInt;
+ /**
+ * @var int|null
+ */
+ private static $staticNullable;
+
+ // PHP7.4
+ private int $instanceInt74;
+ private string $instanceString74;
+ private bool $instanceBool74;
+ private ?string $instanceNullable74;
+ private static int $staticInt74;
+ private static string $staticString74;
+ private static bool $staticBool74;
+ private static ?string $staticNullable74;
+}
diff --git
a/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesGetter/testTypedPropertiesGetter.php.testTypedPropertiesGetter_PHP56.codegen
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesGetter/testTypedPropertiesGetter.php.testTypedPropertiesGetter_PHP56.codegen
new file mode 100644
index 0000000..6ad608b
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesGetter/testTypedPropertiesGetter.php.testTypedPropertiesGetter_PHP56.codegen
@@ -0,0 +1,72 @@
+public function getInstanceArray() {
+return $$this->instanceArray;
+}
+
+public function getInstanceInt() {
+return $$this->instanceInt;
+}
+
+public function getInstanceString() {
+return $$this->instanceString;
+}
+
+public function getInstanceBool() {
+return $$this->instanceBool;
+}
+
+public function getInstanceNull() {
+return $$this->instanceNull;
+}
+
+public function getInstanceNullable() {
+return $$this->instanceNullable;
+}
+
+public function getInstanceArrayNullable() {
+return $$this->instanceArrayNullable;
+}
+
+public function getInstanceClass() {
+return $$this->instanceClass;
+}
+
+public static function getStaticInt() {
+return self::$$staticInt;
+}
+
+public static function getStaticNullable() {
+return self::$$staticNullable;
+}
+
+public function getInstanceInt74() {
+return $$this->instanceInt74;
+}
+
+public function getInstanceString74() {
+return $$this->instanceString74;
+}
+
+public function getInstanceBool74() {
+return $$this->instanceBool74;
+}
+
+public function getInstanceNullable74() {
+return $$this->instanceNullable74;
+}
+
+public static function getStaticInt74() {
+return self::$$staticInt74;
+}
+
+public static function getStaticString74() {
+return self::$$staticString74;
+}
+
+public static function getStaticBool74() {
+return self::$$staticBool74;
+}
+
+public static function getStaticNullable74() {
+return self::$$staticNullable74;
+}
+
diff --git
a/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesGetter/testTypedPropertiesGetter.php.testTypedPropertiesGetter_PHP70.codegen
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesGetter/testTypedPropertiesGetter.php.testTypedPropertiesGetter_PHP70.codegen
new file mode 100644
index 0000000..a8a3e8e
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesGetter/testTypedPropertiesGetter.php.testTypedPropertiesGetter_PHP70.codegen
@@ -0,0 +1,72 @@
+public function getInstanceArray(): array {
+return $$this->instanceArray;
+}
+
+public function getInstanceInt(): int {
+return $$this->instanceInt;
+}
+
+public function getInstanceString(): string {
+return $$this->instanceString;
+}
+
+public function getInstanceBool(): bool {
+return $$this->instanceBool;
+}
+
+public function getInstanceNull() {
+return $$this->instanceNull;
+}
+
+public function getInstanceNullable(): string {
+return $$this->instanceNullable;
+}
+
+public function getInstanceArrayNullable(): array {
+return $$this->instanceArrayNullable;
+}
+
+public function getInstanceClass(): Test53 {
+return $$this->instanceClass;
+}
+
+public static function getStaticInt(): int {
+return self::$$staticInt;
+}
+
+public static function getStaticNullable(): int {
+return self::$$staticNullable;
+}
+
+public function getInstanceInt74() {
+return $$this->instanceInt74;
+}
+
+public function getInstanceString74() {
+return $$this->instanceString74;
+}
+
+public function getInstanceBool74() {
+return $$this->instanceBool74;
+}
+
+public function getInstanceNullable74() {
+return $$this->instanceNullable74;
+}
+
+public static function getStaticInt74() {
+return self::$$staticInt74;
+}
+
+public static function getStaticString74() {
+return self::$$staticString74;
+}
+
+public static function getStaticBool74() {
+return self::$$staticBool74;
+}
+
+public static function getStaticNullable74() {
+return self::$$staticNullable74;
+}
+
diff --git
a/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesGetter/testTypedPropertiesGetter.php.testTypedPropertiesGetter_PHP71.codegen
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesGetter/testTypedPropertiesGetter.php.testTypedPropertiesGetter_PHP71.codegen
new file mode 100644
index 0000000..a3dcdc5
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesGetter/testTypedPropertiesGetter.php.testTypedPropertiesGetter_PHP71.codegen
@@ -0,0 +1,72 @@
+public function getInstanceArray(): array {
+return $$this->instanceArray;
+}
+
+public function getInstanceInt(): int {
+return $$this->instanceInt;
+}
+
+public function getInstanceString(): string {
+return $$this->instanceString;
+}
+
+public function getInstanceBool(): bool {
+return $$this->instanceBool;
+}
+
+public function getInstanceNull() {
+return $$this->instanceNull;
+}
+
+public function getInstanceNullable(): ?string {
+return $$this->instanceNullable;
+}
+
+public function getInstanceArrayNullable(): ?array {
+return $$this->instanceArrayNullable;
+}
+
+public function getInstanceClass(): Test53 {
+return $$this->instanceClass;
+}
+
+public static function getStaticInt(): int {
+return self::$$staticInt;
+}
+
+public static function getStaticNullable(): ?int {
+return self::$$staticNullable;
+}
+
+public function getInstanceInt74() {
+return $$this->instanceInt74;
+}
+
+public function getInstanceString74() {
+return $$this->instanceString74;
+}
+
+public function getInstanceBool74() {
+return $$this->instanceBool74;
+}
+
+public function getInstanceNullable74() {
+return $$this->instanceNullable74;
+}
+
+public static function getStaticInt74() {
+return self::$$staticInt74;
+}
+
+public static function getStaticString74() {
+return self::$$staticString74;
+}
+
+public static function getStaticBool74() {
+return self::$$staticBool74;
+}
+
+public static function getStaticNullable74() {
+return self::$$staticNullable74;
+}
+
diff --git
a/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesGetter/testTypedPropertiesGetter.php.testTypedPropertiesGetter_PHP74.codegen
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesGetter/testTypedPropertiesGetter.php.testTypedPropertiesGetter_PHP74.codegen
new file mode 100644
index 0000000..1efe462
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesGetter/testTypedPropertiesGetter.php.testTypedPropertiesGetter_PHP74.codegen
@@ -0,0 +1,72 @@
+public function getInstanceArray(): array {
+return $$this->instanceArray;
+}
+
+public function getInstanceInt(): int {
+return $$this->instanceInt;
+}
+
+public function getInstanceString(): string {
+return $$this->instanceString;
+}
+
+public function getInstanceBool(): bool {
+return $$this->instanceBool;
+}
+
+public function getInstanceNull() {
+return $$this->instanceNull;
+}
+
+public function getInstanceNullable(): ?string {
+return $$this->instanceNullable;
+}
+
+public function getInstanceArrayNullable(): ?array {
+return $$this->instanceArrayNullable;
+}
+
+public function getInstanceClass(): Test53 {
+return $$this->instanceClass;
+}
+
+public static function getStaticInt(): int {
+return self::$$staticInt;
+}
+
+public static function getStaticNullable(): ?int {
+return self::$$staticNullable;
+}
+
+public function getInstanceInt74(): int {
+return $$this->instanceInt74;
+}
+
+public function getInstanceString74(): string {
+return $$this->instanceString74;
+}
+
+public function getInstanceBool74(): bool {
+return $$this->instanceBool74;
+}
+
+public function getInstanceNullable74(): ?string {
+return $$this->instanceNullable74;
+}
+
+public static function getStaticInt74(): int {
+return self::$$staticInt74;
+}
+
+public static function getStaticString74(): string {
+return self::$$staticString74;
+}
+
+public static function getStaticBool74(): bool {
+return self::$$staticBool74;
+}
+
+public static function getStaticNullable74(): ?string {
+return self::$$staticNullable74;
+}
+
diff --git
a/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesSetter/testTypedPropertiesSetter.php
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesSetter/testTypedPropertiesSetter.php
new file mode 100644
index 0000000..d2d4081
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesSetter/testTypedPropertiesSetter.php
@@ -0,0 +1,73 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+class Example
+{
+ /**
+ * @var array
+ */
+ private $instanceArray;
+ /**
+ * @var int
+ */
+ private $instanceInt;
+ /**
+ * @var string
+ */
+ private $instanceString;
+ /**
+ * @var bool
+ */
+ private $instanceBool;
+ /**
+ * @var null
+ */
+ private $instanceNull;
+ /**
+ * @var null|string
+ */
+ private $instanceNullable;
+ /**
+ * @var string[]|null
+ */
+ private $instanceArrayNullable;
+ /**
+ * @var Test53
+ */
+ private $instanceClass;
+ /**
+ * @var int
+ */
+ private static $staticInt;
+ /**
+ * @var int|null
+ */
+ private static $staticNullable;
+
+ // PHP7.4
+ private int $instanceInt74;
+ private string $instanceString74;
+ private bool $instanceBool74;
+ private ?string $instanceNullable74;
+ private static int $staticInt74;
+ private static string $staticString74;
+ private static bool $staticBool74;
+ private static ?string $staticNullable74;
+}
diff --git
a/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesSetter/testTypedPropertiesSetter.php.testTypedPropertiesSetter_PHP56.codegen
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesSetter/testTypedPropertiesSetter.php.testTypedPropertiesSetter_PHP56.codegen
new file mode 100644
index 0000000..9bc7e7a
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesSetter/testTypedPropertiesSetter.php.testTypedPropertiesSetter_PHP56.codegen
@@ -0,0 +1,72 @@
+public function setInstanceArray($$instanceArray) {
+$$this->instanceArray = $instanceArray;
+}
+
+public function setInstanceInt($$instanceInt) {
+$$this->instanceInt = $instanceInt;
+}
+
+public function setInstanceString($$instanceString) {
+$$this->instanceString = $instanceString;
+}
+
+public function setInstanceBool($$instanceBool) {
+$$this->instanceBool = $instanceBool;
+}
+
+public function setInstanceNull($$instanceNull) {
+$$this->instanceNull = $instanceNull;
+}
+
+public function setInstanceNullable($$instanceNullable) {
+$$this->instanceNullable = $instanceNullable;
+}
+
+public function setInstanceArrayNullable($$instanceArrayNullable) {
+$$this->instanceArrayNullable = $instanceArrayNullable;
+}
+
+public function setInstanceClass(Test53 $$instanceClass) {
+$$this->instanceClass = $instanceClass;
+}
+
+public static function setStaticInt($$staticInt) {
+self::$$staticInt = $staticInt;
+}
+
+public static function setStaticNullable($$staticNullable) {
+self::$$staticNullable = $staticNullable;
+}
+
+public function setInstanceInt74($$instanceInt74) {
+$$this->instanceInt74 = $instanceInt74;
+}
+
+public function setInstanceString74($$instanceString74) {
+$$this->instanceString74 = $instanceString74;
+}
+
+public function setInstanceBool74($$instanceBool74) {
+$$this->instanceBool74 = $instanceBool74;
+}
+
+public function setInstanceNullable74($$instanceNullable74) {
+$$this->instanceNullable74 = $instanceNullable74;
+}
+
+public static function setStaticInt74($$staticInt74) {
+self::$$staticInt74 = $staticInt74;
+}
+
+public static function setStaticString74($$staticString74) {
+self::$$staticString74 = $staticString74;
+}
+
+public static function setStaticBool74($$staticBool74) {
+self::$$staticBool74 = $staticBool74;
+}
+
+public static function setStaticNullable74($$staticNullable74) {
+self::$$staticNullable74 = $staticNullable74;
+}
+
diff --git
a/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesSetter/testTypedPropertiesSetter.php.testTypedPropertiesSetter_PHP70.codegen
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesSetter/testTypedPropertiesSetter.php.testTypedPropertiesSetter_PHP70.codegen
new file mode 100644
index 0000000..7386e04
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesSetter/testTypedPropertiesSetter.php.testTypedPropertiesSetter_PHP70.codegen
@@ -0,0 +1,72 @@
+public function setInstanceArray(array $$instanceArray) {
+$$this->instanceArray = $instanceArray;
+}
+
+public function setInstanceInt(int $$instanceInt) {
+$$this->instanceInt = $instanceInt;
+}
+
+public function setInstanceString(string $$instanceString) {
+$$this->instanceString = $instanceString;
+}
+
+public function setInstanceBool(bool $$instanceBool) {
+$$this->instanceBool = $instanceBool;
+}
+
+public function setInstanceNull($$instanceNull) {
+$$this->instanceNull = $instanceNull;
+}
+
+public function setInstanceNullable(string $$instanceNullable) {
+$$this->instanceNullable = $instanceNullable;
+}
+
+public function setInstanceArrayNullable(array $$instanceArrayNullable) {
+$$this->instanceArrayNullable = $instanceArrayNullable;
+}
+
+public function setInstanceClass(Test53 $$instanceClass) {
+$$this->instanceClass = $instanceClass;
+}
+
+public static function setStaticInt(int $$staticInt) {
+self::$$staticInt = $staticInt;
+}
+
+public static function setStaticNullable(int $$staticNullable) {
+self::$$staticNullable = $staticNullable;
+}
+
+public function setInstanceInt74($$instanceInt74) {
+$$this->instanceInt74 = $instanceInt74;
+}
+
+public function setInstanceString74($$instanceString74) {
+$$this->instanceString74 = $instanceString74;
+}
+
+public function setInstanceBool74($$instanceBool74) {
+$$this->instanceBool74 = $instanceBool74;
+}
+
+public function setInstanceNullable74($$instanceNullable74) {
+$$this->instanceNullable74 = $instanceNullable74;
+}
+
+public static function setStaticInt74($$staticInt74) {
+self::$$staticInt74 = $staticInt74;
+}
+
+public static function setStaticString74($$staticString74) {
+self::$$staticString74 = $staticString74;
+}
+
+public static function setStaticBool74($$staticBool74) {
+self::$$staticBool74 = $staticBool74;
+}
+
+public static function setStaticNullable74($$staticNullable74) {
+self::$$staticNullable74 = $staticNullable74;
+}
+
diff --git
a/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesSetter/testTypedPropertiesSetter.php.testTypedPropertiesSetter_PHP71.codegen
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesSetter/testTypedPropertiesSetter.php.testTypedPropertiesSetter_PHP71.codegen
new file mode 100644
index 0000000..44536a5
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesSetter/testTypedPropertiesSetter.php.testTypedPropertiesSetter_PHP71.codegen
@@ -0,0 +1,72 @@
+public function setInstanceArray(array $$instanceArray) {
+$$this->instanceArray = $instanceArray;
+}
+
+public function setInstanceInt(int $$instanceInt) {
+$$this->instanceInt = $instanceInt;
+}
+
+public function setInstanceString(string $$instanceString) {
+$$this->instanceString = $instanceString;
+}
+
+public function setInstanceBool(bool $$instanceBool) {
+$$this->instanceBool = $instanceBool;
+}
+
+public function setInstanceNull($$instanceNull) {
+$$this->instanceNull = $instanceNull;
+}
+
+public function setInstanceNullable(?string $$instanceNullable) {
+$$this->instanceNullable = $instanceNullable;
+}
+
+public function setInstanceArrayNullable(?array $$instanceArrayNullable) {
+$$this->instanceArrayNullable = $instanceArrayNullable;
+}
+
+public function setInstanceClass(Test53 $$instanceClass) {
+$$this->instanceClass = $instanceClass;
+}
+
+public static function setStaticInt(int $$staticInt) {
+self::$$staticInt = $staticInt;
+}
+
+public static function setStaticNullable(?int $$staticNullable) {
+self::$$staticNullable = $staticNullable;
+}
+
+public function setInstanceInt74($$instanceInt74) {
+$$this->instanceInt74 = $instanceInt74;
+}
+
+public function setInstanceString74($$instanceString74) {
+$$this->instanceString74 = $instanceString74;
+}
+
+public function setInstanceBool74($$instanceBool74) {
+$$this->instanceBool74 = $instanceBool74;
+}
+
+public function setInstanceNullable74($$instanceNullable74) {
+$$this->instanceNullable74 = $instanceNullable74;
+}
+
+public static function setStaticInt74($$staticInt74) {
+self::$$staticInt74 = $staticInt74;
+}
+
+public static function setStaticString74($$staticString74) {
+self::$$staticString74 = $staticString74;
+}
+
+public static function setStaticBool74($$staticBool74) {
+self::$$staticBool74 = $staticBool74;
+}
+
+public static function setStaticNullable74($$staticNullable74) {
+self::$$staticNullable74 = $staticNullable74;
+}
+
diff --git
a/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesSetter/testTypedPropertiesSetter.php.testTypedPropertiesSetter_PHP74.codegen
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesSetter/testTypedPropertiesSetter.php.testTypedPropertiesSetter_PHP74.codegen
new file mode 100644
index 0000000..32b45df
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/codegen/testTypedPropertiesSetter/testTypedPropertiesSetter.php.testTypedPropertiesSetter_PHP74.codegen
@@ -0,0 +1,72 @@
+public function setInstanceArray(array $$instanceArray) {
+$$this->instanceArray = $instanceArray;
+}
+
+public function setInstanceInt(int $$instanceInt) {
+$$this->instanceInt = $instanceInt;
+}
+
+public function setInstanceString(string $$instanceString) {
+$$this->instanceString = $instanceString;
+}
+
+public function setInstanceBool(bool $$instanceBool) {
+$$this->instanceBool = $instanceBool;
+}
+
+public function setInstanceNull($$instanceNull) {
+$$this->instanceNull = $instanceNull;
+}
+
+public function setInstanceNullable(?string $$instanceNullable) {
+$$this->instanceNullable = $instanceNullable;
+}
+
+public function setInstanceArrayNullable(?array $$instanceArrayNullable) {
+$$this->instanceArrayNullable = $instanceArrayNullable;
+}
+
+public function setInstanceClass(Test53 $$instanceClass) {
+$$this->instanceClass = $instanceClass;
+}
+
+public static function setStaticInt(int $$staticInt) {
+self::$$staticInt = $staticInt;
+}
+
+public static function setStaticNullable(?int $$staticNullable) {
+self::$$staticNullable = $staticNullable;
+}
+
+public function setInstanceInt74(int $$instanceInt74) {
+$$this->instanceInt74 = $instanceInt74;
+}
+
+public function setInstanceString74(string $$instanceString74) {
+$$this->instanceString74 = $instanceString74;
+}
+
+public function setInstanceBool74(bool $$instanceBool74) {
+$$this->instanceBool74 = $instanceBool74;
+}
+
+public function setInstanceNullable74(?string $$instanceNullable74) {
+$$this->instanceNullable74 = $instanceNullable74;
+}
+
+public static function setStaticInt74(int $$staticInt74) {
+self::$$staticInt74 = $staticInt74;
+}
+
+public static function setStaticString74(string $$staticString74) {
+self::$$staticString74 = $staticString74;
+}
+
+public static function setStaticBool74(bool $$staticBool74) {
+self::$$staticBool74 = $staticBool74;
+}
+
+public static function setStaticNullable74(?string $$staticNullable74) {
+self::$$staticNullable74 = $staticNullable74;
+}
+
diff --git
a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/codegen/SelectedPropertyMethodsCreatorTest.java
b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/codegen/SelectedPropertyMethodsCreatorTest.java
index 87173f1..d26daef 100644
---
a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/codegen/SelectedPropertyMethodsCreatorTest.java
+++
b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/codegen/SelectedPropertyMethodsCreatorTest.java
@@ -54,13 +54,17 @@ public class SelectedPropertyMethodsCreatorTest extends
PHPTestBase {
}
private CGSInfo getCgsInfo(String caretLine) {
+ return getCgsInfo(caretLine, PhpVersion.PHP_56);
+ }
+
+ private CGSInfo getCgsInfo(String caretLine, PhpVersion phpVersion) {
assert caretLine != null;
FileObject testFile = getTestFile(getTestPath());
Source testSource = getTestSource(testFile);
JTextArea ta = new JTextArea(testSource.getDocument(false));
int caretOffset =
getCaretOffset(testSource.createSnapshot().getText().toString(), caretLine);
ta.setCaretPosition(caretOffset);
- return CGSInfo.getCGSInfo(ta);
+ return CGSInfo.getCGSInfo(ta, phpVersion);
}
private <T extends Property> List<T> selectAllProperties(List<T>
properties) {
@@ -157,87 +161,75 @@ public class SelectedPropertyMethodsCreatorTest extends
PHPTestBase {
}
public void testInstanceImplementMethod_01() throws Exception {
- CGSInfo cgsInfo = getCgsInfo("class Bar implements Foo {^");
- cgsInfo.setPhpVersion(PhpVersion.PHP_70);
+ CGSInfo cgsInfo = getCgsInfo("class Bar implements Foo {^",
PhpVersion.PHP_70);
checkResult(new SelectedPropertyMethodsCreator().create(
selectProperties(cgsInfo.getPossibleMethods(), "myFoo"), new
SinglePropertyMethodCreator.InheritedMethodCreator(cgsInfo)));
}
public void testInstanceImplementMethod_02() throws Exception {
- CGSInfo cgsInfo = getCgsInfo("class Bar implements Foo {^");
- cgsInfo.setPhpVersion(PhpVersion.PHP_55);
+ CGSInfo cgsInfo = getCgsInfo("class Bar implements Foo {^",
PhpVersion.PHP_55);
checkResult(new SelectedPropertyMethodsCreator().create(
selectProperties(cgsInfo.getPossibleMethods(), "myFoo"), new
SinglePropertyMethodCreator.InheritedMethodCreator(cgsInfo)));
}
// #270237
public void testInstanceImplementMethodWithNullableType_01() throws
Exception {
- CGSInfo cgsInfo = getCgsInfo("class Bar implements Foo {^");
- cgsInfo.setPhpVersion(PhpVersion.PHP_71);
+ CGSInfo cgsInfo = getCgsInfo("class Bar implements Foo {^",
PhpVersion.PHP_71);
checkResult(new SelectedPropertyMethodsCreator().create(
selectProperties(cgsInfo.getPossibleMethods(), "myFoo"), new
SinglePropertyMethodCreator.InheritedMethodCreator(cgsInfo)));
}
public void testInstanceImplementMethodWithNullableType_02() throws
Exception {
- CGSInfo cgsInfo = getCgsInfo("class Bar implements Foo {^");
- cgsInfo.setPhpVersion(PhpVersion.PHP_55);
+ CGSInfo cgsInfo = getCgsInfo("class Bar implements Foo {^",
PhpVersion.PHP_55);
checkResult(new SelectedPropertyMethodsCreator().create(
selectProperties(cgsInfo.getPossibleMethods(), "myFoo"), new
SinglePropertyMethodCreator.InheritedMethodCreator(cgsInfo)));
}
public void testInstanceOverrideMethod_01() throws Exception {
- CGSInfo cgsInfo = getCgsInfo("class Bar extends Foo {^");
- cgsInfo.setPhpVersion(PhpVersion.PHP_70);
+ CGSInfo cgsInfo = getCgsInfo("class Bar extends Foo {^",
PhpVersion.PHP_70);
checkResult(new SelectedPropertyMethodsCreator().create(
selectProperties(cgsInfo.getPossibleMethods(), "myFoo"), new
SinglePropertyMethodCreator.InheritedMethodCreator(cgsInfo)));
}
public void testInstanceOverrideMethod_02() throws Exception {
- CGSInfo cgsInfo = getCgsInfo("class Bar extends Foo {^");
- cgsInfo.setPhpVersion(PhpVersion.PHP_56);
+ CGSInfo cgsInfo = getCgsInfo("class Bar extends Foo {^",
PhpVersion.PHP_56);
checkResult(new SelectedPropertyMethodsCreator().create(
selectProperties(cgsInfo.getPossibleMethods(), "myFoo"), new
SinglePropertyMethodCreator.InheritedMethodCreator(cgsInfo)));
}
// #270237
public void testInstanceOverrideMethodWithNullableType_01() throws
Exception {
- CGSInfo cgsInfo = getCgsInfo("class Bar extends Foo {^");
- cgsInfo.setPhpVersion(PhpVersion.PHP_71);
+ CGSInfo cgsInfo = getCgsInfo("class Bar extends Foo {^",
PhpVersion.PHP_71);
checkResult(new SelectedPropertyMethodsCreator().create(
selectProperties(cgsInfo.getPossibleMethods(), "myFoo"), new
SinglePropertyMethodCreator.InheritedMethodCreator(cgsInfo)));
}
public void testInstanceOverrideMethodWithNullableType_02() throws
Exception {
- CGSInfo cgsInfo = getCgsInfo("class Bar extends Foo {^");
- cgsInfo.setPhpVersion(PhpVersion.PHP_56);
+ CGSInfo cgsInfo = getCgsInfo("class Bar extends Foo {^",
PhpVersion.PHP_56);
checkResult(new SelectedPropertyMethodsCreator().create(
selectProperties(cgsInfo.getPossibleMethods(), "myFoo"), new
SinglePropertyMethodCreator.InheritedMethodCreator(cgsInfo)));
}
public void testGetterWithType_01() throws Exception {
- CGSInfo cgsInfo = getCgsInfo("class Foo {^");
- cgsInfo.setPhpVersion(PhpVersion.PHP_70);
+ CGSInfo cgsInfo = getCgsInfo("class Foo {^", PhpVersion.PHP_70);
checkResult(new SelectedPropertyMethodsCreator().create(
selectAllProperties(cgsInfo.getPossibleGetters()), new
SinglePropertyMethodCreator.SingleGetterCreator(cgsInfo)));
}
public void testGetterWithType_02() throws Exception {
- CGSInfo cgsInfo = getCgsInfo("class Foo {^");
- cgsInfo.setPhpVersion(PhpVersion.PHP_55);
+ CGSInfo cgsInfo = getCgsInfo("class Foo {^", PhpVersion.PHP_55);
checkResult(new SelectedPropertyMethodsCreator().create(
selectAllProperties(cgsInfo.getPossibleGetters()), new
SinglePropertyMethodCreator.SingleGetterCreator(cgsInfo)));
}
public void testGetterWithMoreTypes_01() throws Exception {
- CGSInfo cgsInfo = getCgsInfo("class Foo {^");
- cgsInfo.setPhpVersion(PhpVersion.PHP_70);
+ CGSInfo cgsInfo = getCgsInfo("class Foo {^", PhpVersion.PHP_70);
checkResult(new SelectedPropertyMethodsCreator().create(
selectAllProperties(cgsInfo.getPossibleGetters()), new
SinglePropertyMethodCreator.SingleGetterCreator(cgsInfo)));
}
public void testGetterWithMoreTypes_02() throws Exception {
- CGSInfo cgsInfo = getCgsInfo("class Foo {^");
- cgsInfo.setPhpVersion(PhpVersion.PHP_56);
+ CGSInfo cgsInfo = getCgsInfo("class Foo {^", PhpVersion.PHP_56);
checkResult(new SelectedPropertyMethodsCreator().create(
selectAllProperties(cgsInfo.getPossibleGetters()), new
SinglePropertyMethodCreator.SingleGetterCreator(cgsInfo)));
}
@@ -250,9 +242,89 @@ public class SelectedPropertyMethodsCreatorTest extends
PHPTestBase {
// PHP 7.4
public void testSerializeUnserializeMagicMethod() throws Exception {
- CGSInfo cgsInfo = getCgsInfo("class Foo {^");
+ CGSInfo cgsInfo = getCgsInfo("class Foo {^", PhpVersion.PHP_74);
checkResult(new SelectedPropertyMethodsCreator().create(
selectProperties(cgsInfo.getPossibleMethods(), "__serialize",
"__unserialize"), new
SinglePropertyMethodCreator.InheritedMethodCreator(cgsInfo)));
}
+ // NETBEANS-53
+ // getter
+ public void testTypedPropertiesGetter_PHP56() throws Exception {
+ CGSInfo cgsInfo = getCgsInfo("^}", PhpVersion.PHP_56);
+ cgsInfo.setPublicModifier(true);
+ checkResult(new
SelectedPropertyMethodsCreator().create(selectAllProperties(cgsInfo.getPossibleGetters()),
new SinglePropertyMethodCreator.SingleGetterCreator(cgsInfo)));
+ }
+
+ public void testTypedPropertiesGetter_PHP70() throws Exception {
+ CGSInfo cgsInfo = getCgsInfo("^}", PhpVersion.PHP_70);
+ cgsInfo.setPublicModifier(true);
+ checkResult(new
SelectedPropertyMethodsCreator().create(selectAllProperties(cgsInfo.getPossibleGetters()),
new SinglePropertyMethodCreator.SingleGetterCreator(cgsInfo)));
+ }
+
+ public void testTypedPropertiesGetter_PHP71() throws Exception {
+ CGSInfo cgsInfo = getCgsInfo("^}", PhpVersion.PHP_71);
+ cgsInfo.setPublicModifier(true);
+ checkResult(new
SelectedPropertyMethodsCreator().create(selectAllProperties(cgsInfo.getPossibleGetters()),
new SinglePropertyMethodCreator.SingleGetterCreator(cgsInfo)));
+ }
+
+ public void testTypedPropertiesGetter_PHP74() throws Exception {
+ CGSInfo cgsInfo = getCgsInfo("^}", PhpVersion.PHP_74);
+ cgsInfo.setPublicModifier(true);
+ checkResult(new
SelectedPropertyMethodsCreator().create(selectAllProperties(cgsInfo.getPossibleGetters()),
new SinglePropertyMethodCreator.SingleGetterCreator(cgsInfo)));
+ }
+
+ // setter
+ public void testTypedPropertiesSetter_PHP56() throws Exception {
+ CGSInfo cgsInfo = getCgsInfo("^}", PhpVersion.PHP_56);
+ cgsInfo.setPublicModifier(true);
+ checkResult(new
SelectedPropertyMethodsCreator().create(selectAllProperties(cgsInfo.getPossibleSetters()),
new SinglePropertyMethodCreator.SingleSetterCreator(cgsInfo)));
+ }
+
+ public void testTypedPropertiesSetter_PHP70() throws Exception {
+ CGSInfo cgsInfo = getCgsInfo("^}", PhpVersion.PHP_70);
+ cgsInfo.setPublicModifier(true);
+ checkResult(new
SelectedPropertyMethodsCreator().create(selectAllProperties(cgsInfo.getPossibleSetters()),
new SinglePropertyMethodCreator.SingleSetterCreator(cgsInfo)));
+ }
+
+ public void testTypedPropertiesSetter_PHP71() throws Exception {
+ CGSInfo cgsInfo = getCgsInfo("^}", PhpVersion.PHP_71);
+ cgsInfo.setPublicModifier(true);
+ checkResult(new
SelectedPropertyMethodsCreator().create(selectAllProperties(cgsInfo.getPossibleSetters()),
new SinglePropertyMethodCreator.SingleSetterCreator(cgsInfo)));
+ }
+
+ public void testTypedPropertiesSetter_PHP74() throws Exception {
+ CGSInfo cgsInfo = getCgsInfo("^}", PhpVersion.PHP_74);
+ cgsInfo.setPublicModifier(true);
+ checkResult(new
SelectedPropertyMethodsCreator().create(selectAllProperties(cgsInfo.getPossibleSetters()),
new SinglePropertyMethodCreator.SingleSetterCreator(cgsInfo)));
+ }
+
+ // constructor
+ public void testTypedPropertiesConstructor_PHP56() throws Exception {
+ CGSInfo cgsInfo = getCgsInfo("^}", PhpVersion.PHP_56);
+ cgsInfo.setPublicModifier(true);
+ selectAllProperties(cgsInfo.getProperties());
+ checkResult(CGSGenerator.GenType.CONSTRUCTOR.getTemplateText(cgsInfo));
+ }
+
+ public void testTypedPropertiesConstructor_PHP70() throws Exception {
+ CGSInfo cgsInfo = getCgsInfo("^}", PhpVersion.PHP_70);
+ cgsInfo.setPublicModifier(true);
+ selectAllProperties(cgsInfo.getProperties());
+ checkResult(CGSGenerator.GenType.CONSTRUCTOR.getTemplateText(cgsInfo));
+ }
+
+ public void testTypedPropertiesConstructor_PHP71() throws Exception {
+ CGSInfo cgsInfo = getCgsInfo("^}", PhpVersion.PHP_71);
+ cgsInfo.setPublicModifier(true);
+ selectAllProperties(cgsInfo.getProperties());
+ checkResult(CGSGenerator.GenType.CONSTRUCTOR.getTemplateText(cgsInfo));
+ }
+
+ public void testTypedPropertiesConstructor_PHP74() throws Exception {
+ CGSInfo cgsInfo = getCgsInfo("^}", PhpVersion.PHP_74);
+ cgsInfo.setPublicModifier(true);
+ selectAllProperties(cgsInfo.getProperties());
+ checkResult(CGSGenerator.GenType.CONSTRUCTOR.getTemplateText(cgsInfo));
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists