Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry BLIND2019-11-23 07:06:57 -0500
committerThierry BLIND2019-11-23 07:06:57 -0500
commit80f4bdc9b25197cb75dd5dda7310146802babcad (patch)
tree6310b063fbccf3d49c98c9f2dcbcd8b3f418b9e8
parenta9bd976a3fb2bb7222b558196c61f9dd1567d731 (diff)
downloadorg.eclipse.pdt-80f4bdc9b25197cb75dd5dda7310146802babcad.tar.gz
org.eclipse.pdt-80f4bdc9b25197cb75dd5dda7310146802babcad.tar.xz
org.eclipse.pdt-80f4bdc9b25197cb75dd5dda7310146802babcad.zip
Bug 553378 - fix boolean type detection for generated class property
PHPDocs Signed-off-by: Thierry BLIND <thierryblind@msn.com>
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/ui/CodeGeneration.java11
-rw-r--r--tests/org.eclipse.php.ui.tests/workspace/phpdoc-generation/php5/fieldTest04.pdtt22
2 files changed, 31 insertions, 2 deletions
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/ui/CodeGeneration.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/ui/CodeGeneration.java
index 84da29750..971b99180 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/ui/CodeGeneration.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/ui/CodeGeneration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015, 2017 IBM Corporation and others.
+ * Copyright (c) 2009-2019 IBM Corporation and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
@@ -386,8 +386,15 @@ public class CodeGeneration {
case Scalar.TYPE_INT:
fieldTypes[i] = "integer"; //$NON-NLS-1$
break;
+ case Scalar.TYPE_REAL:
+ fieldTypes[i] = PHPSimpleTypes.NUMBER.getTypeName();
+ break;
case Scalar.TYPE_STRING:
- if (!expression.isNullExpression()) {
+ String value = scalar.getStringValue();
+ if ("true".equalsIgnoreCase(value) //$NON-NLS-1$
+ || "false".equalsIgnoreCase(value)) { //$NON-NLS-1$
+ fieldTypes[i] = PHPSimpleTypes.BOOLEAN.getTypeName();
+ } else if (!expression.isNullExpression()) {
fieldTypes[i] = PHPSimpleTypes.STRING.getTypeName();
} else {
// we don't want to use varType to describe
diff --git a/tests/org.eclipse.php.ui.tests/workspace/phpdoc-generation/php5/fieldTest04.pdtt b/tests/org.eclipse.php.ui.tests/workspace/phpdoc-generation/php5/fieldTest04.pdtt
new file mode 100644
index 000000000..b185880a6
--- /dev/null
+++ b/tests/org.eclipse.php.ui.tests/workspace/phpdoc-generation/php5/fieldTest04.pdtt
@@ -0,0 +1,22 @@
+--TEST--
+Bug 553378 - fix boolean type detection for generated class property PHPDocs
+--FILE--
+<?php
+class foo
+{
+ /**|
+ public $prop1 = false, $prop2 = true, $prop3 = 0, $prop4 = 0.5;
+}
+--EXPECT--
+<?php
+class foo
+{
+ /**
+ *
+ * @var boolean $prop1
+ * @var boolean $prop2
+ * @var integer $prop3
+ * @var number $prop4
+ */
+ public $prop1 = false, $prop2 = true, $prop3 = 0, $prop4 = 0.5;
+} \ No newline at end of file

Back to the top