Menu

#9 PHPCS is failing within NetBeans 7.1 (Beta)

alpha
closed
5
2014-08-21
2011-11-22
Anonymous
No

I completely realize that I'm submitting a bug about an Alpha plugin not working with a Beta product, but at the risk of being "that guy," I'm going to go ahead anyway. ;0

My system is perfectly configured for phpcs command line usage--which is what I've been doing for quite a while. When I saw this plugin, I immediately downloaded it, and subsequently found that it doesn't work correctly on NB 7.1. PHPMD works perfectly, btw.

SO... HERE IS THE ERROR
|
|
\ /

When attempting to auto-highlight tasks after a default plugin install, NB reports the following error:

Codesniffer (Errors) Configuration Exception, check Settings! See IDE LOG (org.jmgl.php.codesniffer.BatchInterface) org.xml.sax.SAXParseException Keyword.php /Applications/MAMP/vh/docroots/Punchkick - Server Upgrades/trunk/bin/pki/module-sms/frapi/src/frapi/custom/Action/Keyword.php:1

INFO [org.jmgl.php.codesniffer.BatchInterface]: Running/usr/local/bin/phpcs /Applications/MAMP/vh/docroots/frapi/src/frapi/custom/Action/Generic.php
INFO [org.jmgl.php.codesniffer.BatchInterface]: parsing results...
[Fatal Error] :1:1: Content is not allowed in prolog.
WARNING [org.jmgl.php.codesniffer.BatchInterface]: org.xml.sax.SAXParseException: Content is not allowed in prolog.

Per this article, I think this may be an encoding issue:

http://www.bennadel.com/blog/1206-Content-Is-Not-Allowed-In-Prolog-ColdFusion-XML-And-The-Byte-Order-Mark-BOM-.htm

Here is all of my system info for happy debugging:

Product Version: NetBeans IDE 7.1 Beta (Build 201109252201)
Java: 1.6.0_29; Java HotSpot(TM) 64-Bit Server VM 20.4-b02-402
System: Mac OS X version 10.7.2 running on x86_64; MacRoman; en_US (nb)
User directory: /Users/admin/.netbeans/7.1beta
Cache directory: /Users/admin/.netbeans/7.1beta/var/cache

A little bash output for good measure

