Skip to content

Instantly share code, notes, and snippets.

@Lewiscowles1986
Last active August 24, 2017 19:20
Show Gist options
  • Save Lewiscowles1986/cb090abf5f9f797bdeab7346f38c300b to your computer and use it in GitHub Desktop.
Save Lewiscowles1986/cb090abf5f9f797bdeab7346f38c300b to your computer and use it in GitHub Desktop.
Get PHP Software Project Functions

PHP Function Signature Dump

This project is part of an idea for using automated unattended shell scripts to track API's of Libre & OpenSource projects

It's a total pain in the ass to have a method signature change on you, and it would be lovely if there was some way to automatically update or notify source code when API's change (Imagine the time you could not be spending trawling docs)

The core concept is this

  • Projects:
    ProjectPK, RepoURL, Name, Flags

  • Version:
    VersionPK, Name, Major, Minor, Patch, Build, ReleaseDate, ProjectPK

  • Methods:
    MethodPK, Name, Line, Flags, StructPK, ProjectPK, NamespacePK, FilePK, VersionPK

  • Namespaces:
    NamespacePK, Name, ProjectPK, VersionPK

  • Files:
    FilePK, Path, LanguagePK, ProjectPK, VersionPK

  • Structures:
    StructPK, Name, Flags, VersionPK

  • MethodArguments:
    MethodArgumentPK, Name, Type, MethodPK

  • Dependency:
    DepPK, Name, ProjectPK, VersionPK

Obviously what is here right now is not the above, but what a lovely concept.

LanguagePK is a weird one, but I'm thinking it's just another projectPK

Metadata isn't fully fleshed out and Flags would likely be an indexed bitfield, so you can search multiple properties at once

final class ProjectVersionData {
  ProjectVersion(string Project, string Version)
  getVersion()
  getProjectPK()
}
Interface ReadProjectData {
    getFiles()
    getMethods()
    getStructures()
    getDependencies()
    getNamespacesDefined()
    getFileData(PK filePK)
    getMethodData(PK MethodPK)
    getStructureData(PK StructPK)
}
Interface WriteProjectData {
    addFiles(FileData[] Files)
    addMethods(MethodData[] Method)
    addStructures(StructureData[] Structure)
    addDependencies(string[] Dependencies)
    addNamespacesDefined(NamespaceData[] NS)
}
#!/bin/bash
//
// SEARCH FOR PHP FUNCTIONS
//
SEARCH_PATTERN="((final\s+)?((public|private|protected)\s+)?(static\s+)?function\s+[a-zA-Z0-9_]+\s*?[\(].*[\)])"
SEARCH_PATH="~/projects/wordpress/svn/trunk/src"
grep -R --include=*.php -P $SEARCH_PATTERN --line-number $SEARCH_PATH > functions.lst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment