Skip to content

Commit

Permalink
solve ticket 211
Browse files Browse the repository at this point in the history
  • Loading branch information
llaville committed Oct 28, 2015
1 parent e4c5d42 commit b871a82
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Bartlett/CompatInfo/Analyser/CompatibilityAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ public function leaveNode(Node $node)

} elseif ($node instanceof Node\Expr\Empty_) {
$this->computePhpFeatureVersions($node);

} elseif ($node instanceof Node\Expr\AssignOp\Pow) {
$this->computePhpFeatureVersions($node);
}
}

Expand Down Expand Up @@ -1174,6 +1177,13 @@ private function computePhpFeatureVersions(Node $node)
$this->updateElementVersion($element, $name, $versions);
$this->updateContextVersion($versions);
}

} elseif ($node instanceof Node\Expr\AssignOp\Pow) {
// Exponentiation
$versions = array('php.min' => '5.6.0');
// update current and parent context
$this->updateElementVersion($element, $name, $versions);
$this->updateContextVersion($versions);
}
}

Expand Down
27 changes: 27 additions & 0 deletions tests/PhpFeaturesIssueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class PhpFeaturesIssueTest extends \PHPUnit_Framework_TestCase
const GH168 = 'gh168.php';
const GH200 = 'gh200.php';
const GH207 = 'gh207.php';
const GH211 = 'gh211.php';

protected static $fixtures;
protected static $analyserId;
Expand Down Expand Up @@ -332,4 +333,30 @@ public function testFeatureGH207()
$versions
);
}

/**
* Regression test for feature GH#211
*
* @link https://github.com/llaville/php-compat-info/issues/211
* PHP 5.6 **-Operator not recognized
* @link http://php.net/manual/en/migration56.new-features.php#migration56.new-features.exponentiation
* @group features
* @return void
*/
public function testFeatureGH211()
{
$dataSource = self::$fixtures . self::GH211;
$analysers = array('compatibility');
$metrics = self::$api->run($dataSource, $analysers);
$versions = $metrics[self::$analyserId]['versions'];

$this->assertEquals(
array(
'php.min' => '5.6.0',
'php.max' => '',
'php.all' => '5.6.0',
),
$versions
);
}
}
4 changes: 4 additions & 0 deletions tests/fixtures/gh211.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
$a = 2;
$a **= 3;
printf("a == %d\n", $a);

0 comments on commit b871a82

Please sign in to comment.