Updated: Constructing a bijection between $\left(-\frac{\pi}{2}, \frac{\pi}{2}\right]$ and $\mathbb{R}$ I am supposed to construct a bijective function for the interval:
\begin{align}
I_2=\left(-\frac{\pi}{2} ,\frac{\pi}{2} \right] \longrightarrow \mathbb{R} \tag{Problem}
\end{align}
I first tried the easier case, i.e.
\begin{align}f_1:I_1=\left(-\frac{\pi}{2} ,\frac{\pi}{2} \right) &\longrightarrow \mathbb{R} \\ x& \longmapsto \tan(x)
\end{align}
which is a bijection. Now I know that the composition of bijective functions is still a bijection. Which means that it should be possible to 'make room' for the missing point $\pi/2$. The following function:
\begin{align}\phi : \mathbb{R} &\longrightarrow \mathbb{R \setminus}\lbrace 0 \rbrace \\ x & \longmapsto \begin{cases}x+1  \ \text{if} \ x \in \mathbb{N}_0 \\x \ \text{otherwise} \end{cases}\end{align} 
would be bijective, such that the composition $\phi \circ f_1: I_1 \rightarrow \mathbb{R}\setminus \lbrace 0 \rbrace  $ is bijective, and as desired it now has room for a point that I can map to.
At this point I am not sure if my approach is correct because I can't find a function that would do the trick. Would I need to come up with another composition or is it enough to define a function that maps to the functions introduced above?
Update (in consideration of the answers given)
If I understand things correctly I can define: \begin{align}f_2: I_2 &\longrightarrow \mathbb{R} \\ x& \longmapsto \begin{cases}\phi(x) \ \text{for}  \ x \in I_2 \\0 \ \text{for}  \ x=\frac{\pi}{2} \end{cases} \end{align}
Update 2 (Clarification required).
Define a new function to be equal to $\phi f_1$ over $I_1$ and have it map $π/2$ to $0$. As suggested (and upvoted) by @TBrendle.
If I do understand this correctly, then I need to map $x=\frac{\pi}{2}$ to $0$. However in this case it would make no sense to me to include $I_1$ in the domain, because $\pi/2$ is not in the domain, hence I don't see why I should include it in the codomain, however if I define:
\begin{align}w: I_2 &\longrightarrow \mathbb{R} \\ (\phi\circ f_1)(x) & \longmapsto \begin{cases} (\phi \circ f_1) \ \text{if} \ x \in I_2 \\ 0 \ \text{if} \ x= \frac{\pi}{2} \end{cases} \end{align}
This doesn't even look like a legitimate function to me anymore, since at $x=0$ the function evaluates to both $0$ and $1$. 
 A: Your approach is flawless. What were you worried about? Your function will be defined piecewise.
Added details:
Your new function is 
$$\psi : \left(-\frac{\pi}{2} \frac{\pi}{2}\right] \to \mathbb{R}$$
given by
$$   \psi(x) =
\begin{cases}
\phi(\tan x),  & \text{for }-\frac{\pi}{2} < x< \frac{\pi}{2} \\
0, & \text{for }  x=\frac{\pi}{2}\\
\end{cases}
$$
where $\phi$ is as given in the question. You can verify that the function $\psi$ has the specified domain and range and is a bijection.
A: Why not find a bijection from (-pi/2, pi/2] to the open interval and then compose with tangent?
A: This is a little kludgy, but I think it works.  Let
$$\begin{align}
f(x) &= {\pi/2-x\over x}\text{ for } 0\lt x\le\pi/2\cr
&={x-\pi/4\over x+\pi/4}\text{ for } -\pi/4\lt x\le 0\cr
&={4\over\pi}x+{1\over2}\text{ for } -3\pi/8\lt x\le-\pi/4\cr
&={4\over\pi}x+{5\over4}\text{ for } -7\pi/16\lt x\le-3\pi/8\cr
&=\text{etc.}\cr
\end{align}$$
where the "etc." means you've chopped the interval $(-\pi/2,-\pi/4]$ into finer and finer halves converging on $-\pi/2$ and assigned each interval a linear function with image $(-1/2^n,-1/2^{n+1}]$  The idea is that $(0,\pi/2]$ maps to $[0,\infty)$, $(-\pi/4,0]$ maps to $(-\infty,-1]$, and the rest of the half-open intervals map to $(-1,-1/2]\cup(-1/2,-1/4]\cup(-1/4,-1/8]\cup\cdots=(-1,0)$.
