comparison vendor/nikic/php-parser/test/PhpParser/Parser/MultipleTest.php @ 13:5fb285c0d0e3

Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've been lucky to get away with this so far, as we don't support self-registration which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5 was vulnerable to.
author Chris Cannam
date Mon, 23 Apr 2018 09:33:26 +0100
parents 4c8ae668cc8c
children 129ea1e6d783
comparison
equal deleted inserted replaced
12:7a779792577d 13:5fb285c0d0e3
1 <?php 1 <?php declare(strict_types=1);
2 2
3 namespace PhpParser\Parser; 3 namespace PhpParser\Parser;
4 4
5 use PhpParser\Error; 5 use PhpParser\Error;
6 use PhpParser\Lexer; 6 use PhpParser\Lexer;
9 use PhpParser\Node\Stmt; 9 use PhpParser\Node\Stmt;
10 use PhpParser\ParserTest; 10 use PhpParser\ParserTest;
11 11
12 require_once __DIR__ . '/../ParserTest.php'; 12 require_once __DIR__ . '/../ParserTest.php';
13 13
14 class MultipleTest extends ParserTest { 14 class MultipleTest extends ParserTest
15 {
15 // This provider is for the generic parser tests, just pick an arbitrary order here 16 // This provider is for the generic parser tests, just pick an arbitrary order here
16 protected function getParser(Lexer $lexer) { 17 protected function getParser(Lexer $lexer) {
17 return new Multiple([new Php5($lexer), new Php7($lexer)]); 18 return new Multiple([new Php5($lexer), new Php7($lexer)]);
18 } 19 }
19 20
57 [ 58 [
58 // Different meaning (PHP 5) 59 // Different meaning (PHP 5)
59 '<?php $$a[0];', 60 '<?php $$a[0];',
60 $this->getPrefer5(), 61 $this->getPrefer5(),
61 [ 62 [
62 new Expr\Variable( 63 new Stmt\Expression(new Expr\Variable(
63 new Expr\ArrayDimFetch(new Expr\Variable('a'), LNumber::fromString('0')) 64 new Expr\ArrayDimFetch(new Expr\Variable('a'), LNumber::fromString('0'))
64 ) 65 ))
65 ] 66 ]
66 ], 67 ],
67 [ 68 [
68 // Different meaning (PHP 7) 69 // Different meaning (PHP 7)
69 '<?php $$a[0];', 70 '<?php $$a[0];',
70 $this->getPrefer7(), 71 $this->getPrefer7(),
71 [ 72 [
72 new Expr\ArrayDimFetch( 73 new Stmt\Expression(new Expr\ArrayDimFetch(
73 new Expr\Variable(new Expr\Variable('a')), LNumber::fromString('0') 74 new Expr\Variable(new Expr\Variable('a')), LNumber::fromString('0')
74 ) 75 ))
75 ] 76 ]
76 ], 77 ],
77 ]; 78 ];
78 } 79 }
79 80
80 public function testThrownError() { 81 public function testThrownError() {
81 $this->setExpectedException('PhpParser\Error', 'FAIL A'); 82 $this->expectException(Error::class);
83 $this->expectExceptionMessage('FAIL A');
82 84
83 $parserA = $this->getMockBuilder('PhpParser\Parser')->getMock(); 85 $parserA = $this->getMockBuilder(\PhpParser\Parser::class)->getMock();
84 $parserA->expects($this->at(0)) 86 $parserA->expects($this->at(0))
85 ->method('parse')->will($this->throwException(new Error('FAIL A'))); 87 ->method('parse')->will($this->throwException(new Error('FAIL A')));
86 88
87 $parserB = $this->getMockBuilder('PhpParser\Parser')->getMock(); 89 $parserB = $this->getMockBuilder(\PhpParser\Parser::class)->getMock();
88 $parserB->expects($this->at(0)) 90 $parserB->expects($this->at(0))
89 ->method('parse')->will($this->throwException(new Error('FAIL B'))); 91 ->method('parse')->will($this->throwException(new Error('FAIL B')));
90 92
91 $parser = new Multiple([$parserA, $parserB]); 93 $parser = new Multiple([$parserA, $parserB]);
92 $parser->parse('dummy'); 94 $parser->parse('dummy');