Skip to content

Commit

Permalink
Support declare(...) and namespace declaration statements simultaneously
Browse files Browse the repository at this point in the history
  • Loading branch information
asmblah committed May 18, 2023
1 parent c2f829d commit 8a27f10
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1559,6 +1559,8 @@ module.exports = {
'N_INLINE_HTML_STATEMENT_AT_START',
{
oneOf: [
'N_DECLARE_STATEMENT',

'N_SEMICOLON_NAMESPACE_STATEMENT',

// Braced semicolon statements must not be followed by any other statements.
Expand Down
20 changes: 20 additions & 0 deletions test/integration/statements/declareTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,26 @@ describe('PHP Parser grammar "declare" statement integration', function () {
}]
}]
}
},
'declaring strict_types as on and a namespace in the same module': {
code: '<?php declare(strict_types=1); namespace My\\Stuff;',
expectedAST: {
name: 'N_PROGRAM',
statements: [{
name: 'N_DECLARE_STATEMENT',
directives: [{
name: 'N_STRICT_TYPES_DIRECTIVE',
value: {
name: 'N_INTEGER',
number: '1'
}
}]
}, {
name: 'N_NAMESPACE_STATEMENT',
namespace: 'My\\Stuff',
statements: []
}]
}
}
}, function (scenario, description) {
describe(description, function () {
Expand Down

0 comments on commit 8a27f10

Please sign in to comment.