Skip to content

Instantly share code, notes, and snippets.

@surfmuggle
Last active September 2, 2019 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save surfmuggle/0c197b8ae8e231d4fdf4a879a60a186d to your computer and use it in GitHub Desktop.
Save surfmuggle/0c197b8ae8e231d4fdf4a879a60a186d to your computer and use it in GitHub Desktop.
PHP Static analysis with noverify exe
2019/09/03 01:20:24 -exclude-checks arraySyntax, PHPDocC:\Dev\PHP\ResourceSpace_9_0_13357\include
2019/09/03 01:20:25 error using cmnd.CombinedOutput()
2019/09/03 01:20:25 exit status 2
2019/09/03 01:20:25 what does this mean?
2019/09/03 01:20:25 2019/09/03 01:20:24.418022 Started
2019/09/03 01:20:24.931815 Indexing [C:\Dev\PHP\ResourceSpace_9_0_13357\include]
2019/09/03 01:20:25.243995 Linting
<critical> INFO phpdocLint: PHPDoc is incorrect: use int type instead of integer on line 4 at C:\Dev\PHP\ResourceSpace_9_0_13357\include\annotation_functions.php:9
function getAnnotation($ref)
^^^^^^^^^^^^^
MAYBE arraySyntax: Use of old array syntax (use short form instead) at C:\Dev\PHP\ResourceSpace_9_0_13357\include\annotation_functions.php:13
return array();
^^^^^^^
.....
package main
import (
"bytes"
"log"
"os"
"os/exec"
)
func logStuff(s string) {
f, err := os.OpenFile("testlogfile", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
log.Fatalf("error opening file: %v", err)
}
defer f.Close()
log.SetOutput(f)
log.Println(s)
}
// https://stackoverflow.com/questions/25190971/golang-copy-exec-output-to-log
func main() {
// C:\Dev\PHP\ResourceSpace_9_0_13357\include
// pathToCache := "-cache-dir=C:\\Users\\Devmuggle\\/tmp/cache/noverify"
pathToCode := "C:\\Dev\\PHP\\ResourceSpace_9_0_13357\\include"
// args := []string{"-exclude-checks arraySyntax, PHPDoc", pathToCode}
// args := strings.Join([]string{pathToCache, pathToCode}, " ")
// log.Println(args)
// args := strings.Join(arg, " ");
// https://golang.org/pkg/os/exec/#Command
// cmnd := exec.Command("noverify.exe", args...)
cmnd := exec.Command("noverify.exe", pathToCode)
//cmnd.Run() // and wait
// cmnd.Start()
b, err := cmnd.CombinedOutput()
if err != nil {
logStuff("error using cmnd.CombinedOutput()")
// log.Fatal(err)
logStuff(err.Error())
logStuff("what does this mean?")
}
// n := int64(bytes.IndexByte(b, 0))
var myslice []byte
n := bytes.Count(b, myslice)
s := string(b[:n])
// logStuff(strconv.Itoa(n))
logStuff(s)
// log.Println("log")
// log.Output
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment