{"id":230587,"date":"2022-12-07T10:30:00","date_gmt":"2022-12-07T07:30:00","guid":{"rendered":"https:\/\/wordpress.mediadoma.com\/?p=230587"},"modified":"2022-11-09T23:05:14","modified_gmt":"2022-11-09T20:05:14","slug":"prostij-sposib-perevesti-standartnij-klas-php-u-pevnij-tip","status":"publish","type":"post","link":"https:\/\/wordpress.mediadoma.com\/uk\/prostij-sposib-perevesti-standartnij-klas-php-u-pevnij-tip\/","title":{"rendered":"\u041f\u0440\u043e\u0441\u0442\u0438\u0439 \u0441\u043f\u043e\u0441\u0456\u0431 \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0438\u0439 \u043a\u043b\u0430\u0441 PHP \u0443 \u043f\u0435\u0432\u043d\u0438\u0439 \u0442\u0438\u043f"},"content":{"rendered":"\n<p>\u042f\u043a\u0449\u043e \u0432\u0438 \u043f\u0440\u0430\u0446\u044e\u0454\u0442\u0435 \u0437 \u043e\u0431&#8217;\u0454\u043a\u0442\u043d\u043e-\u043e\u0440\u0456\u0454\u043d\u0442\u043e\u0432\u0430\u043d\u0438\u043c PHP \u0443 WordPress \u0456 \u0431\u0443\u0434\u0443\u0454\u0442\u0435 \u0440\u0456\u0437\u043d\u0456 \u043c\u043e\u0434\u0435\u043b\u0456, \u044f\u043a\u0456 \u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u0430\u044e\u0442\u044c \u0432\u0430\u0448\u0438\u043c \u0432\u0435\u0431-\u0434\u043e\u0434\u0430\u0442\u043a\u0430\u043c, \u0432\u0435\u043b\u0438\u043a\u0430 \u0439\u043c\u043e\u0432\u0456\u0440\u043d\u0456\u0441\u0442\u044c, \u0449\u043e \u0432\u0438 \u043c\u0430\u0442\u0438\u043c\u0435\u0442\u0435 \u0441\u043f\u0440\u0430\u0432\u0443 \u0437 \u043e\u0442\u0440\u0438\u043c\u0430\u043d\u043d\u044f\u043c \u0441\u0435\u0440\u0456\u0430\u043b\u0456\u0437\u043e\u0432\u0430\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0456\u0439 \u0446\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0443 \u044f\u043a\u0438\u0439\u0441\u044c \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0456\u0434 \u0447\u0430\u0441 \u0432\u0438\u043a\u043e\u043d\u0430\u043d\u043d\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u0438.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a \u043e\u0441\u044c \u0449\u043e: \u0456\u043d\u043e\u0434\u0456 \u043d\u0435\u0441\u0435\u0440\u0456\u0430\u043b\u0456\u0437\u043e\u0432\u0430\u043d\u0456 \u0434\u0430\u043d\u0456 \u043f\u043e\u0432\u0435\u0440\u0442\u0430\u044e\u0442\u044c\u0441\u044f \u044f\u043a \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0456 \u043a\u043b\u0430\u0441\u0438 PHP. \u0426\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0454, \u0449\u043e \u044f\u043a\u0449\u043e \u0432\u0438 \u043f\u0435\u0440\u0435\u0432\u0456\u0440\u0438\u0442\u0435 \u0442\u0438\u043f (\u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e \u0440\u0456\u0437\u043d\u0438\u0445 \u0456\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0456\u0432 \u043d\u0430\u043b\u0430\u0433\u043e\u0434\u0436\u0435\u043d\u043d\u044f), \u0432\u0438 \u043f\u043e\u0431\u0430\u0447\u0438\u0442\u0435, \u0449\u043e \u0446\u0435 \u0442\u0438\u043f <a href=\"https:\/\/php.net\/manual\/en\/language.types.object.php#language.types.object.casting\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">stdClass<\/a>.<\/p>\n<p>\u042f\u043a\u0449\u043e \u0432\u0438 \u043d\u0430\u043b\u0435\u0436\u043d\u0438\u043c \u0447\u0438\u043d\u043e\u043c \u0431\u0443\u0434\u0443\u0432\u0430\u043b\u0438 \u0441\u0432\u043e\u0457 \u043c\u043e\u0434\u0435\u043b\u0456, \u0432\u0430\u0448 \u043a\u043e\u0434 \u043c\u0430\u0442\u0438\u043c\u0435 \u0444\u0443\u043d\u043a\u0446\u0456\u0457, \u044f\u043a\u0438\u0445 \u043d\u0435\u043c\u0430\u0454 \u0443 <strong>stdClass<\/strong>, \u0456 \u0432\u0438 \u0437\u0430\u0445\u043e\u0447\u0435\u0442\u0435 \u0457\u0445 \u0432\u0438\u043a\u043b\u0438\u043a\u0430\u0442\u0438.<\/p>\n<p>\u041a\u0440\u0456\u043c \u0442\u043e\u0433\u043e, \u0432\u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0457\u0445 \u0432\u0456\u0434 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0443 \u0434\u043e \u0456\u043d\u0448\u043e\u0433\u043e, \u044f\u043a \u0446\u0435 \u043c\u043e\u0436\u043d\u0430 \u0437\u0440\u043e\u0431\u0438\u0442\u0438 \u0437 \u0440\u0456\u0434\u043d\u0438\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 (\u0442\u0430\u043a\u0438\u043c\u0438 \u044f\u043a \u0440\u044f\u0434\u043a\u0438, \u0446\u0456\u043b\u0456 \u0447\u0438\u0441\u043b\u0430 \u0442\u043e\u0449\u043e). \u0423 \u043f\u043e\u0434\u0456\u0431\u043d\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0456\u044f\u0445 \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u043c\u0430\u0442\u0438 \u043c\u043e\u0436\u043b\u0438\u0432\u0456\u0441\u0442\u044c \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0438\u0439 \u043a\u043b\u0430\u0441 PHP \u0434\u043e \u043f\u0435\u0432\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0443.<\/p>\n<p>\u0406 \u043e\u0441\u044c \u0444\u0443\u043d\u043a\u0446\u0456\u044f, \u044f\u043a\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0436\u0435 \u0432\u0430\u043c \u0446\u0435 \u0437\u0440\u043e\u0431\u0438\u0442\u0438.<\/p>\n<h2>\u041f\u0435\u0440\u0435\u0432\u0435\u0434\u0456\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0438\u0439 \u043a\u043b\u0430\u0441 PHP \u0434\u043e \u043f\u0435\u0432\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0443<\/h2>\n<p>\u0414\u043b\u044f \u0446\u044c\u043e\u0433\u043e \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u0443 \u043f\u0440\u0438\u043f\u0443\u0441\u0442\u0438\u043c\u043e \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u0435:<\/p>\n<ol>\n<li>\u0423 \u043c\u0435\u043d\u0435 \u0454 \u043a\u043b\u0430\u0441 \u0456\u0437 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u043e\u043c \u0456\u043c\u0435\u043d <strong>AcmeModelProduct<\/strong>.<\/li>\n<li>\u0423 \u044f\u043a\u0438\u0439\u0441\u044c \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0456\u043d \u0437\u0431\u0435\u0440\u0456\u0433\u0430\u0454\u0442\u044c\u0441\u044f \u0432 \u0431\u0430\u0437\u0456 \u0434\u0430\u043d\u0438\u0445 WordPress, \u0430\u043b\u0435 \u043f\u0440\u0438 \u043e\u0442\u0440\u0438\u043c\u0430\u043d\u043d\u0456 \u0432\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u044e\u0454\u0442\u044c\u0441\u044f \u044f\u043a \u0435\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <strong>stdClass<\/strong>.<\/li>\n<li>\u041c\u0435\u043d\u0456 \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u0430 \u043d\u0435\u0441\u0435\u0440\u0456\u0430\u043b\u0456\u0437\u043e\u0432\u0430\u043d\u0430 \u0432\u0435\u0440\u0441\u0456\u044f \u043e\u0431\u2019\u0454\u043a\u0442\u0430, \u0449\u043e\u0431 \u0431\u0443\u0442\u0438 \u0432\u0435\u0440\u0441\u0456\u0454\u044e <strong>Product<\/strong>.<\/li>\n<\/ol>\n<p>\u0417 \u0446\u0456\u0454\u044e \u043c\u0435\u0442\u043e\u044e \u0443 \u043c\u0435\u043d\u0435 \u0454 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0442\u0430\u043a\u0430 \u0444\u0443\u043d\u043a\u0446\u0456\u044f, \u044f\u043a\u0443 \u044f \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0438 <strong><a href=\"https:\/\/gist.github.com\/tommcfarlin\/49aae6f2d029b369b2c4bdb35c7b8107#file-00-cast-class-to-type-php\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">, \u043a\u043e\u043b\u0438 \u043c\u0435\u043d\u0456 \u0446\u0435 \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e:<\/a><\/strong><\/p>\n<pre><code>&lt;?php\n\/**\n * This function will take an instance of a PHP stdClass and attempt to cast it to\n * the type of the specified $className.\n *\n * For example, we may pass 'AcmeModelProduct' as the $className.\n *\n * @param object $instance  an instance of the stdClass to convert\n * @param string $className the name of the class type to which we want to cals\n *\n * @return mixed a version of the incoming $instance casted as the specified className\n *\/\nprotected function cast($instance, $className)\n{\n    return unserialize(sprintf(\n        'O:%d:\"%s\"%s',\n        strlen($className),\n        $className,\n        strstr(strstr(serialize($instance), '\"'), ':')\n    ));\n}\n<\/code><\/pre>\n<p>\u0417\u0432\u0456\u0441\u043d\u043e, \u200b\u200b\u0444\u0443\u043d\u043a\u0446\u0456\u044f \u043f\u0440\u043e\u043a\u043e\u043c\u0435\u043d\u0442\u043e\u0432\u0430\u043d\u0430 \u043d\u0430\u0441\u0442\u0456\u043b\u044c\u043a\u0438 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e, \u043d\u0430\u0441\u043a\u0456\u043b\u044c\u043a\u0438 \u044f \u043c\u043e\u0436\u0443 \u043d\u0430\u0434\u0430\u0442\u0438, \u0430\u043b\u0435 \u0454 \u043a\u0456\u043b\u044c\u043a\u0430 \u0440\u0435\u0447\u0435\u0439, \u044f\u043a\u0456 \u044f \u043c\u043e\u0436\u0443 \u043f\u043e\u044f\u0441\u043d\u0438\u0442\u0438 \u0442\u0440\u043e\u0445\u0438 \u0434\u043e\u043a\u043b\u0430\u0434\u043d\u0456\u0448\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0456 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457, \u043d\u0456\u0436 \u0443 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0456 \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0440\u044f \u0434\u043e \u043a\u043e\u0434\u0443.<\/p>\n<h3>\u0420\u043e\u0437\u0443\u043c\u0456\u043d\u043d\u044f \u041a\u043e\u0434\u0435\u043a\u0441\u0443<\/h3>\n<p>\u041f\u043e-\u043f\u0435\u0440\u0448\u0435, \u0432\u0430\u0436\u043b\u0438\u0432\u043e \u043f\u0435\u0440\u0435\u043a\u043e\u043d\u0430\u0442\u0438\u0441\u044f, \u0449\u043e \u0432\u0438 \u0440\u043e\u0437\u0443\u043c\u0456\u0454\u0442\u0435 \u0442\u0430\u043a\u0456 \u0444\u0443\u043d\u043a\u0446\u0456\u0457 PHP (\u0443\u0441\u0456 \u0432\u043e\u043d\u0438 \u0447\u0456\u0442\u043a\u043e \u0432\u0438\u0437\u043d\u0430\u0447\u0435\u043d\u0456 \u0432 \u043f\u043e\u0441\u0456\u0431\u043d\u0438\u043a\u0443 PHP):<\/p>\n<ul>\n<li><a href=\"https:\/\/php.net\/manual\/en\/function.unserialize.php\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">\u0434\u0435\u0441\u0435\u0440\u0456\u0430\u043b\u0456\u0437\u0443\u0432\u0430\u0442\u0438<\/a>. \u0421\u0442\u0432\u043e\u0440\u044e\u0454 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f PHP \u0456\u0437 \u0437\u0431\u0435\u0440\u0435\u0436\u0435\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044f.<\/li>\n<li><a href=\"https:\/\/php.net\/manual\/en\/function.sprintf.php\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">sprintf<\/a>. \u041f\u043e\u0432\u0435\u0440\u0442\u0430\u0454 \u0432\u0456\u0434\u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432\u0430\u043d\u0438\u0439 \u0440\u044f\u0434\u043e\u043a<\/li>\n<li><strong><a href=\"https:\/\/php.net\/manual\/en\/function.sprintf.php\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">strlen<\/a><\/strong>. \u041e\u0442\u0440\u0438\u043c\u0430\u0442\u0438 \u0434\u043e\u0432\u0436\u0438\u043d\u0443 \u0440\u044f\u0434\u043a\u0430<\/li>\n<li><a href=\"https:\/\/php.net\/manual\/en\/function.strstr.php\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">strstr<\/a>. \u0417\u043d\u0430\u0439\u0434\u0456\u0442\u044c \u043f\u0435\u0440\u0448\u0435 \u0432\u0445\u043e\u0434\u0436\u0435\u043d\u043d\u044f \u0440\u044f\u0434\u043a\u0430.<\/li>\n<li><a href=\"https:\/\/php.net\/manual\/en\/function.serialize.php\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">\u0441\u0435\u0440\u0456\u0430\u043b\u0456\u0437\u0443\u0432\u0430\u0442\u0438<\/a>. \u0421\u0442\u0432\u043e\u0440\u044e\u0454 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f, \u044f\u043a\u0435 \u043c\u043e\u0436\u043d\u0430 \u0437\u0431\u0435\u0440\u0435\u0433\u0442\u0438.<\/li>\n<\/ul>\n<p>\u041e\u0442\u0436\u0435, \u0442\u0430\u043a, \u0432\u0445\u0456\u0434\u043d\u0438\u0439 \u0435\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0443 \u043e\u0442\u0440\u0438\u043c\u0443\u0454\u0442\u044c\u0441\u044f, \u0430 \u043f\u043e\u0442\u0456\u043c \u043f\u0435\u0440\u0435\u0442\u0432\u043e\u0440\u044e\u0454\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u0442\u0438\u043f, \u0430\u043b\u0435 \u044f\u043a\u0443 \u0440\u043e\u043b\u044c \u0443 \u0446\u044c\u043e\u043c\u0443 \u0432\u0456\u0434\u0456\u0433\u0440\u0430\u044e\u0442\u044c \u043d\u0430\u0432\u0435\u0434\u0435\u043d\u0456 \u0432\u0438\u0449\u0435 \u0444\u0443\u043d\u043a\u0446\u0456\u0457? \u0426\u0435 \u043f\u043e\u0432\u2019\u044f\u0437\u0430\u043d\u043e \u0437 \u0442\u0438\u043c, \u044f\u043a \u043a\u043b\u0430\u0441 \u0441\u0435\u0440\u0456\u0430\u043b\u0456\u0437\u0443\u0454\u0442\u044c\u0441\u044f \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u0438\u0445 WordPress.<\/p>\n<p>\u0412\u0456\u0437\u044c\u043c\u0435\u043c\u043e, \u043d\u0430\u043f\u0440\u0438\u043a\u043b\u0430\u0434, <strong><a href=\"https:\/\/gist.github.com\/tommcfarlin\/49aae6f2d029b369b2c4bdb35c7b8107#file-01-serialized-data-php\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">\u0442\u0430\u043a\u0438\u0439 \u0440\u044f\u0434\u043e\u043a:<\/a><\/strong><\/p>\n<pre><code>O:17:\"AcmeModelProduct\":8:{s:25:\"\ufffdAcmeModelProduct\ufffdnumber\";s:3:\"532\";s:23:\"\ufffdAcmeModelProduct\ufffdname\";s:23:\"Aura Bath &amp; Spa - Matte\";s:27:\"\ufffdAcmeModelProduct\ufffdlongName\";s:56:\"Aura Bath &amp; Spa Waterborne Interior Paint - Matte Finish\";s:22:\"\ufffdAcmeModelProduct\ufffdurl\";s:37:\"http:\/\/www.benjaminmoore.com\/aura_532\";s:27:\"\ufffdAcmeModelProduct\ufffdshortUrl\";s:9:\"\/aura_532\";s:26:\"\ufffdAcmeModelProduct\ufffdimage1x\";s:153:\"www2.benjaminmoore.com\/ShowPropertyServlet?nodePath=\/BEA Repository\/imagerepository\/public_site\/product_images_new\/IA_pri_0532\/\/image_88x86.content_en_US\";s:26:\"\ufffdAcmeModelProduct\ufffdimage2x\";s:155:\"www2.benjaminmoore.com\/ShowPropertyServlet?nodePath=\/BEA Repository\/imagerepository\/public_site\/product_images_new\/IA_pri_0532\/\/image_197x193.content_en_US\";s:26:\"\ufffdAcmeModelProduct\ufffdimage3x\";s:155:\"www2.benjaminmoore.com\/ShowPropertyServlet?nodePath=\/BEA Repository\/imagerepository\/public_site\/product_images_new\/IA_pri_0532\/\/image_197x193.content_en_US\";}<\/code><\/pre>\n<p>\u042f \u0437\u043d\u0430\u044e \u2013 \u043f\u0435\u0440\u0435\u0433\u043b\u044f\u0434\u0430\u0442\u0438 \u0446\u0435 \u043d\u0435 \u0437\u043e\u0432\u0441\u0456\u043c \u043f\u0440\u0438\u0454\u043c\u043d\u043e, \u0430\u043b\u0435 \u0441\u0430\u043c\u0435 \u0442\u0430\u043a WordPress \u0441\u0435\u0440\u0456\u0430\u043b\u0456\u0437\u0443\u0454 \u043e\u0431\u2019\u0454\u043a\u0442. \u041a\u0440\u0456\u043c \u0442\u043e\u0433\u043e, \u043a\u043e\u043b\u0438 \u0439\u043e\u0433\u043e \u0432\u0438\u0442\u044f\u0433\u0443\u044e\u0442\u044c \u0456\u0437 \u0431\u0430\u0437\u0438 \u0434\u0430\u043d\u0438\u0445, \u0446\u0435 \u0440\u043e\u0431\u0438\u0442\u044c\u0441\u044f, \u0430 \u043f\u043e\u0442\u0456\u043c \u043f\u043e\u0432\u0435\u0440\u0442\u0430\u0454\u0442\u044c\u0441\u044f \u044f\u043a \u0435\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <strong>stdClass<\/strong>, \u0430 \u043d\u0435 \u044f\u043a \u0435\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0443, \u044f\u043a\u0438\u043c \u0432\u0456\u043d \u0431\u0443\u0432 \u0434\u043e \u0437\u0431\u0435\u0440\u0435\u0436\u0435\u043d\u043d\u044f.<\/p>\n<p>\u041e\u0441\u044c \u0442\u0443\u0442 \u0456 \u0432\u0441\u0442\u0443\u043f\u0430\u0454 \u0432 \u0434\u0456\u044e \u0437\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0432\u0438\u0449\u0435 \u0444\u0443\u043d\u043a\u0446\u0456\u044f. \u0429\u043e\u0431 \u0432\u0456\u0434\u043d\u043e\u0432\u0438\u0442\u0438 \u0439\u043e\u0433\u043e \u0442\u0438\u043f \u0443\u0433\u043e\u0434\u0438, \u0432\u0438 \u0437\u0430\u0445\u043e\u0447\u0435\u0442\u0435 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0439\u043e\u0433\u043e \u044f\u043a \u0442\u0430\u043a\u0438\u0439. \u0406 \u0434\u043b\u044f \u0446\u044c\u043e\u0433\u043e \u0432\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0440\u043e\u0431\u0438\u0442\u0438 \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u0435:<\/p>\n<pre><code>&lt;?php\n$exampleObject = get_option('acmeModelProject', null);\nif (null === $exampleObject) {\n  return;\n}\n\n$exampleObject = $this-&gt;cast($exampleObject, 'AcmeModelProduct');\n<\/code><\/pre>\n<p>\u0417\u0430\u0443\u0432\u0430\u0436\u0442\u0435, \u0449\u043e \u044f \u043e\u0442\u0440\u0438\u043c\u0443\u044e \u043e\u0431\u2019\u0454\u043a\u0442, \u044f\u043a\u0438\u0439 \u0431\u0443\u043b\u043e \u0441\u0435\u0440\u0456\u0430\u043b\u0456\u0437\u043e\u0432\u0430\u043d\u043e \u0434\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0456 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0456\u0432. \u042f \u043d\u0435 \u0434\u043e\u0432\u043e\u0434\u0436\u0443, \u0447\u0438 \u0432\u0430\u0440\u0442\u043e \u0432\u0430\u043c \u0446\u0435 \u0440\u043e\u0431\u0438\u0442\u0438 \u0447\u0438 \u043d\u0456, \u0446\u0435 \u0434\u043b\u044f \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u0443.<\/p>\n<p>\u041f\u043e- \u0434\u0440\u0443\u0433\u0435, \u0437\u0430\u0443\u0432\u0430\u0436\u0442\u0435, \u0449\u043e \u044f \u0432\u0438\u043a\u043b\u0438\u043a\u0430\u044e <strong>cast<\/strong> \u0434\u043b\u044f \u0435\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 <strong>$this<\/strong>, \u0442\u043e\u043c\u0443 <strong>$this<\/strong> \u043c\u043e\u0436\u0435 \u0431\u0443\u0442\u0438 \u0435\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c \u043a\u043b\u0430\u0441\u0443 \u0430\u0431\u043e \u0446\u0435 \u043c\u043e\u0436\u0435 \u0431\u0443\u0442\u0438 \u043c\u0435\u0442\u043e\u0434 \u0443 \u0431\u0430\u0437\u043e\u0432\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0456. \u0426\u0435 \u043d\u0435 \u043c\u0430\u0454 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f (\u044f\u043a\u0449\u043e \u043e\u0441\u0442\u0430\u043d\u043d\u0456\u0439 \u043f\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u043e \u044f\u043a <strong>\u0437\u0430\u0445\u0438\u0449\u0435\u043d\u0438\u0439<\/strong> ).<\/p>\n<p>\u0417 \u0446\u044c\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0443 \u0443 \u0432\u0430\u0441 \u0454 \u0435\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0443, \u044f\u043a\u0438\u0439 \u0432\u0438 \u0441\u043f\u043e\u0447\u0430\u0442\u043a\u0443 \u0437\u0431\u0435\u0440\u0435\u0433\u043b\u0438, \u0437 \u0443\u0441\u0456\u0454\u044e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u044e \u0434\u043b\u044f \u0432\u0430\u0441 \u0456\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0456\u0454\u044e, \u0442\u0430\u043a \u0431\u0438 \u043c\u043e\u0432\u0438\u0442\u0438, \u043a\u043e\u043b\u0438 \u0432\u0438 \u0439\u043e\u0433\u043e \u0432\u043f\u0435\u0440\u0448\u0435 \u0437\u0431\u0435\u0440\u0435\u0433\u043b\u0438.<\/p>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">\u0414\u0436\u0435\u0440\u0435\u043b\u043e \u0437\u0430\u043f\u0438\u0441\u0443:  <a target=\"_blank\" rel=\"noopener nofollow\" href=\"\/\/tommcfarlin.com\" class=\"external external_icon\">tommcfarlin.com<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412\u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0457\u0445 \u0432\u0456\u0434 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0443 \u0434\u043e \u0456\u043d\u0448\u043e\u0433\u043e, \u044f\u043a \u0446\u0435 \u043c\u043e\u0436\u043d\u0430 \u0437\u0440\u043e\u0431\u0438\u0442\u0438 \u0437 \u0440\u0456\u0434\u043d\u0438\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 (\u0442\u0430\u043a\u0438\u043c\u0438 \u044f\u043a \u0440\u044f\u0434\u043a\u0438, \u0446\u0456\u043b\u0456 \u0447\u0438\u0441\u043b\u0430 \u0442\u043e\u0449\u043e). \u0423 \u043f\u043e\u0434\u0456\u0431\u043d\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0456\u044f\u0445 \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u043c\u0430\u0442\u0438 \u043c\u043e\u0436\u043b\u0438\u0432\u0456\u0441\u0442\u044c \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0438\u0439 \u043a\u043b\u0430\u0441 PHP \u0434\u043e \u043f\u0435\u0432\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0443.<\/p>\n","protected":false},"author":1,"featured_media":236170,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[808],"tags":[1174],"class_list":["post-230587","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php-10","tag-affiai-uk"],"_links":{"self":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/posts\/230587","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/comments?post=230587"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/posts\/230587\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/media\/236170"}],"wp:attachment":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/media?parent=230587"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/categories?post=230587"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/tags?post=230587"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}