for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Dazzle\Filesystem\Driver\Flag;
class FlagPermissionResolver extends FlagResolverAbstract implements FlagResolverInterface
{
/**
* @var int|null
*/
const DEFAULT_FLAG = null;
* @var string
private $scope = '';
* @var array
private $mapping = [
'user' => [
'w' => 128,
'x' => 64,
'r' => 256,
],
'group' => [
'w' => 16,
'x' => 8,
'r' => 32,
'universe' => [
'w' => 2,
'x' => 1,
'r' => 4,
];
* @override
* @inheritDoc
public function resolve($flag, $flags = null, $mapping = null)
$resultFlags = 0;
$start = 0;
foreach ([ 'universe', 'group', 'user' ] as $scope)
$this->currentScope = $scope;
currentScope
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
$start -= 3;
$chunk = substr($flag, $start, 3);
$resultFlags |= parent::resolve($chunk, $flags, $mapping);
}
return $resultFlags;
protected function getFlags()
return static::DEFAULT_FLAG;
protected function getMapping()
return $this->mapping[$this->scope];
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: