During his periods of nightly shutdown, Data's dream program begins manifesting bizarre and nonsensical nightmares that Data has difficulty deciphering the meanings of. The situation becomes more serious, however, when Data begins oversleeping, then having periods of waking dreams — and things become dire when he eventually begins sleepwalking during those waking dreams and doing bad stuff, like, say, stabbing Counselor Troi.
I've talked recently about Good Brannon Braga. "Phantasms" is more like B-grade Decent Brannon Braga, but it still gets an endorsement from me because it has the benefit of being amusing. The best way to approach "Phantasms" is to look at it as weirdness for weirdness' sake. On that level it works. It benefits from some bizarre and funny images and has a tone that strikes the right balance of strange, funny, and downright goofy. It does all of this while also tying everything into a fairly routine — and definitely Braga-esque — tech/alien mystery involving interphasic parasites from another dimension (or something) which, if not expunged, will cause the entire crew to lose cellular cohesion and disintegrate. You know, the part of the plot that makes sense compared to Data's nightmares.
This is the logical plot-based non-character outgrowth of Data dreaming, established in last year's "Birthright, Part I." It involves Troi as a human cake being cut up, Worf commenting on its deliciousness ("It is a cellular peptide cake"), a trio of 19th-century laborers dismantling a corridor on the Enterprise, a telephone that won't stop ringing inside Data's chest, Crusher drinking Riker's brain through a straw, and, of course, Dr. Sigmund Freud (Bernard Kates) deconstructing it all in the holodeck and recommending Data undergo full psychoanalysis. Of course, all of that pales in comparison to Data becoming a mad slasher, stalking Troi through the corridor, and then stabbing her in the turbolift in a perfectly framed payoff shot that echoes Norman Bates in Psycho. When I look at that list, what's not to like?
All of this is happening for a reason, naturally. It's shortly after the stabbing that Crusher discovers the invisible alien parasites from another dimension, and it's learned that Data's dreams are actually subconscious manifestations of his program having detected them on their wavelength. The meanings behind the images line up with the happenings aboard the Enterprise as a result of the alien presence; within the clues lie the answer of how to destroy them. So Picard and Geordi use the holodeck to enter Data's dream and try to crack the mystery. This leads to a lengthy sequence where Data's dream is broken down, symbol by symbol, with Picard and Geordi providing running commentary to explain how the puzzle all fits together. This is more arbitrary than enlightening, but it gets the story from A to B.
All of this is leavened by its humor. In addition to the story's clear amusement with its own goofiness, we also have a running gag about Picard potentially missing a conference that he absolutely would love to miss but has been sternly warned by the admiral to absolutely not miss it without a really good reason. As I said before, this is the nuts-and-bolts approach to Data as a piece of hardware instead of an exploration of what nightmares mean to him as a character, but sometimes hardware is what we enjoy in our TNG.