Use-statement problem (annotations)

General discussion on Zend Guard / Optimizer

Use-statement problem (annotations)

Postby lansoweb on Mon Nov 19, 2012 1:35 pm

Hi all!
Just to be sure, during the encoding process, are the use-statement removed?
I'm facing a problem with annotations after encoding my code. I have the following class:

namespace Test\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="test")
*/
class Test
{
}

After encoding i get this error:
The annotation "ORM\Entity" in xxx was never imported. Did you maybe forget to add a "use" statement for this annotation?

Following the code in Doctrine/Common/Annotations/DocParser.php to print the use-statements imported from file, it returns just the namespace. Before encoding it returns them all.

If i change the annotation to:
@Doctrine\ORM\Mapping\Entity
it works as expected.

It happens with any level of code optimization. The same happens with ionCube (sorry to bring it here, just tried).

Is there any "hidden" option to not remove the use-statements (thought code optimization=none do the trick, but no) or will i have to rewrite all my code? Any thoughts?

Thanks,
Leandro
lansoweb
 
Posts: 7
Joined: Tue Jun 01, 2010 1:47 pm

Re: Use-statement problem (annotations)

Postby beeare on Wed Nov 06, 2013 9:51 am

Hello,

we are observing the same behavior with PHP files encoded with Zend Guard 6, but I assume the problem is a result of the optimization routines of Zend Optimizer, not a bug in Zend Guard/Zend Guard Loader. When using fully qualified names (including namespace) for the annotation classes specified in the PHPDoc comments instead of use statements, it works as expected.

This is the options part from our guard.xml:

Code: Select all
   <options>
      <phpVersion value="5.4"/>

      <phpFilesExtensions>
         <extension>php</extension>
         <extension>inc</extension>
         <extension>php3</extension>
         <extension>php4</extension>
         <extension>phtml</extension>
      </phpFilesExtensions>

      <supportShortTags value="true"/>
      <supportASPTags value="false"/>
      <workWithEncodedFilesOnly value="false"/>
      
      <expiration>
         <none/>
      </expiration>

      <licenseType value="none"/>
      <headerInformation>
         <default/>
      </headerInformation>

      <optimizationLevel value="minimal"/>
      <ignoreErrors value="false"/>
      <verbosityLevel value="silent"/>
      <allowEncodedFileModification value="true"/>
      <resolveSymlinks value="false"/>
      
      <securityMethodList>
         <securityMethod name="encodePhpFiles" value="true"/>
         <securityMethod name="removeLineNumbers" value="false"/>
         <securityMethod name="removePhpDoc" value="false"/>
         <securityMethod name="obfuscateVariables" value="false"/>
         <securityMethod name="obfuscateFunctions" value="false"/>
         <securityMethod name="obfuscateClasses" value="false"/>
         <securityMethod name="obfuscatePhpEntities" value="false"/>
      </securityMethodList>

      <ignorePatterns>
         <pattern>.svn</pattern>
      </ignorePatterns>
   </options>


Best regards,
Benjamin Rack
beeare
 
Posts: 6
Joined: Thu Feb 05, 2009 11:51 pm

Re: Use-statement problem (annotations)

Postby glee8045 on Thu Nov 21, 2013 2:33 pm

I really find it difficult to understand this php script. Really needs a tutorial for this.
glee8045
 
Posts: 21
Joined: Wed Jul 31, 2013 5:34 am


Return to Zend Guard / Optimizer

Who is online

Users browsing this forum: No registered users and 3 guests