This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 197728 - PHP Class Template does not fill in placeholders
Summary: PHP Class Template does not fill in placeholders
Status: RESOLVED INCOMPLETE
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.0
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-14 06:43 UTC by nzeyimana
Modified: 2012-04-13 14:15 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nzeyimana 2011-04-14 06:43:44 UTC
Product Version = NetBeans IDE 7.0 RC1 (Build 201103280000)
Operating System = Windows XP version 5.1 running on x86
Java; VM; Vendor = 1.6.0_17
Runtime = Java HotSpot(TM) Client VM 14.3-b01

When one chooses "Source Files" -> Right-Click -> New PHPClass, the Class file is created but placeholders don't get replaced by actual values. 
the file content becomes 
<?php

<#assign licenseFirst = "/* ">
<#assign licensePrefix = " * ">
<#assign licenseLast = " */">
<#include "../Licenses/license-${project.license}.txt">

/**
 * Description of ${name}
 *
 * @author      ${user}
 * @copyright   [This gets replaced though]
 * @version     1.0.0
 * @created     ${date?date?string("yyyy-MM-dd")} ${time?time?string("HH:mm:ss")}
 * @date        ${date?date?string("yyyy-MM-dd")} ${time?time?string("HH:mm:ss")}
 */
class ${name}
{
public $Var1;
public $Var2;


public function fnFunctionName()
{
//
}
}


But when I use the menu [File -> New File], ${user} and ${name} are replaced. The other variables don't show up.
Comment 1 OndrejBrejla 2011-04-14 08:13:45 UTC
Can you try it using "dev" version? (http://bits.netbeans.org/download/trunk/nightly/latest/) Because it works for me properly...but I'm using Ubuntu. So can you try it please? Thanks.
Comment 2 nzeyimana 2011-04-14 10:44:04 UTC
(In reply to comment #1)
> Can you try it using "dev" version?
> (http://bits.netbeans.org/download/trunk/nightly/latest/) Because it works for
> me properly...but I'm using Ubuntu. So can you try it please? Thanks.

Even the DEV build does not solve this problem. 
But one extra detail is that I have a custom template (in my ${HOME}/.netbeans/${VER}/config/Templates/Scripting). And it works fine in NB 6.8 and 6.9 

The template has the text: 


<#assign licenseFirst = "/* ">
<#assign licensePrefix = " * ">
<#assign licenseLast = " */">
<#include "../Licenses/license-${project.license}.txt">

/**
 * Description of ${name}
 *
 * @author      ${user}
 * @copyright   NEFSYS
 * @version     1.0.0
 * @created     ${date?date?string("yyyy-MM-dd")} ${time?time?string("HH:mm:ss")}
 * @date        ${date?date?string("yyyy-MM-dd")} ${time?time?string("HH:mm:ss")}
 */
class ${name}
{
    public $Var1;
    public $Var2;


    public function fnFunctionName()
    {
        //
    }
}
Comment 3 zombat 2011-06-09 17:07:30 UTC
I am getting this as well on NetBeans IDE 7.0 (Build 201104080000), Java: 1.6.0_22; Java HotSpot(TM) 64-Bit Server VM 17.1-b03, on System: Windows 7 version 6.1 running on amd64; Cp1252; en_CA (nb).  However, I have noticed something odd that may be of help.

If I select a folder in the Projects explorer tree, then go to File Menu -> New File -> PHP -> PHP Class -> Finish, then I get a new editor window with the template values filled in correctly.

If I select a folder in the Projects explorer tree, then right-click -> New -> PHP Class -> Finish, I also get an editor window with the template values filled in correctly.

However, I have noticed that when I right click in the Projects tree, there are actually TWO options for a new PHP class file.  There is "PHP Class" and "PHPClass" (no space).  The "PHPClass" appears to be the problem.

If I select a folder in the Projects explorer tree, then right-click -> New -> PHPClass -> Finish (ie. the "no space" option), I get an editor window with the template values that are *not* filled in.

I do not know where this option is coming from.  If I go to Tools -> Templates -> PHP, I can only see the "PHP Class" (correct) template.  The incorrect "PHPClass" does not show up.  It does not appear anywhere in the Templates list in fact.

Hope this helps.
Comment 4 Petr Pisl 2011-06-22 14:28:31 UTC
I can not reproduce this. Probably it's somehow connecting with importing setting from one version to another one. 

Could you please send the list of files in config/Templates/Scripting folder and also content of .nbattrs file? Thanks.
Comment 5 zombat 2011-06-22 16:52:00 UTC
I agree that it's probably an importing/upgrading issue, I don't recall seeing it when I was using 6.8 on a fresh install.  In my ~\.netbeans directory I have a 7.0 and a 6.8 folder.  Inside ~\.netbeans\7.0\config\Templates\Scripting there are two files:

PHPClass
PHPClass.php

It seems the PHPClass file (no extension) contains the text that is not filled in properly, and the PHPClass.php file contains the text that is used correctly.

I checked the ~\.netbeans\6.8\config\Templates\Scripting folder as a comparison, and there is only one file, the PHPClass (no extension) file, and it is the same as the one that is in the 7.0 folder.  Looks like maybe it got imported during the upgrade but is now incorrect?

My ~\.netbeans\7.0\config\.nbattrs file contains the following:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE attributes PUBLIC "-//NetBeans//DTD DefaultAttributes 1.0//EN" "http://www.netbeans.org/dtds/attributes-1_0.dtd">
<attributes version="1.0">
    <fileobject name="">
        <attr name="Services\DiffProviders\org-netbeans-modules-diff-builtin-provider-BuiltInDiffProvider.settings\position" intvalue="100"/>
    </fileobject>
</attributes>


Cheers
Comment 6 Petr Pisl 2011-09-29 12:32:02 UTC
My guess is that this could happen during importing fro one version to another one. Unfortunately I can not reproduce it, so this is just my guess.
Comment 7 ckbosh 2012-03-15 21:46:20 UTC
Product Version: NetBeans IDE 7.1 (Build 201112071828)
Java: 1.6.0_07; Java HotSpot(TM) Client VM 10.0-b23
System: Windows Vista version 6.0 running on x86; Cp1252; en_US (nb)


Greetings,

I'm having exactly the same problem described by others, with the configuration above. File menu new class parses fine. Right-click context menu shows two "new php class" choices in the context. Both generate a file with the placeholders not replaced.

I did have older versions (6.9, 6.8, 6.7.1). on the machine in question, and did import settings with each upgrade. I skipped 7.0. The 7.1 upgrade is the first place this behavior has happened.
Comment 8 Ondrej Brejla 2012-04-13 14:15:28 UTC
Please, can you try it in 7.2 dev [1]? If the problem still occurs, reopen this issue. Thanks a lot.

[1] http://bits.netbeans.org/download/trunk/nightly/latest/