Index: src/wp-includes/post.php
===================================================================
--- src/wp-includes/post.php	(revision 50923)
+++ src/wp-includes/post.php	(working copy)
@@ -2558,7 +2558,7 @@
 			} else {
 				$value = format_to_edit( $value );
 			}
-		} else {
+		} elseif ( ! in_array( $field, $int_fields, true ) || ! is_int( $value ) ) {
 			$value = esc_attr( $value );
 		}
 	} elseif ( 'db' === $context ) {
@@ -2626,10 +2626,12 @@
 			$value = apply_filters( "post_{$field}", $value, $post_id, $context );
 		}
 
-		if ( 'attribute' === $context ) {
-			$value = esc_attr( $value );
-		} elseif ( 'js' === $context ) {
-			$value = esc_js( $value );
+		if ( ! in_array( $field, $int_fields, true ) || ! is_int( $value ) ) {
+			if ( 'attribute' === $context ) {
+				$value = esc_attr( $value );
+			} elseif ( 'js' === $context ) {
+				$value = esc_js( $value );
+			}
 		}
 	}
 
Index: tests/phpunit/tests/post/objects.php
===================================================================
--- tests/phpunit/tests/post/objects.php	(revision 50923)
+++ tests/phpunit/tests/post/objects.php	(working copy)
@@ -184,6 +184,23 @@
 		$this->assertSame( esc_js( "Mary's home" ), $raw_post->post_title );
 	}
 
+	/**
+	 * @ticket 52995
+	 */
+	function test_numeric_properties_should_be_cast_to_ints() {
+		$post_id  = self::factory()->post->create();
+		$contexts = array( 'raw', 'edit', 'db', 'display', 'attribute', 'js' );
+
+		foreach ( $contexts as $context ) {
+			$post = get_post( $post_id, OBJECT, $context );
+
+			$this->assertSame( $context, $post->filter );
+			$this->assertInternalType( 'int', $post->ID );
+			$this->assertInternalType( 'int', $post->post_parent );
+			$this->assertInternalType( 'int', $post->menu_order );
+		}
+	}
+
 	function test_get_post_identity() {
 		$post = get_post( self::factory()->post->create() );
 
