Question: I dont know if I can post this here or not. But a strange thing happened recently. 

I use pycharm to run my python codes and surprisingly when I opened a piece of my code - it got deleted. The file is 0KB now - for some reason. I am using this file for over a month now and this happened when I opened it and the file automatically got deleted from pycharm and next it became 0KB.

When I tried to delete this file: 

I get the following 

Error 0xx800710FE: This file is currently not available for use on this computer

Answer: 
See [Define a form option allowed values depending on another option value in a FormType](https://stackoverflow.com/questions/35204850/define-a-form-option-allowed-values-depending-on-another-option-value-in-a-formt/35215869#35215869).

You should use a **normalizer** for this:

```
use Symfony\Component\Form\Exception\InvalidConfigurationException;

$resolver->setNormalizer('data', function(Options $options, $data) {
    if (!$data instanceof Foo && !$data instanceof Bar) {
        throw new InvalidConfigurationException('"data" option must implement "Foo" and "Bar" interfaces.');
    }

    return $data;
});

```
Finally, I found a way but I'm not sure at all that it's a conventional way:

```
//...
function is_foobar($value) {
    //return true or false;
}

$resolver = new OptionsResolver();
$resolver->setRequired('data');
$resolver->setAllowedTypes('data', 'foobar');
//...

```

---

**EDIT:**

Well, after I sleep on, I think my approach is wrong, because it's already done by using `setAllowedValues` or `addAllowedValues` methods:

```
$resolver->setAllowedValues('foo', function ($value) {
    return $value instanceof Foo && $value instanceof Bar;
});

```

So it's not necessary to use `setAllowedTypes` for this purpose.