dev-master
9999999-devCheck syntax for some programming languages
GPLv3
The Requires
by Anton Korniychuk
Check syntax for some programming languages
Check code in some programming languages for syntax errors., (*1)
Currently supported languages: - php - sql - json, (*2)
Feel free to let me know what else you want added via:, (*3)
The preferred way to install this extension is through composer., (*4)
Either run, (*5)
$ php composer.phar require ancor/yii2-code-syntax
or add, (*6)
"ancor/yii2-code-syntax": "dev-master"
to the require
section of your composer.json
file., (*7)
Validation occurs as follows:, (*8)
EXPLAIN
use ancor\codeSyntax\SqlSyntaxValidator; public function rules() { return [ [['sqlCodeField'], SqlSyntaxValidator::className()], ]; }
use ancor\codeSyntax\SqlSyntaxValidator; public function rules() { return [ [ ['sqlCodeField'], SqlSyntaxValidator::className(), // 'wrapper' => '...{{part}}...', // 'makeSql' => function($validator, $partSql) { ... } 'message' => 'Field {attribute} is invalid', ], ]; }
Warning: this validator use php cli. And if php has been not added to $PATH, validator will not work., (*9)
use ancor\codeSyntax\PhpSyntaxValidator; public function rules() { return [ [['phpCodeField'], PhpSyntaxValidator::className()], ]; }
use ancor\codeSyntax\PhpSyntaxValidator; public function rules() { return [ [ ['phpCodeField'], PhpSyntaxValidator::className(), 'isWrapPhp' => true, 'message' => 'Field {attribute} is invalid', ], ]; }
Warning: this validator use json_decode()
php function. And depends on php-json extension., (*10)
use ancor\codeSyntax\JsonSyntaxValidator; public function rules() { return [ [['jsonCodeField'], JsonSyntaxValidator::className()], ]; }
use ancor\codeSyntax\JsonSyntaxValidator; public function rules() { return [ [ ['jsonCodeField'], JsonSyntaxValidator::className(), 'message' => 'Field {attribute} has invalid json. Code: {errCode}, Msg: {errMsg}', ], ]; }
Check syntax for some programming languages
GPLv3