My AppleScript skills are pretty rusty, but if not opposed to using a GUI script you could try:
tell application "Finder"
activate
if (count windows) is 0 then make new Finder window
end tell
delay 3
tell application "System Events"
tell process "Finder"
try
--change the row number below for your situation
click button "Eject" of UI element 1 of row 18 of outline 1 of scroll area 1 of splitter group 1 of window 1
end try
end tell
end tell
delay 3
tell application "Finder"
close window 1
end tell
The script assumes the Finder sidebar items you've chosen to show are static. To get the row number to use in the script, with iPhone attached, count the rows of text, including sidebar headings (e.g., Favorites, iCloud, and Locations), from the top to the row with iPhone. The delays are there so you can see if the script is working. You might try the script with reduced delays or eliminate them altogether. The row the iPhone shows up in Finder's sidebar when connected should (maybe?) be consistent. At least it is on my Mac.