File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ declare(strict_types=1);
1313
1414require_once __DIR__ . '/../vendor/autoload.php ' ;
1515
16- // inspired by https://github.com/mathiasverraes/uptodocs this CLI script will lint
16+ // inspired by https://github.com/mathiasverraes/uptodocs this CLI script lints
1717// the Neon snippets in the Markdown files like README.md
1818
1919$ path = realpath (__DIR__ . '/../ ' );
@@ -48,7 +48,7 @@ foreach ($it as $file) {
4848 } catch (Nette \Neon \Exception $ e ) {
4949 $ success = false ;
5050 $ relPath = str_replace ($ path . DIRECTORY_SEPARATOR , '' , $ file ->getRealPath ());
51- echo " Failed parsing node ". $ nodeCount . " of file " . $ relPath ."\n" ;
51+ echo sprintf ( ' Failed parsing node "%s " of file "%s" ' , $ nodeCount , $ relPath) ."\n" ;
5252 }
5353 }
5454 }
Original file line number Diff line number Diff line change @@ -28,12 +28,19 @@ foreach ($it as $file) {
2828 }
2929
3030 try {
31- $ content = file_get_contents ($ file ->getRealPath ());
32- Nette \Neon \Neon::decode ($ content );
31+ $ neon = Nette \Neon \Neon::decodeFile ($ file ->getRealPath ());
32+ array_walk_recursive ($ neon , function ($ value , $ key ) use ($ success ) {
33+ if (($ key === 'class ' ) && !class_exists ($ value )) {
34+ throw new \RuntimeException (sprintf ('Class "%s" does not exist ' , $ value ));
35+ }
36+ });
3337 } catch (Nette \Neon \Exception $ e ) {
3438 $ success = false ;
3539 $ relPath = str_replace ($ path . DIRECTORY_SEPARATOR , '' , $ file ->getRealPath ());
36- echo "Failed parsing " .$ relPath ."\n" ;
40+ echo sprintf ('Failed parsing file "%s" ' , $ relPath )."\n" ;
41+ } catch (\RuntimeException $ e ) {
42+ $ success = false ;
43+ echo $ e ->getMessage ()."\n" ;
3744 }
3845}
3946
You can’t perform that action at this time.
0 commit comments