Strategypage noted some time ago that missiles are getting better but a cannon just in case is prudent:
Most modern fighters (including the new F-22) still carry cannon and Sidewinders. This is not the result of excessive caution, but knowledge of how hairy air combat can get. The Wild Blue Yonder is a big place and no radar is perfect. Enemy aircraft can sneak in from behind mountains, hills, forests or radar jamming. The chance of finding your self within visual (and Sidewinder) range of enemy aircraft is still a very likely possibility.
But no, the F-22 does not carry a cannon internally (but the F-35 does even though nobody thinks they'll need to dogfight). Perhaps there is a gun pod that can be added.
Or maybe we think we don't need cannons--again.