forked from camspiers/galapagos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add visitor to remove second argument from stream_context_create func…
…tion
- Loading branch information
Showing
4 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace galapagos\php54; | ||
|
||
class StreamContext extends \PHPParser_NodeVisitorAbstract { | ||
|
||
public function enterNode(\PHPParser_Node $node) { | ||
|
||
if ($node instanceof \PhpParser\Node\Expr\FuncCall && | ||
$node->name == "stream_context_create" && | ||
count($node->args) == 2) | ||
{ | ||
array_pop($node->args); | ||
return $node; | ||
} | ||
} | ||
|
||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace galapagos\php54; | ||
|
||
use galapagos\AbstractTestCase; | ||
|
||
class StreamContextTest extends AbstractTestCase { | ||
/** @dataProvider provideTests */ | ||
public function testTransform($name, $code, $expected) { | ||
$this->assertSame( | ||
$this->canonicalize($expected), | ||
$this->canonicalize(transform_stream_context($code)), | ||
$name | ||
); | ||
} | ||
|
||
public function provideTests() { | ||
return $this->getTests(__DIR__.'/stream_context', 'test'); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Calling stream_context_create with more than 1 param. | ||
----- | ||
<?php | ||
|
||
$ctx = stream_context_create($options); | ||
$ctx = stream_context_create($options, $default); | ||
----- | ||
<?php | ||
|
||
$ctx = stream_context_create($options); | ||
$ctx = stream_context_create($options); |