I started off by trying to include every file in a GitHub project. My purpose is to call get_declared_classes() after that as a form of reflection so I can learn what classes are declared in the project. Never did I expect that I would run into this problem which I have no solution for after much research and testing. Please help.
The project I am using: https://github.com/farafiri/PHP-parsing-tool
I downloaded it into a folder. Wrote this code:
$toparse = shell_exec("find '/Users/user/Documents/PHP-parsing-tool-master/src' -iname '*.php' 2> /dev/null");
$filenames = explode("\n", $toparse);
//d() is a custom function that acts like var_dump.
d($filenames);
$filenames dumps (please pardon the custom format that comes with d(). Basically $filenames is an array of 77 elements with each element a string representing paths of each file in the Github project):
array (77) [
0 => string (77) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/RuleCondition.php"
1 => string (76) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/SequenceItem.php"
2 => string (71) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/Integer.php"
3 => string (70) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/Series.php"
4 => string (68) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/Time.php"
5 => string (69) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/Regex.php"
6 => string (105) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/ItemRestrictions/ItemRestrictionInterface.php"
7 => string (98) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/ItemRestrictions/ItemRestrictionOr.php"
8 => string (99) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/ItemRestrictions/ItemRestrictionAnd.php"
9 => string (91) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/ItemRestrictions/FollowedBy.php"
10 => string (83) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/ItemRestrictions/Is.php"
11 => string (88) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/ItemRestrictions/Contain.php"
12 => string (99) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/ItemRestrictions/ItemRestrictionNot.php"
13 => string (72) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/TextNode.php"
14 => string (86) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/WhiteCharactersContext.php"
15 => string (82) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/ExtensionInterface.php"
16 => string (70) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/Choice.php"
17 => string (80) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/ItemRestrictions.php"
18 => string (68) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/Base.php"
19 => string (73) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/Lookahead.php"
20 => string (80) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/ParametrizedNode.php"
21 => string (71) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/Unorder.php"
22 => string (68) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/Text.php"
23 => string (76) "/Users/user/Documents/PHP-parsing-tool-master/src/Extension/StringObject.php"
24 => string (70) "/Users/user/Documents/PHP-parsing-tool-master/src/ParsingException.php"
25 => string (60) "/Users/user/Documents/PHP-parsing-tool-master/src/Parser.php"
26 => string (64) "/Users/user/Documents/PHP-parsing-tool-master/src/Util/Regex.php"
27 => string (64) "/Users/user/Documents/PHP-parsing-tool-master/src/Util/Error.php"
28 => string (75) "/Users/user/Documents/PHP-parsing-tool-master/src/SyntaxTreeNode/Series.php"
29 => string (85) "/Users/user/Documents/PHP-parsing-tool-master/src/SyntaxTreeNode/PredefinedString.php"
30 => string (75) "/Users/user/Documents/PHP-parsing-tool-master/src/SyntaxTreeNode/Branch.php"
31 => string (73) "/Users/user/Documents/PHP-parsing-tool-master/src/SyntaxTreeNode/Base.php"
32 => string (76) "/Users/user/Documents/PHP-parsing-tool-master/src/SyntaxTreeNode/Numeric.php"
33 => string (73) "/Users/user/Documents/PHP-parsing-tool-master/src/SyntaxTreeNode/Root.php"
34 => string (73) "/Users/user/Documents/PHP-parsing-tool-master/src/SyntaxTreeNode/Leaf.php"
35 => string (77) "/Users/user/Documents/PHP-parsing-tool-master/src/SyntaxTreeNode/LeafTime.php"
36 => string (71) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNodeCopier.php"
37 => string (72) "/Users/user/Documents/PHP-parsing-tool-master/src/Examples/CSVParser.php"
38 => string (88) "/Users/user/Documents/PHP-parsing-tool-master/src/Examples/YamlLikeIndentationParser.php"
39 => string (89) "/Users/user/Documents/PHP-parsing-tool-master/src/Examples/ArithmeticExpressionParser.php"
40 => string (73) "/Users/user/Documents/PHP-parsing-tool-master/src/Examples/JSONParser.php"
41 => string (75) "/Users/user/Documents/PHP-parsing-tool-master/src/Examples/JSONFormater.php"
42 => string (86) "/Users/user/Documents/PHP-parsing-tool-master/src/Examples/BooleanExpressionParser.php"
43 => string (74) "/Users/user/Documents/PHP-parsing-tool-master/src/ParserAwareInterface.php"
44 => string (63) "/Users/user/Documents/PHP-parsing-tool-master/src/Exception.php"
45 => string (72) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/Series.php"
46 => string (75) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/PEGBranch.php"
47 => string (96) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/WhitespaceNegativeContextCheck.php"
48 => string (81) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/BranchInterface.php"
49 => string (74) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/BaseNode.php"
50 => string (82) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/PredefinedString.php"
51 => string (79) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/LeafInterface.php"
52 => string (71) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/Regex.php"
53 => string (86) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/BranchExtraCondition.php"
54 => string (79) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/BranchFactory.php"
55 => string (79) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/ParameterNode.php"
56 => string (73) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/AnyText.php"
57 => string (72) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/Branch.php"
58 => string (72) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/Choice.php"
59 => string (82) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/ItemRestrictions.php"
60 => string (75) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/Decorator.php"
61 => string (73) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/Numeric.php"
62 => string (75) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/Lookahead.php"
63 => string (82) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/ParametrizedNode.php"
64 => string (87) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/BranchStringCondition.php"
65 => string (79) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/NodeInterface.php"
66 => string (88) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/WhitespaceContextCheck.php"
67 => string (88) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/PredefinedSimpleString.php"
68 => string (77) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/NaiveBranch.php"
69 => string (73) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/Unorder.php"
70 => string (81) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/BranchDecorator.php"
71 => string (74) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/LeafTime.php"
72 => string (70) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/Text.php"
73 => string (71) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/TextS.php"
74 => string (85) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarNode/ErrorTrackDecorator.php"
75 => string (67) "/Users/user/Documents/PHP-parsing-tool-master/src/GrammarParser.php"
76 => string (0) ""
]
Then:
foreach ($filenames as $n=>$f) {
d($f);
include $f;
d($f);
}
The foreach loop has no issue up till the element with index 15. The script terminates when including that file. I know this because the d() function before the include was executed, but not the d() function after the include. I ran the script on the command line, and used PHP7.2.10, from MAMP 4, on macOS 10.13.6.
This is the full contents of that file:
<?php
namespace ParserGenerator\Extension;
echo "hello in interface";
interface ExtensionInterface
{
function extendGrammar($grammarGrammar);
function modifyBranches($grammar, $parsedGrammar, $grammarParser, $options);
function createGrammarBranch($grammar, $grammarBranch, $grammarParser, $options);
function fillGrammarBranch($grammar, $grammarBranch, $grammarParser, $options);
function buildSequenceItem(&$grammar, $sequenceItem, $grammarParser, $options);
function buildSequence($grammar, $rule, $grammarParser, $options);
}
echo "hello in interface 2";
The script terminated after "hello in interface" was echoed. "hello in interface 2" was never echoed.
The strange thing is also that even though my php.ini file has already been set to error_reporting=E_ALL and display_errors=On, no information on the script termination whatsoever was dumped to my terminal. There's no parse error, fatal error etc.
What is the problem and how do I make the script execute all the way to the end? Apologies, but am I missing something on namespaces and interfaces?
Aucun commentaire:
Enregistrer un commentaire