Overview
Comment: | Outil pour tester les problèmes de compatibilité des plugins avec la version 0.8 |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA1: |
52c3f195faba3f3d93172ea4822c8fcc |
User & Date: | bohwaz on 2017-04-26 12:41:03 |
Other Links: | branch diff | manifest | tags |
Context
2017-04-27
| ||
05:10 | Améliorations permises par passage à PHP 5.6 check-in: 653437ae4f user: bohwaz tags: dev | |
2017-04-26
| ||
12:41 | Outil pour tester les problèmes de compatibilité des plugins avec la version 0.8 check-in: 52c3f195fa user: bohwaz tags: dev | |
2017-03-29
| ||
04:49 | Mise à jour tests pour nouveau comportement check-in: 3a12d5f2a3 user: bohwaz tags: dev | |
Changes
Added tools/plugin_check_0.8.php version [ec4dbeaaed].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | <?php if (empty($argv[1])) { echo sprintf('Usage: %s PLUGIN_DIRECTORY' . PHP_EOL, $argv[0]); exit(1); } assert_options(ASSERT_ACTIVE, true); assert_options(ASSERT_BAIL, true); $dir = rtrim($argv[1], '/\\') . DIRECTORY_SEPARATOR; assert(is_readable($dir), 'Le répertoire du plugin n\'est pas lisible'); assert(is_dir($dir), sprintf('%s n\'est pas un répertoire', $dir)); assert(file_exists($dir . 'garradin_plugin.ini'), sprintf('%s n\'est pas un répertoire de plugin Garradin', $dir)); $dir_iterator = new RecursiveDirectoryIterator(substr($dir, 0, -1), FilesystemIterator::SKIP_DOTS); $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST); $base = realpath($dir); foreach ($iterator as $file) { if ($file->isDir()) { // Skip directories continue; } $source = str_replace($base, '', $file->getRealPath()); if ($file->getExtension() == 'php') { check_php($file->getRealPath(), $source); } elseif ($file->getExtension() == 'tpl') { check_smarty($file->getRealPath(), $source); } } function check_php($file, $source) { static $deprecated_php_functions = [ '->simpleQuerySingle', '->queryFetchAssocKey', '->queryFetchAssoc', '->queryFetch', '->simpleStatementFetchAssocKey', '->simpleStatementFetchAssoc', '->simpleStatementFetch', '->simpleStatement', '->escapeString', '->simpleExec', '->simpleUpdate', '->simpleInsert', ]; $content = file_get_contents($file); foreach ($deprecated_php_functions as $func) { if (stripos($content, $func) !== false) { fputs(STDERR, sprintf('DEPRECATED: %s: la fonction %s est dépréciée et sera supprimée de la prochaine version de Garradin.', $source, $func) . PHP_EOL); } } } function check_smarty($file, $source) { $content = file_get_contents($file); if (preg_match('/\{.*`.*\}/sU', $content)) { fputs(STDERR, sprintf('ERROR: %s: la syntaxe `$variable` est invalide dans Smartyer, utiliser le modifieur |args:$variable', $source) . PHP_EOL); } if (preg_match('/\{\s*(section|php|switch|insert|capture)/', $content, $match)) { fputs(STDERR, sprintf('ERROR: %s: le bloc "%s" est absent dans Smartyer', $source, $match[1]) . PHP_EOL); } if (preg_match('/(\$smarty\.|\$tpl\.|\$templatelite\.)/', $content, $match)) { fputs(STDERR, sprintf('ERROR: %s: les variables "%s" sont absentes dans Smartyer', $source, $match[1]) . PHP_EOL); } if (preg_match('/\{.*\|escape/sU', $content)) { fputs(STDERR, sprintf('SUGGESTION: %s: le modifieur |escape n\'est plus nécessaire (escaping automatique)', $source) . PHP_EOL); } } |