Datastore/src/Key.php
public function ancestor($kind, $identifier, array $options = [])
    {
        $options += [
            'identifierType' => null
        ];

        $pathElement = $this->normalizeElement($kind, $identifier, $options['identifierType']);

        array_unshift($this->path, $pathElement);

        return $this;
    }
public function ancestor($kind, $identifier, array $options = [])
    {
        $options += [
            'identifierType' => null
        ];

        $pathElement = $this->normalizeElement($kind, $identifier, $options['identifierType']);

        array_unshift($this->path, $pathElement);

        return $this;
    }
public function ancestor ( $ kind , $ identifier , array $ options = [ ] ) { $ options += [ 'identifierType' => null ] ; $ pathElement = $ this -> normalizeElement ( $ kind , $ identifier , $ options [ 'identifierType' ] ) ; array_unshift ( $ this -> path , $ pathElement ) ; return $ this ; }
Add a path element to the beginning of the Key path.

Example:
```
$key->ancestor('Person', 'Jane');
```

```
// In cases where the identifier type is ambiguous, you can choose the
// type to be used.

$key->ancestor('Robots', '1337', [
'identifierType' => Key::TYPE_NAME
]);
```

@see https://cloud.google.com/datastore/reference/rest/v1/Key#PathElement PathElement

@param string $kind The kind.
@param string|int $identifier The name or ID of the object.
@param array $options {
Configuration Options

@type string $identifierType [optional] If omitted, the type will be
determined internally. Setting this to either `Key::TYPE_ID` or
`Key::TYPE_NAME` will force the pathElement identifier type.
}
@return Key
Add a path element to the beginning of the Key path .