Skip to content

Commit a2dbe3f

Browse files
committed
Regression test
1 parent 6dae756 commit a2dbe3f

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2817,4 +2817,15 @@ public function testConstantParameterCheck(): void
28172817
]);
28182818
}
28192819

2820+
#[RequiresPhp('>= 8.0')]
2821+
public function testBug12850(): void
2822+
{
2823+
$this->analyse([__DIR__ . '/data/bug-12850.php'], [
2824+
[
2825+
'Constants LOCK_EX, LOCK_SH cannot be combined for parameter #2 $operation of function flock.',
2826+
9,
2827+
],
2828+
]);
2829+
}
2830+
28202831
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug12850;
4+
5+
$handle = fopen(__FILE__, 'r');
6+
assert($handle !== false);
7+
8+
// exclusive group violation - LOCK_SH and LOCK_EX cannot be combined
9+
flock($handle, LOCK_EX|LOCK_SH);
10+
11+
// ok - single lock type
12+
flock($handle, LOCK_EX);
13+
flock($handle, LOCK_SH);
14+
flock($handle, LOCK_UN);
15+
16+
// ok - lock type with LOCK_NB modifier
17+
flock($handle, LOCK_EX|LOCK_NB);
18+
flock($handle, LOCK_SH|LOCK_NB);

0 commit comments

Comments
 (0)