admin@MacBook-Pro{~}:which phpcs
/usr/local/bin/phpcs
admin@MacBook-Pro{~}:phpcs --version
PHP_CodeSniffer version 1.3.0 (stable) by Squiz Pty Ltd. (http://www.squiz.net)

Discussion

  • Jens Radtke

    Jens Radtke - 2011-11-22

    hehe, alpha on beta is great but this one seems to be an exception related to another problem.
    At this time most of "content in prolog" errors are caused by wrong php.ini settings, in detail please check if you have an date.timezone entry.
    If you have so, please try to run phpcs on bash for some php file in xml mode and check what kind of content is present in xml prolog.

     
  • Jens Radtke

    Jens Radtke - 2011-11-22

    If you still get this error, please try the new version.
    The new one will show the cmd output in case of errors in ide log.
    Hope this helps, if not please report the new log.

     
  • Ryan Unger

    Ryan Unger - 2011-11-23

    THANKS SO MUCH for your quick replies. :)

    I checked and I do have a date.timezone entry.

    I ran phpcs on a file and here was the output (note that I removed sensitive directory names...)

    phpcs --encoding=utf-8 --extensions=php --standard=PKI --tab-width=2 --report-width=120 --report=xml --error-severity=1 --warning-severity=8 Keyword.php

    PHP CODE SNIFFER REPORT SUMMARY

    FILE ERRORS WARNINGS

    .../Action/Keyword.php 2 0

    A TOTAL OF 2 ERROR(S) AND 0 WARNING(S) WERE FOUND IN 1 FILE(S)

    Time: 0 seconds, Memory: 5.50Mb

    <phpcs version="1.3.0"> <file name="/Applications/MAMP/vh/docroots/Action/Keyword.php" errors="2" warnings="0"> <error line="15" column="1" source="Squiz.Classes.ValidClassName.NotCamelCaps" severity="5">Class name "Action_Keyword" is not in camel caps format</error> <error line="101" column="5" source="Zend.NamingConventions.ValidVariableName.NotCamelCaps" severity="5">Variable "code_id" is not in valid camel caps format</error> </file> </phpcs>

    I'm going to test the new build and report what else I find.

     
  • Ryan Unger

    Ryan Unger - 2011-11-23

    Hi again. I uninstalled the last version of the plugin and reinstalled the new one. I was still getting an error at first, but this time with more debugger info which helped A TON...

    I found the root cause was my phpcs config settings on my system.

    $bash:phpcs --config-show
    Array
    (
    [encoding] => utf-8
    [tab-width] => 4
    [error-severity] => 1
    [warning-severity] => 8
    [standard] => Zend
    [report_format] => summary
    [report_width] => 120
    )

    I suspected the issue may be with the summary that is printed prior to the XML output--and it was!! :)

    I've included my output below for your reference, but perhaps the "take away" is just to add some note for users in an FAQ to double check that there is not a "report_format" config setting in place.

    p.s. My new config settings are (where PKI is my own custom set of phpcs settings)
    Array
    (
    [tab-width] => 2
    [error-severity] => 1
    [warning-severity] => 8
    [report_width] => 120
    [standard] => PKI
    [encoding] => utf-8
    )

    THANKS AGAIN for recompiling the plugin with the added debugger info!!!!

    WARNING [org.openide.filesystems.Ordering]: Found same position 600 for both TaskList/Groups/issue.instance and TaskList/Groups/phpCS-Warning.instance
    WARNING [org.netbeans.TopSecurityManager]: use of system property netbeans.home has been obsoleted in favor of InstalledFileLocator at org.netbeans.modules.bugzilla.BugzillaConfig.getNBConfigPath(BugzillaConfig.java:426)
    INFO [org.jmgl.php.CachedProvider]: new cached provider for org.jmgl.php.codesniffer.BatchInterface created
    INFO [org.jmgl.php.CachedProvider]: new cached provider for org.jmgl.php.messdetector.BatchInterface created
    INFO [org.jmgl.php.CachedProvider]: Loaded cached Tasks for 0 Files!
    INFO [org.jmgl.php.CachedProvider]: Loaded cached Tasks for 2 Files!
    INFO [org.jmgl.php.SettingsResolver]: No own configuration found under /Users/ryanunger/NetBeansProjects/PKI :: Module-SMS - Frapi/nbproject/codesniffer.properties
    INFO [org.jmgl.php.codesniffer.BatchInterface]: Running/usr/local/bin/phpcs /Applications/MAMP/vh/docroots/Action/Generic.php
    INFO [org.jmgl.php.codesniffer.BatchInterface]: parsing results...
    [Fatal Error] :1:1: Content is not allowed in prolog.
    WARNING [org.jmgl.php.codesniffer.BatchInterface]: org.xml.sax.SAXParseException: Content is not allowed in prolog.
    WARNING [org.jmgl.php.codesniffer.BatchInterface]: Given output was: "PHP CODE SNIFFER REPORT SUMMARY------------------------------------------------------------------------------------------------------------------------FILE ERRORS WARNINGS------------------------------------------------------------------------------------------------------------------------...oots/Action/Generic.php 4 0------------------------------------------------------------------------------------------------------------------------A TOTAL OF 4 ERROR(S) AND 0 WARNING(S) WERE FOUND IN 1 FILE(S)------------------------------------------------------------------------------------------------------------------------Time: 0 seconds, Memory: 3.50Mb<?xml version="1.0" encoding="UTF-8"?><phpcs version="1.3.0"> <file name="/Applications/MAMP/vh/docroots/Action/Generic.php" errors="4" warnings="0"> <error line="22" column="13" source="Zend.NamingConventions.ValidVariableName.PrivateNoUnderscore" severity="5">Protected member variable "uid" must contain a leading underscore</error> <error line="29" column="13" source="Zend.NamingConventions.ValidVariableName.PrivateNoUnderscore" severity="5">Protected member variable "requiredParams" must contain a leading underscore</error> <error line="36" column="13" source="Zend.NamingConventions.ValidVariableName.PrivateNoUnderscore" severity="5">Protected member variable "data" must contain a leading underscore</error> <error line="60" column="5" source="PEAR.ControlStructures.ControlSignature" severity="5">Expected "if (...) {\n"; found "if (...)\n {\n"</error> </file></phpcs>"

     
  • Jens Radtke

    Jens Radtke - 2011-11-23

    Ah, this seems to be a kind of "bug" of phpcs itself, there should be no non-xml output if report format is xml :o)

     

Log in to post a comment.