When you declare a class attribute as 0 or higher, and initialise it as 0. Then adding 0 or 1 to it, should not be a problem. It's still 0 or higher.
<?php
class Bar {
/**
* @var int
* @psalm-var 0|positive-int
*/
protected $depth = 0;
function foo(bool $isRoot): void {
$this->depth += $isRoot ? 0 : 1;
}
}