Phan\Language\Element\Flags::bitVectorWithState PHP Method

bitVectorWithState() public static method

Either enable or disable the given flag on the given bit vector.
public static bitVectorWithState ( integer $bit_vector, integer $flag, boolean $value ) : integer
$bit_vector integer The bit vector we're operating on
$flag integer The flag we're setting on the bit vector such as Flags::IS_DEPRECATED.
$value boolean True to or the flag in, false to & the bit vector with the flags negation
return integer A new bit vector with the given flag set or unset
    public static function bitVectorWithState(int $bit_vector, int $flag, bool $value) : int
    {
        $bit_vector = $value ? $bit_vector | $flag : $bit_vector & ~$flag;
        return $bit_vector;
    }

Usage Example

Example #1
0
 /**
  * Returns the Parameter in the form expected by a caller.
  *
  * If this parameter is variadic (e.g. `DateTime ...$args`), then this
  * would return a parameter with the type of the elements (e.g. `DateTime`)
  *
  * If this parameter is not variadic, returns $this.
  *
  * @return static (usually $this)
  */
 public function asNonVariadic()
 {
     if (!$this->isVariadic()) {
         return $this;
     }
     // TODO: Is it possible to cache this while maintaining correctness? PostOrderAnalysisVisitor clones the value to avoid it being reused.
     //
     // Also, figure out if the cloning still working correctly after this PR for fixing variadic args.
     // create a single Parameter instance for analyzing callers
     // of the corresponding method/function.
     // e.g. $this->getUnionType() is of type T[]
     //      $this->non_variadic->getUnionType() is of type T
     return new Parameter($this->getContext(), $this->getName(), $this->getVariadicElementUnionType(), Flags::bitVectorWithState($this->getFlags(), \ast\flags\PARAM_VARIADIC, false));
 }
All Usage Examples Of Phan\Language\Element\Flags::bitVectorWithState