Can't set PHP block visibility programatically Heres my code:

$blocks['membership_package_information'] = array( 
    'info' => "Membership Package Information",
    'visibility' => BLOCK_VISIBILITY_PHP,
    'pages' => membership_block_visibility(),
  );

function membership_block_visibility() {
  if(arg(0) == 'checkout' && arg(2) == null) {
    return true;
  }
  else {
    return false;
  }
}

I'm trying to limit the block to only show on the first page of the drupal commerce checkout page (checkout/[order-id]) and not the second (checkout/[order-id]/review) but its not working. When I put this code in the PHP visibility section of the block UI page, it works. I'd rather it be in my module, why wont it work? It seems that the UI settings are being picked up and not whats in my block.
Re: https://api.drupal.org/api/drupal/modules!block!block.api.php/function/hook_block_info/7 you have to put the actual PHP code "in" the pages array key...


  For BLOCK_VISIBILITY_PHP, the PHP code's return value should be TRUE if
  the block is to be made visible or FALSE if the block should not be
  visible.


...not set it to the return of a function, eg, something along these lines:

$blocks['membership_package_information'] = array( 
    'info' =&gt; "Membership Package Information",
    'visibility' =&gt; BLOCK_VISIBILITY_PHP,
    'pages' =&gt; '&lt;?php return membership_block_visibility(); ?&gt;' // ADDITION: you need the &lt;?php ?&gt; brackets :)
);

// make sure this function is in a module file that is always loaded...

function membership_block_visibility() {
  if(arg(0) == 'checkout' &amp;&amp; arg(2) == null) {
    return true;
  }
  else {
    return false;
  }
}


Do also note the caveat off the api page:


  Most modules do not provide an initial value for 'visibility' or
  'pages', and any value provided can be modified by a user on the block
  configuration screen.