PHP wordfile generator

PHP wordfile generator

15
Basic UserBasic User
15

    Jun 18, 2007#1

    The PHP project publish full API documentation, and even provide a script that turns that documentation into a function list. You can get that here (revision 1.7) or here (revision 1.9).

    Combine that with a small bit of VBS I wrote:

    Code: Select all

    Const ForReading = 1, ForWriting = 2, ForAppending = 8
    Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objInStream = objFSO.OpenTextFile("functions.txt")
    If Not objFSO.FileExists("wordfile.stub.txt") Then
      objFSO.CreateTextFile "wordfile.stub.txt"
    End If
    Set objOut = objFSO.GetFile("wordfile.stub.txt")
    Set objOutStream = objOut.OpenAsTextStream(ForWriting)
    
    strLetter = "a"
    strThisLine = ""
    
    While Not objInStream.AtEndOfStream
      strLine = objInStream.ReadLine
      objOutStream.Write strLine & " "
      strThisLine = strThisLine & strLine & " "
      If LCase(Left(strLine, 1)) <> strLetter Then
        objOutStream.Write vbCrLf
        strLetter = Lcase(Left(strLine, 1))
        strThisLine = ""
      ElseIf Len(strThisLine) > 150 Then
        objOutStream.Write vbCrLf
        strThisLine = ""
      End If
    Wend
    
    objOutStream.Close
    objInStream.Close
      
      MsgBox "DONE"
    
    And you can easily generate a completely up-to-date function list for a given version of PHP to make your PHP wordfile a lot more complete than any available on the UE site.

    6,681583
    Grand MasterGrand Master
    6,681583

      Jun 18, 2007#2

      Following should be done after the wordfile is created:
      1. Run my macro TestForDuplicate and correct the list if necessary.
      2. Run my macro TestForInvalid and correct the list if necessary.
      3. Because PHP is partly case-sensitive and partly not, delete keyword Nocase in the first line, run my macro SortLanguage and insert again Nocase.
      For details about my macros look at the ultimate syntax highlighting tools
      Best regards from an UC/UE/UES for Windows user from Austria

      15
      Basic UserBasic User
      15

        Jun 18, 2007#3

        1. There are no duplicates. The list was de-duplicated before the lang file was created.
        2. I'll run that.
        3. They are case sorted.
        I'm not the anti-christ, I just do his work.

        2362
        MasterMaster
        2362

          Mar 03, 2012#4

          THEMike wrote:The PHP project publish full API documentation, and even provide a script that turns that documentation into a function list. You can get that here.
          That link isn't valid any longer. Is there a script anywhere that can still turn that documentation into a function list? I'd like to update my wordfile to PHP 5.4 if possible.

          I'd also like to obtain a list of all deprecated and/or discontinued functions, so that I can place them in a separate color group and mark them red and underline them, so I'll be able to see quickly what not to use should I accidentally attempt to use one of those.

          Anyone know a good source for that kind of thing? Trying to ferret it all out manually could take weeks that I just don't have.

          6,681583
          Grand MasterGrand Master
          6,681583

            Mar 03, 2012#5

            I found 2 newer versions of the PHP script and replaced the link in initial post (for revision 1.5) by links to the revision 1.7 and 1.9.

            2362
            MasterMaster
            2362

              Mar 03, 2012#6

              Mofi,

              Thank you for the updated links. Both files, however, use a deprecated functions in the script causing it not to work properly in PHP 5.3+. Also, the newer file has a typo in a variable name. The variable was assigned in one line, then when attempted to use it in the next line, it was misspelled, causing another error.

              I was able to fix it, but it pulls up all the deprecated functions, alias functions, and everything into one large list.

              Granted, this is suitable for most people. However, now that we have the ability to create more than 8 color groups, I have it in mind to get those separated so that I don't accidentally use a function that has been deprecated in a later version. My hosting provider for my web server runs PHP 5.2 and I run on 5.3 at home, and now 5.4 has come out, which I will be upgrading to as well. I'll need to visually see when a function I have used in 5.2 has been deprecated, so that I can avoid it and find an alternative so that my scripts will continue to run should my hosting provider finally make the upgrade.

              Therefore, I plan to add additional color groups as follows:

              Code: Select all

              /C1"Control Structures"
              /C2"Tags"
              /C3"Variables"
              /C4"Operators"
              /C5"Built-in Functions"
              /C6"Built-in Constants"
              /C7"Built-in Variables"
              /C8"Keywords"
              /C9"Wrappers"
              /C10"Magic Constants"  (I want these highlighted separately)
              /C11"Function Aliases" (These are discouraged, so again, I want them separated)
              /C12"Deprecated Functions" (To be colored red and underlined.)
              /C13"Deprecated Constants"
              /C14"Deprecated Variables"
              I have noticed that /C8"Keywords" currently contains a lot of repetition from other groups, but with the difference of using the $ in front of them. I plan to fix that issue as well.

              Thanks to that script, I should be able to see how to rewrite it. However, it will also have to be expanded to handle setting up the:
              wrappers
              built-in variables
              magic constants
              deprecated functions
              built-in constants
              deprecated variables
              deprecated constants
              function aliases
              control structures.

              I'm afraid that won't be as small of a task as what was available from the previous script. As I am about to head out of town, my time is limited and I have so many projects on my burners that I'm afraid of a fire at this point. :)

              Perhaps if I can get this done, I can get a new, proper PHP wordfile made that supports up to PHP 5.4 (current).

              Much of PHP is case insensitive, but there is also portions of PHP that IS case sensitive, such as using magic constants. Since it would be in everyone's best interest to start treating PHP case sensitive because of such things, I have already removed the Nocase from my PHP file, so that when I redo this it can be done properly.